20170212

Mastermind Game #1: Considerations and Limitations

ARDUINO: Pondering doing a fun little project for a while now, but not quite found the correct one until it hit me: A version of the classic Mastermind board game.


Though it won't be a 1:1 copy. That would require an unholy amount of LEDs and just the though of soldering all those RGB leds and accompanying resistors make me dizzy. So no, got to simplify things a bit.

I guess I could cheat, and just use a color display - but then I might as well do it on the Pi in Go or AGK. Nope, I want this to be 'hands-on' as it were. So LEDs, buttons and I'm also thinking a rotary encoder...

But first - the rules. In the original you get six colors, ten tries and the 'coder' can tell if a color is correct or if a color and position is correct. But not what position and/or color. But since the 'cracker' got the entire history available, the process of elimination is simple enough.

In the version I'm making, The history will not be directly visible as such. I'm thinking of using a rotary encoder to browse back and forth in the history. The same encoder will be used to select what LED to change and to what color.

Speaking of colors. Your typical RGB LED got plenty to choose from - but for simplicity I'll keep it to what can be achieved using binary on/off. So no gradients. If not counting fully off (black) or fully on (white) that leaves six colors. Which is just perfect.

Color - R - - G - - B -
red 1 0 0
green 0 1 0
blue 0 0 1
yellow 1 1 0
magenta 1 0 1
cyan 0 1 1

As for the 'coder' LEDs, I'll just use four yellow ones to signal correct color, and four green ones to signal correct color and position.

In addition I'll also need something to signal how many tries have been attempted. If counting LEDs needed to be controlled now, I get 5 x 4 = 20. I can control that using three Shift Registers and have four channels left over. So unless I want to throw in another Shift Register, a 7seg LED display is not going to happen. But with the four bits left over from the three Shift Registers, I can count to 16 - which is plenty. So I'll add four blue LEDs and use that as a digital counter. Counting in digital is cool anyways, and blue LEDs are the coolest, so double win!

In the next installment I'll go through some of the initial hardware design. Ultimately, I'm going to want this in a nice little box with a 9V battery for power. So it's all going to run off a bare Atmega328P in the end with all the necessary discrete components to have it all humming along nicely. Which will be fun to bodge up on perf-boards with a ton of wires hither and dither to connect it all 😄

No comments:

Post a Comment