Skip to content

Latest commit

 

History

History
120 lines (92 loc) · 6.92 KB

Initial_Guesses.md

File metadata and controls

120 lines (92 loc) · 6.92 KB

The Best Initial Guesses

All Mastermind algorithms are sensitive to the first guess chosen. Guessing 1111 first gives far less information about the secret than 1234. There are a limited set of different choices for every combination of pin and color counts.

I've run all games for each deterministic algorithm with each possible initial guess. Raw results are in the .json files in this repo. Tables below give what most people want: the one that yields the lowest maximum turns, and then best average turns.

Patterns of initial guesses

Using different digits for the same pattern isn't useful, nor are shuffled patterns. For example, for a $4p6c$ game these are the unique initial guesses:

$$[1111, 1112, 1122, 1123, 1234]$$

Repetitions of the same pattern, such as 2222, 2111, 3456, 1223, etc. aren't useful as they yield the same information. It should be easy to see that for a first guess, all codewords with the same color (i.e., 1111, 2222, 3333, etc.) give exactly the same amount of information.

Sure, for some secrets one might give a lot more information than another. For instance, if the secret is 2222 then certainly guessing 2222 first is a big win. But over all games, with all digits equally likely, nothing is gained from picking variations on the same pattern.

The best initial guesses for each algorithm

Each table shows the first guess which gives the lowest maximum turns, and then best average turns, over all games. There are some guesses which yield a better average at the expense of a worse maximum; these entries are marked with an asterisk(*). This can be found in the relevant JSON files in this and the results directories; it wasn't worth the clutter in the tables to list both.

Knuth

2c 3c 4c 5c 6c 7c 8c 9c 10c 11c 12c 13c 14c 15c
2p 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3p 112 112 112 112 123 123 123 123 123 123 123 123 123 123
4p 1112 1123 1123 1123 1122 1234 1234 1234 1234 1234 1234 1234 1234 1123*
5p 11122 11122 11223 11223 11223 11223 11223 11234 12345 12345 12345 12345 12345 11234
6p 111222 111223 112233 112233 111234 112234 112234 112234 112345 112234 112345 123456 123456 112345
7p 1111222 1112233 1112233 1112234 1122334 1122334 1122345 1112234* 1122345 1122334* 1122345 1123456
8p 11111222 11122233 11122334 11122334 11122334 11223344 11223344 11223345

Most Parts

2c 3c 4c 5c 6c 7c 8c 9c 10c 11c 12c 13c 14c 15c
2p 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3p 112 112 112 123 123 123 123 123 123 123 123 123 123 123
4p 1112 1123 1123 1123 1123 1123 1234 1234 1234 1122* 1234 1234 1234 1234
5p 11122 11123 11223 11223 11122* 11223 11223 11234 11234 11234 11234 12345 12345 12345
6p 111122 111223 111223 111223 112233 112234* 112233 112234 112234 112234 112234 112233* 112345 111234*
7p 1111222 1111223 1112223 1112233 1112233 1234567* 1122334 1122334 1122334 1122334 1122345* 1122334
8p 11112222 11112223 11122233 11122233 11122233 11122334 11122334 11122334

Expected Size

2c 3c 4c 5c 6c 7c 8c 9c 10c 11c 12c 13c 14c 15c
2p 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3p 112 112 112 112 123 123 123 123 123 123 123 123 123 123
4p 1112 1123 1123 1123 1122* 1234 1234 1234 1123* 1234 1234 1234 1234 1234
5p 11122 11123 11223 11223 11223 11223 11223 11234 11234 11223 11234 12345 11234 11234
6p 111122 111223 111234 111234* 112233 112234 112234 112233 123456 123456 112345* 112345* 112345* 112345*
7p 1111222 1112223 1112233 1112233 1112233 1112233 1234567* 1234567 1234567 1234567
8p 11111222 11122233 11122233 11122334 11112223 11234567 12345678

Entropy

