June 2013
Intermediate to advanced
312 pages
6h 47m
English
#|
You’ve installed DrRacket, learned that programs go into the definitions panel, and experimented with Racket in the interactions panel. You are now ready to write your first real program, a simple game for guessing numbers.
|#
The first game we will write is one of the simplest and oldest games around. It’s the classic Guess My Number game. In this game, the player thinks of a number between 1 and 100. Our program will then figure out that number by repeatedly making guesses and asking the player if her number is bigger or smaller than the current guess.
The following piece shows what a game might look like in the interactions panel if the player chose 18:
> (guess) 50 > (smaller) 25 ...