Tool/Solver to solve Mastermind automatically. Mastermind is a board game based on deduction. This board game proposes to the player to find a combination of colours in a minimum of tentatives.

Mastermind Solver - dCode

Tag(s) : Board Games

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

Tool/Solver to solve Mastermind automatically. Mastermind is a board game based on deduction. This board game proposes to the player to find a combination of colours in a minimum of tentatives.

The **Mastermind** solver is configurable in size (number of colored pawns in the solution code) and in choice (number of possible colors) depending on the game of **Mastermind** to be resolved by the player.

In its original verison, a **mastermind** has generally 4 pegs/slots among 6 colours for each attempt, the player recieve a global information about correct or incorrect colors and positions.

The dCode solver uses a simplified syntax to describe the propositions of combinations and to deduce the possible solutions. Each combination proposed must contain N letters followed by 2 digits, with N the length of the combination (number of boxes to find) and the 2 digits indicating the clues obtained (number of colors well and badly placed). Separate each proposition with a line break.

Each letter represents a color of your choice, it is advisable to use the initial of the color (but beware of duplicates: do not put B for *Black* and *Blue* ! Prefer to replace Blue with C (for *Cyan*).

__Example:__ Combination RGBY 2 0 correspond to a proposal with in position 1 : R for Red, in position 2 : G for Green, in position 3 : B for Black and in position 4 : Y for Yellow

Digits 2 and 0 correspond respectively to 2 pegs in the correct position and 0 in wrong position.

It is also possible to indicate jokers (empty cells or unknown indicated by ?,*,- or _) as for the combination, than for right and wrong position.

__Example:__ Black,Black,Yellow,Red (1 in the right position, 2 in the wrong position) is written: BBYR12

__Example:__ Yellow,Blank,Blank,Blank (0 well positionned, 1 bad positionned) is written: Y--- 01 (here - = joker)

__Example:__ Red,Green,Blue (1 in the right position and ignore the wrongly placed) is written: 'RGB 1?' (here ? = joker)

According to Donald Knuth, and according to the original rules (combination of 4 colors among 6) it is possible to find the code in 5 steps (or less). The algorithm to use is:

1 - Generate the set E of the 1296 possible codes (from 1111 to 6666).

2 - Propose as first guess 1122

3 - If the answer is correct, the game is over. Otherwise, delete from the set E all the codes that would give the same answer.

4 - For each possible code that has not been attempted, calculate how many possibilities of the set E would be eliminated for each possible answer (combination well placed-misplaced). Give a score to this code equal to the minimum number of possibilities eliminated in E. Propose one of the codes with the best score as guess (preferably a code present in S). Resume in step 3.

This algorithm can find the code in 5 steps (or less).

Mathematically, if the strategy of the code-breaker (guessing player) is known then there are indeed more or less difficult combinations, but as indicated (above), using the optimal strategy of Donald Knuth then no combination is really difficult and all solutions can be found in 5 steps or less. Always mathematically, if the player's strategy is not known, then there is no combination more difficult than another.

For information, using this type of algorithm, the best combinations (the most difficult combinations to solve) are 1221, 2354, 3311, 4524, 5656, 6643.

However, not all players reason with mathematical algorithms, it is possible to consider combinations more difficult to find by trapping the human brain.

- Novice players often forget that the combination can have the same color several times, using 2 or 3 times the same element in the combination can make the game more difficult.

- If the combinations are made of numbers or letters, use large numbers or letters at the end of the alphabet in priority, because the algorithms and the players will often start by trying 1122 and not 5566 (and if it does, use mid range digits).

- If the players have agreed, a variant authorizes one or more empty spaces in the combination.

The best known variant is to use words to guess. The game, sometimes called Masterword then becomes much more complicated because the number of possible combinations increases exponentially.

A variant (which needs a players agreement before setting the game) is to allow a *blank* (a space without peg / color).

The **Mastermind** is often used as a puzzle in video games, such as in Old School RuneScape (OSRS) where a **Mastermind** makes players sweat (Fremennik Exiles).

The board game **Mastermind** credits Mordecai Meirovitz as author in 1971.

dCode retains ownership of the online 'Mastermind Solver' tool source code. Except explicit open source licence (indicated CC / Creative Commons / free), any algorithm, applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (PHP, Java, C#, Python, Javascript, Matlab, etc.) no data, script or API access will be for free, same for Mastermind Solver download for offline use on PC, tablet, iPhone or Android !

Please, check our community Discord for help requests!

mastermind,master,mind,mordecai,meirovitz,peg,slot,code,game,rule,player,combination,masterword

Source : https://www.dcode.fr/mastermind-solver

© 2020 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback

▲