Project idea thanks to Izaak Rubin
Mastermind is a game in which the goal is for the player to guess a hidden answer. It is, in a way, a very fancy "guess my number" type of game. For our purposes, there are two relevant numbers:
COLORS: The number of different colors that a piece in the answer might have
PEGS: The number of elements in the answer
TURNS: The number of guesses a player can make before being forced to give up
For example, suppose that we had six colors: RED, ORANGE, YELLOW, GREEN, BLUE, and PURPLE, and our answer for this particular game had four pegs. For a sample game, let's suppose these pegs were ORANGE BLUE PURPLE ORANGE. The user will keep guessing until entering this sequence at which point s/he wins or until some maximum number of guesses has been tried without success. Here is how game might go:
|RED ORANGE YELLOW GREEN||0 CORRECT 1 INCORRECT|
|YELLOW PURPLE PURPLE BLUE||1 CORRECT 1 INCORRECT|
|GREEN PURPLE BLUE GREEN||0 CORRECT 2 INCORRECT|
|BLUE RED PURPLE RED||1 CORRECT 1 INCORRECT|
|ORANGE BLUE PURPLE ORANGE||YOU WIN!|
Note that CORRECT means that a color in the solution was guessed in its correct position. In the second guess, for example, the third peg guessed is PURPLE which is where a PURPLE peg is in the solution. Notice further the other PURPLE peg in that guess was not counted in the context of the answer; a second PURPLE peg would need to be in the solution for the second PURPLE peg in the guess to count.
INCORRECT is something of a misnomer. INCORRECT means that a peg guessed is in the solution, just not in the place it was guessed. In the first guess, there is an ORANGE peg in the solution--in fact there are two ORANGE pegs in the solution. However, the user only guessed one ORANGE peg, so that's the most credit that will be given. Since there is no ORANGE peg in the second position, the feedback showed 1 INCORRECT. The feedback does not tell the user directly which color was right. It merely indicates some number of pegs in the right position (CORRECT) and some number in the wrong position (INCORRECT). If you hate CORRECT and INCORRECT and would like to find better words, that's fine. (If you want to somehow incorporate color and/or images in your game, there is code in DrScheme for that, and you can get some extra credit or just do it for kicks, depending on your situation. Documentation on MrEd, the graphics piece of DrScheme, can be found at http://download.plt-scheme.org/doc/)
The user should be able to choose the number of different colors up to a maximum of 10 and the number of pegs in the solution pattern up to a maximum of 8. (You can make your program more flexible, but from a user's perspective, it can be a nightmare keeping track of more than this.) The maximum number of guesses should be 10, although for testing purposes, you might want to start out with an unlimited number (or a very high number) of guesses.
In order to do this project, you will need to read input from users, generate solutions so that each game is not identical (although getting one solution to work right and then building on that is probably a good idea), and at the end of each game, ask the user if s/he wants to play again and arranging another game if so. If not, then say "Thanks for playing!" or something similarly boring, yet acceptable on a high school campus.