next up previous
Next: Here is your project Up: Project 2 Description Previous: Hangman

A Template For hangman-guess

Here is a template for hangman-guess:

(define hangman-guess
  (lambda (guess)
    (let ((new-status (reveal-list chosen-word status-word guess)))
      (cond
        ;New information has been revealed
       ((not (equal? new-status status-word))
        (cond
         ;Either the player has won
         ((equal? new-status chosen-word)
           ;[Output a congratulations statement]
           ;[Start a new game]
          )
         ;Or the player has a new status word
         (else
          (set! status-word new-status)
          ;[Output a good guess statement which includes the new status word]
          )))
        ;No new information
      (else
        ;The player has lost
        (if (null? body-parts-left)
            ;[Output a sorry you lost statement and start a new game]
            ;The player lost a body part
            (set! body-parts-left (cdr body-parts-left))              
              ;[Output a sorry, the body part lost and the status word]
             ))))))

Here is the reveal-list procedures

(define reveal-list
  (lambda (chosen-word status-word guess)
    (letrec ((reveal-one
              (lambda (chosen-letter status-letter)
                (cond
                 ((eq? chosen-letter guess) guess)
                 (else
                  status-letter)))))
      (map reveal-one chosen-word status-word))))



Patricia Gilfeather 2001-04-12