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 customizable in size (number of pegs/slots in the code) and in size (number of available colours) according to the player game.

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

The solver uses a simple syntax to describe combinations propositions and to deduce the possible solutions: N letters followed by 1 or 2 digits. N is the number of boxes and each letter represents a color, the numbers indicate the clues obtained (number of boxes correctly or badly placed).

Each combination proposed is written on a new line.

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 Blue and in position 4 : Y for Yellow

Initial letter of the color can be used (beware of doubles : Black and Blue for example)

Digits 2 and 0 correspond respectively to 2 pegs in the correct position and 0 in wrong position. (Be careful to indicate this with the right number)

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: Red Green Blue (1 in the right position and ignore the wrongly placed) is written: 'RGB 1?' (? = 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).

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

dCode retains ownership of the source code of the script Mastermind Solver online. Except explicit open source licence (indicated Creative Commons / free), any algorithm, applet, snippet, software (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt, encrypt, decipher, cipher, decode, code, translate) written in any informatic langauge (PHP, Java, C#, Python, Javascript, Matlab, etc.) which dCode owns rights will not be released for free. To download the online Mastermind Solver script for offline use on PC, iPhone or Android, ask for price quote on contact page !

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

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

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

Feedback

▲