2c 3c 4c 5c 6c 7c 8c 9c 10c 11c 12c 13c 14c 15c
2p 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3p 112 112 112 123 123 123 123 123 123 123 123 123 123 123
4p 1112 1123 1123 1123 1123 1123 1234 1234 1234 1234 1234 1234 1234 1234
5p 11122 11123 11223 11223 11122* 11223 11223 11234 11234 11234 11234 12345 12345 11223*
6p 111122 111223 111223 112234* 111223 112234 112233 112234 112234 112234 112234 112345 112345 112345
7p 1111222 1112223 1112233 1112233 1112233 1122334 1122334 1122334 1122334 1122345
8p 11112222 11122233 11122233 11122334 11122334 11122334 12345678*

Unique initial guess patterns for various game sizes:

The sets remain constant once $c = p$.

2p2c: 11, 12

3p2c: 111, 112
3p3c: 111, 112, 123

4p2c: 1111, 1112
4p3c: 1111, 1112, 1122, 1123
4p4c: 1111, 1112, 1122, 1123, 1234

5p2c: 11111, 11112
5p3c: 11111, 11112, 11122, 11123, 11223
5p4c: 11111, 11112, 11122, 11123, 11223, 11234
5p5c: 11111, 11112, 11122, 11123, 11223, 11234, 12345

6p2c: 111111, 111112, 111122, 111222
6p3c: 111111, 111112, 111122, 111123, 111222, 111223, 112233
6p4c: 111111, 111112, 111122, 111123, 111222, 111223, 111234, 112233, 112234
6p5c: 111111, 111112, 111122, 111123, 111222, 111223, 111234, 112233, 112234, 112345
6p6c: 111111, 111112, 111122, 111123, 111222, 111223, 111234, 112233, 112234, 112345, 123456

7p2c: 1111111, 1111112, 1111122, 1111222  
7p3c: 1111111, 1111112, 1111122, 1111123, 1111222, 1111223, 1112223, 1112233
7p4c: 1111111, 1111112, 1111122, 1111123, 1111222, 1111223, 1111234, 1112223, 1112233, 1112234, 1122334
7p5c: 1111111, 1111112, 1111122, 1111123, 1111222, 1111223, 1111234, 1112223, 1112233, 1112234, 1112345, 1122334, 1122345
7p6c: 1111111, 1111112, 1111122, 1111123, 1111222, 1111223, 1111234, 1112223, 1112233, 1112234, 1112345, 1122334, 1122345, 1123456
7p7c: 1111111, 1111112, 1111122, 1111123, 1111222, 1111223, 1111234, 1112223, 1112233, 1112234, 1112345, 1122334, 1122345, 1123456, 1234567
 
8p2c: 11111111, 11111112, 11111122, 11111222, 11112222
8p3c: 11111111, 11111112, 11111122, 11111123, 11111222, 11111223, 11112222, 11112223, 11112233, 11122233
8p4c: 11111111, 11111112, 11111122, 11111123, 11111222, 11111223, 11111234, 11112222, 11112223, 11112233, 11112234, 11122233, 11122234, 11122334, 11223344
8p5c: 11111111, 11111112, 11111122, 11111123, 11111222, 11111223, 11111234, 11112222, 11112223, 11112233, 11112234, 11112345, 11122233, 11122234, 11122334, 11122345, 11223344, 11223345
8p6c: 11111111, 11111112, 11111122, 11111123, 11111222, 11111223, 11111234, 11112222, 11112223, 11112233, 11112234, 11112345, 11122233, 11122234, 11122334, 11122345, 11123456, 11223344, 11223345, 11223456
8p7c: 11111111, 11111112, 11111122, 11111123, 11111222, 11111223, 11111234, 11112222, 11112223, 11112233, 11112234, 11112345, 11122233, 11122234, 11122334, 11122345, 11123456, 11223344, 11223345, 11223456, 11234567
8p8c: 11111111, 11111112, 11111122, 11111123, 11111222, 11111223, 11111234, 11112222, 11112223, 11112233, 11112234, 11112345, 11122233, 11122234, 11122334, 11122345, 11123456, 11223344, 11223345, 11223456, 11234567, 12345678