Monday, November 2, 2009

Mastermind-Understanding Logic

There is an important thing to remember in programming whenever creating a game, a device enhancement, a database, or whatever. You have to remember logic! I'll use the example of mastermind. Here are the rules to the game

Mastermind Rules
Object of the Game
The computer picks a sequence of 4 pegs, each one being one of any of six colors.
The object of the game is to guess the exact positions of the colors in the computer's sequence in as few guesses as possible. After each guess, the computer gives you a score of exact and partial matches.
Use Logic…Not Regular Expressions


Rules
1. The sequence can contain pegs of colors: red, yellow, green, blue, white, black
2. A color can be used any number of times in the sequence.
3. All four pegs of the secret sequence will contain a color - no blanks/empties are allowed.
4. Each guess must consist of 4 peg colors - no blanks.
5. You have 8 guesses to find the secret sequence.


Just say you wanted to write a program for this game, instead of worrying about what the graphics and forms look like, work on the logic of the game first. The gui can always be programmed later.

Go to this page for more hints on how to do your algorithm:
The link is http://www.uthinksmart.com/mastermind.htm

No comments:

Post a Comment