Today I just had the best idea for a new game: an implementation of the 1972 published game 'Mastermind'.
The game
To put it to simple terms, one player creates a code of 4 different colored pegs and the other player has to guess this code. For this he has 12 guesses (if i remember correctly) and with each guess the first player has to show the number of pegs of right color as well as right position, and the number of pegs that have the right color but the wrong position. For this pegs of two different colors are used.
My implementation
As my console has 8 LEDs this fits perfectly onto it. I implemented it as single player game, so the code is randomly generated from, at the moment, 4 colors (green, red, blue and purple). I guess it would be possible to use the remaining 300 Byte of flash memory for a multiplayer version of this game, but I'm not going to try it. For showing the number of completely right colors I used a white LED and for only the correct color it shows orange LEDs.
The game starts with all red pegs. With 'key2' you can change the color of the currently selected LED, with 'key3' you can move to the next LED (and jump from the last to the first one). With 'key1' you can basically submit you code to the other player (the computer) so he shows the number of rights. At the moment I did not implement a limited amount of guesses, as I have no Idea how i could show the number of guesses a player has left.
With each guess it's checked to see if you won, and if you did by guessing the code the gamestate changes to won and a new round starts.
Also I reduced the brightness of the LEDs as it was painful staring into them with the previous brightness.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.