Over the past few weeks, I presented myself with challenges motivating me to work through various coding hurdles for Peggy (Tabletop Game Engine). I have a fourth challenge dealing with additional CRUD for a game’s data objects. I set that one aside and considered another challenge (#5) exploring multi-faced game pieces (dice and cards). I had another idea taking these challenges in another direction.
Instead of a challenge for random piece behaviors, why not create a simple game? Or, I could recreate one of ye olde Pegamoose Games from many years ago. I constructed a list (in one of my work tickets) of the various solo mini-games. Dress-a-Moose was very similar to elements of the first few challenges, for this one, I intended to present a “naked” pegamoose image and a variety of items to decorate it. I decided to table this challenge for a bit to work on a “Code Breaker” prototype instead.
History
Code Breaker is my variant of another game I have played under a couple different names (Master Mind the tabletop version, and Hits and Blows on Nintendo Switch). These games arrange four colored pegs in a row and the player guesses what the colored pegs are based on feedback after each unsuccessful guess. A different set of pegs indicates which colored pegs are the correct color and in the correct position, a correct color in a wrong position, and which are flat out wrong.
As I outlined the work and brainstormed ideas for Code Breaker, I considered making the “secret codes” of colors increasingly more difficult. I considered allowing players to specify how many code digits to guess and other, possible game options. As much fun as I thought these ideas might be, I reminded myself, “Keep it simple, stupid!” After all, the challenge is meant to be a basic prototype plus a bit of coding practice.
My Variant
The current prototype includes a secret code of six digits, instead of the usual four. Hits and Blows allow the option for no duplicates or colors used twice. In my version, any color may be duplicated up to six times. If my rusty, dusty math is correct, that makes six to the power of six possible different codes (or 46,656 unique codes). Instead of limiting the game to eight guesses, my version provides unlimited guesses.
The four types of hints this variant provides are:
- An empty square indicating the player did not specify a color for a space.
- A green check for correct guesses in a correct space.
- A yellow yield for correct color in a wrong space.
- A red X per incorrect guess.
Hurdles
The trickiest part of this project involved accurately calculating the hints. Correct guesses? No problem! Guessing a color not in the code? Piece of cake! Empty spaces? A scoop of ice cream with that cake! Everything else…Uh…
In my first attempt, I figured everything else would be the number of spaces minus the correct and incorrect guesses. Something was not quite right with this possible solution and the yield hints did not accurately reflect the comparison of the code versus the guess. I tweaked the code to check for right colors in the wrong space, but a miscalculation resulted in more hints than possibly number of spaces. Try again.
I tried several times to calculate the yellow yields accurately. I encountered difficulty distinguishing the difference between a color in the wrong space and guessing a color too many times (which should result in the red X, instead of yellow yield). This is what resulted in indicating more than six hints, one for each space. For the final solution, I realized I needed to compare the counts of colors for both the guesses and codes.
Design Decisions
One design decision evolving out of this project, I had considered dragging and dropping the colors into the different slots. I may do that for the “live” version (as a Pegamoose Games featured mini-game). I think the point and click (or double-click) works well enough for this prottype.
When I started this project, I had used underscores for the blanks and question marks for the code placeholders. As I wired in the colorful pegamooses (which I had intended to use from the start), I remembered I had also created a mystery token with a question mark and an empty circle.
Restarting a game is as easy as reloading the page. I provide this in a New Game button, too. Plus, I added another button for the rules. Plus, two more buttons for either clearing a selected blank or clearing the entire guess.
Future Considerations
At the moment, because of “unlimited” attempts, I want to issue points for the different types of incorrect guesses. To prevent the game from truly being unlimited, I might cut the game off when a player meets or exceeds a threshold score.
Once the game is wired into Peggy, I may consider those additional options mentioned earlier in the blog for adjusting the constraints of the game for a possible deluxe edition of the game. Players could earn points when the game ends with scores falling within certain ranges. Also, because players would login to their account, the Peggy version would preserve game states so players may continue an in-progress game at a later time. Play at your leisure!
Another possible feature, I may have thought earlier, but am thinking it now as I write this blog, is to allow the player to click on one of their rows of guesses and fill in the guess with the same set of colors. This might be particularly useful the more accurate a player’s guess.
Play on!
Here is the link if you would like to play this Code Breaker prototype:
https://pegamoosegames.com/games/codebreaker/
All in all, I am very proud of myself for making a very playable, working prototype that can be wired into the final product once Peggy is more “live-worthy”. A majority of this project was completed within two to three days. More of these types of mini games help the site get closer to a “live-worthy” status.
If you have any suggestions, please share in the comments section. Or, if you have suggestions for other mini games, I would like your input on that, too!
Leave a Reply