Implementing the Mastermind game

In this series I am going to implement a version of the well-known Mastermind board game. Well, it is well know at least to me. As I have encountered many people who are not familiar with it so let’s start by explaining the game:

The Game

In this series I am going to implement a version of the well-known Mastermind board game. Well, it is well know at least to me. As I have encountered many people who are not familiar with it so let’s start by explaining the game:

The Game

  • The computer selects N different items from a pool of M items and puts them in some order. This is the secret that the user has to find in the right order.

  • The user selects N different items from the pool of M items in a certain order.

  • The computer gives a * sign for every item that is in the same location as in the secret and a + sign for every item that is in the secret but not in the place the user put it.The order of the response does NOT correspond to the order of the values.

  • The last two steps are repeated until the user finds the secret and the the user wins. If the user cannot find the secret in K guesses then the user loses.

  • N, M and K can be be anything. Items can be anything (eg. colors, digits, letters, etc.)

  • In the original game M = 6 colors, N = 4 and K = 12 and * was a back stick and + was a white stick.

  • There difficulty can be increased by allowing items to be repeated in the secret and/or by allowing empty spaces in the secret.

Let’s see an example when the pool of items are the 6 digits 1-6 and that the size of the secret is 4.

The computer selects 4 values randomly:

  • hidden: 3654
  • guess 1: 1234 *+ (4 is in the right place, 3 is in the wrong place)
  • guess 2: 1256 *+ (5 is in the right place, 6 is in the wrong place)
  • guess 3: 6354 **++ (4 and 5 in the right place, 3 and 6 in the wrong place)
  • guess 4: 3654 **** win

An original box

Image description

Technology

  • First I’ll implement a command-line version of the game written in Python
  • Then I will probably implement a web version with plain HTML using the Flask framework written in Python
  • Then I don’t know yet. I might implement a different front-end for the game or I will re-implement the whole thing in JavaScript. I don’t know yet.

In any case I am going to publish and explain my progress so follow me if you are interested.


Print Share Comment Cite Upload Translate
APA
Gábor Szabó | Sciencx (2024-03-29T02:04:41+00:00) » Implementing the Mastermind game. Retrieved from https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/.
MLA
" » Implementing the Mastermind game." Gábor Szabó | Sciencx - Tuesday December 13, 2022, https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/
HARVARD
Gábor Szabó | Sciencx Tuesday December 13, 2022 » Implementing the Mastermind game., viewed 2024-03-29T02:04:41+00:00,<https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/>
VANCOUVER
Gábor Szabó | Sciencx - » Implementing the Mastermind game. [Internet]. [Accessed 2024-03-29T02:04:41+00:00]. Available from: https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/
CHICAGO
" » Implementing the Mastermind game." Gábor Szabó | Sciencx - Accessed 2024-03-29T02:04:41+00:00. https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/
IEEE
" » Implementing the Mastermind game." Gábor Szabó | Sciencx [Online]. Available: https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/. [Accessed: 2024-03-29T02:04:41+00:00]
rf:citation
» Implementing the Mastermind game | Gábor Szabó | Sciencx | https://www.scien.cx/2022/12/13/implementing-the-mastermind-game/ | 2024-03-29T02:04:41+00:00
https://github.com/addpipe/simple-recorderjs-demo