The optimal way to play Mastermind is to craft guesses so they eliminate as many of the remaining patterns as possible: on your turn you can go through every possible guess, tabulate the responses that guess would get for every possible target pattern that remains, and pick a guess where the options are spread evenly across several responses and not just clustered into one, so that no matter what response you get it eliminates a large number of other possibilities. With a good starting guess, you can beat the game on average in only 4–5 guesses.

Well, two can play at that game.

Galaxybrain is an adversarial Mastermind that tries to extend the game as long as possible by not actually picking a pattern at the start, but instead keeping track of all patterns you haven't eliminated through your guesses and giving you whatever answer will eliminate the least number of those possibilities. It can't increase the worst-case performance of a given strategy, but it'll ensure you never get lucky and guess the correct answer early by making you tediously eliminate every other possibility every time.

Will you actually notice a difference with vanilla Mastermind when you play this? I dunno! This is just a random idea I had that was inspired by jan Misali's video "hangman is a weird game" and I wanted to see what would happen.

I made everything here except the background image, which is a Transparent Textures modification of a Toptal Subtle Patterns texture by Atle Mo. The source code is on Bitbucket, if you dare (I would personally recommend not daring):

Rated 4.5 out of 5 stars
(2 total ratings)
Made withBfxr
Tags2D, Minimalist, Mouse only, Short, Singleplayer
Code licenseMIT License
Average sessionA few minutes
InputsMouse, Touchscreen
LinksSource code


Log in with to leave a comment.

Anyone doing better than 8 tries?

(1 edit)

I got 9 once, 7 twice, and 6 once.

by round 3, it's down to 9-24 options.

I think 7 is the best.