What is it?
Color code is a simple Alexa skill game where the player tries to guess the correct color sequence. The rules and logic are the same as the board game Mastermind or the pen and paper game Bulls and Cows. After each guess the player is told how many colors they have in the correct slot and how many colors are in the incorrect slot, but not which positions or colors are correct. Ultimately the goal is to guess the correct sequence in as few turns as possible.
What does it do?
Upon launching the skill the player is asked if they would like to start a game. If they answer affirmatively then the player is prompted to select the number of slots (between one and four) and the number of colors (between two and nine) that they want to play with. The skill then asks the player if they will be using Echo buttons or just voice control to submit their guesses. If the player uses Echo buttons then the roll call for the buttons begins, otherwise the game starts immediately.
If the player uses Echo buttons then each button corresponds to a slot in the sequence. Pressing a button changes the color for that slot to the next color, and when the player has finished setting their desired sequence they can say "Try this code" to find out how well the guess matches the answer. Alternatively, if the player is using voice control they simply state the sequence of colors (voice control works even if the player indicated that they were using Echo buttons previously and will change the color of the Echo buttons to match the current guess). After the game reports the number of correctly and incorrectly matched colors, the player is then asked to guess again if they did not find the answer. The game continues until the player determines the solution.
Ideally the player would be able to keep a running mental tally of their past guesses and the narrowing pool of possible solutions, but with a large number of slots and colors this can be a bit difficult. In both Mastermind and Bulls and Cows the record of past tries is available visually, but that is obviously out of the question for someone using an Alexa based device without a display. As an alternative, this skill is able to recount the complete record of past guesses after the player asks "What have I guessed before?" or the record for a single turn if the player asks "What did I guess on turn #?", where # is the turn in question (asking for a particular turn will also set the Echo buttons to the previous color sequence).
Once the player has the solution the game compares the number of guesses it took them to their previously recorded best score if they played using that combination of the numbers of slots and colors, updating the best score as necessary. The player can then choose if they want to play with the same settings or choose a different number of slots or colors for their next game.
What makes it work?
This skill is programmed in Javascript with NodeJS and runs on AWS Lambda. Data storage between sessions (for keeping track of the record lowest numbers of guesses) is handled with AWS DynamoDB.
Why did you make it?
In my childhood we had an animal themed Mastermind board game (one color was represented by plastic lions, another color was hippos, etc) that I played with my siblings.
While games of this type are simple and rather shallow (your standard 4-slot 6-color game has been mathematically proven to be solvable in a maximum of five guesses), they provide a fun way for kids to practice their logical deduction skills.
Comments