Google

link="#009900" vlink="#007700" alink="#cc0000"> Teachpacks for How to Design Programs

Mastermind


master.ss

The teachpack master.ss provides the operation master. It implements a GUI for playing a simple master mind-like game. The player clicks on two colors and the program responds with an answer that indicates how many colors and places were correct.

The function master consumes the function check-guess, which is the key component of TeachMasterMind. The function check-guess consumes the two colors that the player guessed and the two players that the master chose (randomly at the beginning of the game). It compares the colors and produces an appropriate symbol.

The teachpack provides only one operation:

  • master : check-guess -> symbol;
    It prompts the user 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.