Note:

If you happen to find an error not corrected below, please send it to our Google email with Errata in the subject line.

(realmofracket AT gmail DOT com)

------------------------------------------------------------------

page viii Missing in print edition, Dedications

pages xvii--xviii Missing in print edition, Acknowledgments

page 29 The end of section 2.1 mistakenly claims that

Even if we played the game with numbers between 1 and 1,000,000, a binary strategy could guess the right number in about 10 guesses.

The correct statement is that

... a binary strategy could guess the right number in about 20 guesses.

Thanks to Joseph DiMuro for reporting this mistake.

page 31 The sixth paragraph of section 2.4 inaccurately states:

If the average number ends up being a fraction, we choose the nearest whole number.

Instead this sentence should read:

If the average number ends up being a fraction, we choose to round the result down to the nearest whole number.

Thanks to Holger Thomson for pointing out this error.

page 33 The explanation for the smaller function includes the following sentence:

By taking the max of lower and (sub1 (guess)), we ensure that bigger is never smaller than lower.

But the variable bigger does not appear in this context. The sentence should say that

By taking the max of lower and (sub1 (guess)), we ensure that upper is never smaller than lower.

Thanks to Nate Kidwell for pointing out the error.

page 53 At the end of the page, the image? predicate was used prior to the introduction of the 2htdp/image library and will not work. Instead the interactions to try should be:

              
> (number? 'a)
#f
> (integer? 837361738222)
#t
> (string? "hello world")
#t
> (symbol? 'a)
#t
> (boolean? "false")
#f
              
            

Thanks to Mary Lightheart for finding this oversight.

page 66 The definition of my-equal? is broken. The cond should start as follows:

	      
(cond 
  [(and (point? a) (point? b))
   (and (my-equal? (point-x a) (point-x b))
        (my-equal? (point-y a) (point-y b)))]
	      
	    

Thanks to Gordon Hartley for catching this problem.

page 75 The indentation for the winning-players function is incorrectly indented. The properly indented function looks like the following:

              
(define (winning-players lst)
  (define sorted-lst (sort lst ...))
  (define (winners lst pred)
    (cond
      [(empty? lst) (list pred)]
      [else
       (define fst (first lst))
       (if (score> (record-score pred) (record-score fst))
           (list pred)
           (cons pred (winners (rest lst) fst)))]))
  ;; START HERE:
  (winners (rest sorted-lst) (first sorted-lst)))
              
            

Thanks to Marvin Hernandez for finding this error.

page 81 Readers asked about the definitions of WIDTH and HEIGHT; as the book explains on page 72, "we will not show you all the constant definitions because we're more interested in talking about games than constants." The code in collects/realm in the Racket distribution is complete.

page 82 The interaction at the read-eval-print loop

(draw-a-ufo-onto-an-empty-canvas 33)

should read

(draw-a-ufo-onto-an-empty-scene 33)

Thanks to Ron Given, Mauricio Aldazosa, and Christopher D. Walborn for reporting this mistake.

page 102 The following sentence should be inserted directly below the definition of the rot function:

Find the definition of decay in the source code.

Thanks to Vitaly Samigullin and Dave Yrueta for reporting this oversight.

page 107 The render-end function calls the render-snake-world function, but should be calling render-pit instead.

Thank you to Uisang, Vitaly Samigullin and Dave Yrueta for finding this error.

page 114 The definition of the my-filter function takes in two parameters, but only one is supplied when recurring. The definition should read:

	      
(define (my-filter pred lst)
  (cond [(empty? lst) empty]
        [(pred (first lst))
         (cons (first lst) (my-filter pred (rest lst)))]
        [else (my-filter pred (rest lst))]))
	      
	    

Thanks to Dustin Kut Moy Cheung for spotting this error.

page 134 The explanation of player-health+ says that

If the result is larger than the desired maximum, internal+ produces the maximum.

There is no internal+ function. Instead it should say that the function uses interval+:

If the result is larger than the desired maximum, interval+ produces the maximum.

Thanks to Zack Hickman for sending in this correction.

page 136 The struct definition of orc-world near the top of the page has an extra parenthesis tacked on at the end. The snippet should read:

(struct orc-world (player lom attack# target) #:mutable)

Thanks to Ton-Kiat Tan for reporting this mistake.

page 143 The interaction with DrRacket near the top of the page is missing an initial target for render-monsters. Here is the correct interaction:

	      
> (beside (render-player (initialize-player))
          (above (render-monsters (initialize-monsters) #f)
                 (message "You win")))
	      
	    

Thanks to Diego Sevilla Ruiz for spotting this problem.

page 186 The first paragraph incorrectly states that:

Pictorially, the calculations proceed according to the diagrams on page 184.

The diagrams are on the next page, so the sentence should read:

Pictorially, the calculations proceed according to the diagrams on page 185.

Thanks to Sonoda for the catch.

page 204 The definition of game-tree does not match the definition on page 183 and is therefore out of sync with the rest of chapter 10. The correct definition is:

		
(define (game-tree board player dice)
  ;; create tree of attacks from this position; add passing move
  (define (attacks board)
    (for*/list ([src board]
                [dst (neighbors (territory-index src))]
                #:when (attackable? board player src dst))
      (define from (territory-index src))
      (define dice (territory-dice src))
      (define newb (execute board player from dst dice))
      (define more (delay (cons (passes newb) (attacks newb))))
      (move (list from dst) (game newb player more))))
  ;; create a passing move and the rest of the game tree
  (define (passes board)
    (define-values (new-dice newb) (distribute board player dice))
    (move ‘() (game-tree newb (switch player) new-dice)))
  ;; -- START: --
  (game board player (delay (attacks board))))
		
	      

Thanks to Ryan Davis for investigating this difference using the source code in collects/realm. Note that the source file in collects/realm slightly differs from the definition here in naming and indentation but is functionally equivalent.

page 205 The third paragraph (starting with "As you can see, ....") contains the sentence

"This function uses the locally defined game-moves and force."
This should read as
"This function uses the locally defined game-delayed-moves and force."

Thanks again to Sonoda for finding this error.

pages 282--283 The illustration is missing a panel. The two pages should be separated by Chad floating over an island.