Share your repls and programming experiences

← Back to all posts
Mastermind (Board Game) Online!
tussiez (1641)


Mastermind is a board game where you guess a color combination using hints from the other player/computer.

This is actually my second version, because I realized that you could play against the computer since the other player only "grades" you.

How To Play

You can find the same instructions on the page itself :)

-- Scroll to bottom for TL;DR --

Mastermind is a guessing game. The goal is to reveal a combination of colors that the Codemaker creates.

In this game, you are the Codebreaker, the one who finds the combination, and the computer is the Codemaker. There are four positions (0,0,0,0) and there are six possible colors, lime, red, yellow, black, white, and cyan.

To make it easier to guess the code, the Codemaker gives you Hints after each guess. These hints come in four smaller pegs.

To avoid directly giving away the code, the place that each peg is placed in does not matter.

A RED peg indicates that (1)ONE peg in your guess is NOT included in the code, and is NOT in the right position.

A WHITE peg indicates that (1)ONE of your pegs IS a color in the Codemaker's combination, but is NOT in the right position.

An EMPTY/BLACK peg means that you have gotten (1)ONE peg to match a color in the Codemaker's combination, and is in the CORRECT position. You do not need to move or change this peg in subsequent rounds.

This is the entire game. Have fun playing!

TL;DR: Guess a color combination, Codemaker gives response, RED peg response = wrong color, wrong position, WHITE peg response = right color, wrong position, NO peg = right color, right position.

Have fun!
I just wrote this in a few hours, so if you see any issues that make the game unplayable, let me know in the comments :)

NOTE: The reponse/reply pegs are in random order, and this is done on purpose. The position they’re in doesn’t matter

elizurfk (17)

This game is not right
I get the black in the first position it says right, but in the subsequent rounds it says it is wrong, but when I look at the answer its right! Can you please fix that bug?

tussiez (1641)

@elizurfk As you may see in the instructions, the pegs are in random order (to make it harder)

tussiez (1641)

@elizurfk The position of the pegs don’t correspond to positions on your guess