Back to Parent


Files are located at and

The current product is capable of playing Mastermind by selecting two colors from a palette of five.  The colors can be repeated, although this is toggled in the code by commenting the following lines:

# keep picking colors until one that is not already within "selected_colors" has been picked

until !@selected_colors.include?(random)

     random = color_spectrum.sample


The user has twelve guesses, and can enter them by typing out the name of the colors or by using single-letter abbreviations or colored heart emoji.  The bot can provide up to two hints per game, and has special messages if it's about to win or if the user guesses the correct code within two turns.  It keeps track of the user's best score and doesn't like when the user sends it the poo emoji.

Some of these are results or messages that most users might not see in normal play and it isn't worth the conversational awkwardness to have the bot announce that it can do such things prior to playing the game.  Rather, it is better for the user to appreciate the functionality when such cases arise.  Other than the instructions and the game over responses, I wanted to keep the text length short, in case the user would want to scroll up to look at previous guesses.  A video of the solution is shown below:

NOTE: After clicking on the video, expand it by clicking in the upper-right corner. Otherwise, half of the screen will be cut off.

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!