Serkan Gur’s VB Examples Page

Financial Excel VBA

·         Black Derman Toy Option Pricing Model

·         Vasicek Option Pricing Model

·         Eurobond Pricing Functions

Visual Basic Code Samples

Interactive Bulls & Cows Game

Excel Mastermind with Optimal Strategy

MASTERMIND STRATEGIES

In the classical Mastermind game where the secret code is a 4 digit repeatable combination of 6 different colours, there are in fact just 5 unique types of first guesses to the game. And a player’s guess will be scored according to its correct (colour and position) and semi-correct (correct colour but wrong position) digits. If we multiply correct number of digits by 10 and add to that number semi-correct digits in the guess, we can show each score by a 2-digit number: 00, 01, 02, ……, 30, and 40. Note that 31 is not a valid score. The table below shows the number of remaining valid possibilities after the first guess for each of the possible combinations and for each possible score:

 

1111

1112

1122

1123

1234

00

625

256

256

81

16

01

0

308

256

276

152

02

0

61

96

222

312

03

0

0

16

44

136

04

0

0

1

2

9

10

500

317

256

182

108

11

0

156

208

230

252

12

0

27

36

84

132

13

0

0

0

4

8

20

150

123

114

105

96

21

0

24

32

40

48

22

0

3

4

5

6

30

20

20

20

20

20

40

1

1

1

1

1

Total:

1296

1296

1296

1296

1296

Simple

1

2

8

9

52

Worst Case

625

317

256

276

312

Entropy

1.5

2.7

2.9

3.0

3.1

Expected Size

512.0

235.9

204.5

185.3

188.2

Most Parts

5

11

13

14

14

 

From this table, you can see which game strategy picks which first guess and why it does so by looking at the highlighted cells (these are the first guesses of each classical Mastermind strategy). This table below shows the game solution tree averages for all the classical strategies as well as the Optimal Strategy.

Strategy Total Guesses Average Maximum Guesses 6 or more Guesses Author Year
Optimal (Max: 6) 5625 4.34028 6 1 Lai 1993
Optimal (Max: 5) 5626 4.34105 5 0 Lai 1993
Weighted Entropy 5646 4.35648 6 3 Gur 2021
Most parts 5668 4.37346 6 7 Kooi 2005
Expected Size 5696 4.39506 6 3 Irving 1979
Entropy 5722 4.41512 6 12 Neuwirth 1982
Worst Case (Min-Max) 5801 4.47608 5 0 Knuth 1977
Simple 7471 5.76466 9 853 Shapiro 1983

 

Link to my Audio page

Wordle TR (Turkish Wordle) Optimal Solution Table

Link to my book: New and Powerful Mastermind Strategies

Download book code