Skip to content
← Back to Community
Mastermind
Profile icon
Roar123

Mastermind in Python

The classic game of Mastermind is now implemented in Python, meaning you can play the codebreaking game in the comfort of the console.

Rules

The computer has generated a random code - you have to guess it!

Enter your guess as a string of 4 letters, where each letter stands for a color.

Ex. rgbp stands for red, green, blue, and purple from the left to right slot respectively

Here is the complete list of color notation:

Red: r
Blue: b
Green: g
Orange: o
Purple: p
White: w

Red: pin in the right position with correct color
White: pin in wrong position with correct color

Example

Screenshot 2020-02-21 at 6.16.35 PM

Features

  • Color terminal interface
  • Automatic guess enforcement
  • Accurate guess evaluation
  • Turn and score tracking

Is your mind ready for Mastermind? Find out now!

Voters
Profile icon
BlueComet
Profile icon
studentAlfredAl
Profile icon
AmazingMech2418
Profile icon
nN34398Ff
Profile icon
dxb09
Profile icon
JackLyons1
Profile icon
s679419
Profile icon
Thom169
Profile icon
kajohnson0211
Profile icon
mamamia5x
Comments
hotnewtop
Profile icon
SilentShadowBla

Amazing!!!

Profile icon
SixBeeps

Hooh, this is tough

Profile icon
Roar123

@SixBeeps :) Don't worry - one day you'll become a Mastermind master!

Profile icon
JDOG787

@SixBeeps how many times have you cracked the code?

Profile icon
AmazingMech2418

@SixBeeps Try starting with all one color (I normally do red) and then when you get at least one right, add a second color and mess around with the order until you get all of the correct colors in the right places and then add a third color and so on.

Profile icon
MrEconomical

Great work! Finally, a terminal game that isn't garbage

  • EEEEEE
Profile icon
Roar123
Profile icon
oignons
Profile icon
mamamia5x

I was making an HTML mastermind game, then this came out. Well done though.

Profile icon
JDOG787

cool!

Profile icon
Roar123
Profile icon
JDOG787

@Roar123 I love this game!

Profile icon
nN34398Ff
Profile icon
AS06GH

i got it in ten on my first try

Profile icon
CodingClubber

@AS06GH i got 8
this is awesome
i dont get how it works

Profile icon
Roar123
Profile icon
Roar123

@CodingClubber Check out the logic in evaluate()

Profile icon
[deleted]

nice game!

Profile icon
AmazingMech2418

I've always enjoyed this game. Also, great job on making it in Python! By the way, I got it in 3.
image

Profile icon
renderthepi

3 red on my first guess, what are the odds?
rgbo
rgbb
rggo
rrbo

Profile icon
B123D321

This is awesome! Great job!

Profile icon
ags17dewh

hahahahah nice bro!

Profile icon
Powerpasta

This game doesn't work once I get past the loading screen

Profile icon
Roar123

@Powerpasta Try running the program

Profile icon
DarkBlueWall

woo 3 turns!!
rbgp
rbgo
rbwp