top of page

Mastermind

    Mastermind is a code-breaking game for two players. They decide in advance who is the codemaker and who is the codebreaker. The codemaker chooses a pattern of four code pegs, and the codebreaker tried to guess that pattern in order and color within twelve turns. The game is played using a decoding board, with a shield at one end to cover the code makers code, code pegs of six different colors, and key pegs, some are colored white and others black. Each guess is made by placing a row of code pegs on the decoding board. Once placed, the code maker provides feedback by placing from zero to four key pegs. A black key peg is placed for each code peg from the guess that is correct, and a white peg indicates the existence of a correct color peg placed in the wrong position. Once feedback is provided, another guess is made; guesses and feedback continue to alternate until either the codebreaker guesses correctly or they run out of guesses.

    During my second semester, I took Digital Electronics which had a 2-week project at the end of the class. The only restraint was it had to be done on a breadboard, with no code involved, so I chose to do a simplified version of Mastermind. I used a crystal oscillator to mimic a random number generator and outputted four one-bit numbers as my code, and four switches for my codebreaker. I compared the bits using an XOR gate, put those bits through a full adder to find how many bits were correct, and output that number to a seven-segment display. This way the probability of breaking the code is much higher because it is either on or off and there are no colors, but the codebreaker only knows how many of the bits were correct rather than which pegs were correct.

In this video, every time I am pressing the button I am resetting the code with four new numbers outputted by the crystal oscillator. The blue switches below my hand indicate the code breakers guess, and the seven-segment display shows how many digits they got correct. 

bottom of page