For the midterm project me and my project partner Dimos decided to recreate the board game Mastermind .Mastermind is a code-breaking game for two players.One player becomes the codemaker, the other the codebreaker. The codemaker chooses a pattern of four code pegs. The code breaker has a certain number of chances to guess the correct code.

THE GAME

We decided to use physical buttons to choose colours and the p5 sketch will give clues to the codebreaker. Once a particular coloured button is pressed,the corresponding coloured LED lights up.The sketch should generate random code every time the user plays the game. These buttons will recreate three colours: white, red, green, blue and one enter button. The rules are exactly the same as of the original mastermind game but instead of using all eight colours we limited ourselves to three. We also used a box to fit the buttons and the Arduino microcontroller,breadboard, wiring inside the box.

img_4620

After deciding our theme, we set about sketching, figuring out the basic mechanics of the project:

img_4536 img_4537

  • We figured that we would have to used digital input and output to set up 3 button and LED’s.
  • I wired three button switches in parallel on the breadboard.
  • The next step was getting a coloured shape in p5 js using serial communication.

  • We had certain issues on the arduino serial monitor after wiring 3 LED’s and 3 buttons to the breadboard.
  • We took a lot of time troubleshooting and getting accurate values on the serial communicator once the button is pressed.

img_4573img_4557

  • The next step after getting all the buttons to work was to get the game working on the p5 sketch
  • We were able to create the mastermind game on p5 with tremendous help from the residents and second years
  • The logic of getting different clues on the screen on the basis of the colour code given was challenging.
  • We tried and tested the game with many people to figure out

This is the link to the p5 sketch. The game can be played using left , right and up arrow keys. The user needs to click on the screen to start the game.

https://alpha.editor.p5js.org/projects/r1BlT161e

  • We were able to create the mastermind game on p5 with tremendous help from the residents and second years.
  • The next step was to generate a single coloured box on the game after clicking a button.

  • We were able to create the mastermind game on p5 with tremendous help from the residents and second years.
  • We faced issues where multiple squares were appearing on clicking a particular button and there was a significant lag while the squares appeared.
  • We took help from second years,Benedetta  and figured that printing the R,G,Y separately on the serial monitor helped solve the issue of printing multiple squares on clicking a single button.
  • State Detection code also helped in solving this issue.

  • We soldered the buttons and LED’s as we wanted to suspend them from the cardboard box.
  • We engraved “Mastermind” on the box.

img_4693

  • The final working prototype of the mastermind game!

The final arduino code.

The final sketch