master-lib.ss

The library master-lib.ss provides the single operation repl, which implements a simple read-evaluate-guess-and-print loop. The operation consumes the program check-guess and then plays MasterMind. The program check-guess is responsible for comparing the color guesses of a player with the (random) choices of repl.

The library provides only one operation:

  • repl : check-guess -> symbol;
    It prompts users for two colors (symbols) and uses check-guess to play mastermind.
    If the guesses completely match the set-up, check-guess must return 'PerfectGuess; otherwise it must return a different, informative symbol.
  • Legitimate colors are: black white blue red green gold pink brown purple navy
  • A user can terminate the game by typing quit instead of a color.

  • Sample session: First set library to master-lib.ss . Execute and play as follows:
    > (repl check-guess)
      Your next two guesses please: red black
      Not quite, but here is a clue: OneColorAtCorrectPosition
      Your next two guesses please: red green
      ...
      Congratulations!