mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
BAGELS
Original source downloaded from Vintage Basic
Conversion to Ruby by Tom Armitage
Translator's notes:
This is a highly imperative port. As such, it's very much, in the spirit of David Ahl's original version, and also highly un-Rubyish.
A few decisions I made:
- the main loop is a 'while' loop. Most games are a main loop that runs until it doesn't, and I felt that "while the player wished to keep playing, the game should run" was an appropriate structure.
- lots of puts and gets; that feels appropriate to the Ahl implementation. No clever cli or curses libraries here.
- the number in question, and the player's answer, are stored as numbers. They're only converted into arrays for the purpose of
puts_clue_for- ie, when comparison is need. The original game stored them as arrays, which made sense, but given the computer says "I have a number in mind", I decided to store what was in its 'mind' as a number. - the
String#centermethod from Ruby 2.5~ sure is handy.