The Electronic Master Mind of 1977

In 1977, Parker Brothers and Invicta published a handheld electronic version of the Mastermind code-breaking game. The game was a calculator-like device that provided feedback to the player after each guess The player has X guesses to match the computer's code by selecting the correct numbers in the correct order.

The hardware

Wio Terminal D51R is an “All in one development device” with a Microchip ATAMD51 200MHZ 32 Mbit flash, WiFi, BT, 2.4 inches 320x240 screen, USBC, microSD slot, 3 Axis accelerometer, Mic, Buzzer, GPIO pins, Grove connector and buttons.

I’ve had this device for a while, but due to some WiFi configuration issues, I left it sitting in a drawer. Now I’ve discovered that it’s perfect for a small game like Mastermind.

Arduino IDE configuration

Add https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json to the additional boards URL. Select Wio Terminal as the board. If you have problems uploading you can use the side button, sliding twice down to force boot mode.

Even when the device is coded from Arduino, there are some differences regarding other boards.

The documentation comes in a form of tutorial videos and lessons to download instead of a quick API reference but I was able to find the information I needed. https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/

I have copied Free_Fonts.h from a tutorial example and started to code the UI.

The code guessing is made with the front little joytick: up and down to increase or decrease the number, left and right to change digit and the push button to enter the code.

The two right numbers shows the hints: right digits in right positions and right digits in wrong positions. A tries counter is maintained and buzzer sounds are generated at certain game stages.

if (user1==rand1){rightNumbersAndPositions=rightNumbersAndPositions+1}

if (user2==rand2){rightNumbersAndPositions=rightNumbersAndPositions+1}

if (user3==rand3){rightNumbersAndPositions=rightNumbersAndPositions+1}

if (user1==rand2 or user1==rand3){rightNumbers=rightNumbers+1;}

if (user2==rand1 or user2==rand3){rightNumbers=rightNumbers+1;}

if (user3==rand1 or user3==rand2){rightNumbers=rightNumbers+1;}

if (rightNumbersAndPositions==3){

winScreen();

}

The famous picture

There are essays about the Mastermind game, optimal algorithms to play, and all, but an entire generation remembers the game box photograph of an intriguing couple. Who were they? What relationship did they have? What were their skills? The game, of course, has its merits, but the picture undoubtedly contributed to the allure and sales. So, I wanted to include the picture, and this was the most complicated part of the project.

1. I have created a 320x240 bmp image

2. I have copied the bmp has to the microSD card

3. I have installed Seeed_Arduino_FS-master.zip and Rawimage.h libraries to use microSD

4. The default bmp had to be processed to extract header information, so Seeed Studios provided a Python script or an exe file to do this job. I have created a bmp folder, executed the program, then selected 8 bit convert. Finally I have copied the new bmp to the microSD.

Final notes

In an era of captivating immersive virtual reality experiences, why bother coding a seemingly straightforward game like Mastermind? The answer maybe lies in the delightful blend of history, education, and personal curiosity.