Skip to content

An even faster C++ classical Mastermind game optimal solver that uses a highly optimized recursive DFS algorithm to find the strategy with the lowest possible average number of moves (4.34028). Code can also be easily customized for different combinations of code breaking games other than 4 digits of 6 colors [4,6]

License

Notifications You must be signed in to change notification settings

ObsessiveCompulsiveAudiophile/code-breaking-games-optimal-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

code-breaking-games-optimal-solver

serkan gur 2025

An ultra fast C++ Mastermind game optimal solution tree generator that uses a highly optimized recursive DFS algorithm to find the strategy with the lowest possible average number of moves (4.34028). Capable of solving any other combination and starting a game from any level!

Some features:

  • intelligently prune non-promising branches of the search tree with Maxparts method
  • pre-computed score table
  • super fast (thanks to Clang compiler) hybrid polynomial dot product & hash table equivalence pruning
  • custom tuned vectorization of loops

How to compile and run:

Single .cpp file

Platform toolset: LLVM (clang-cl)

All options:

/GS /W3 /Gy /Zi /O2 /Ob2 /fp:fast /WX- /arch:AVX2 /Gd /Oy /Oi /MD /std:c++20 /Fa

Example end of output:

...

112330 124520 114340 :3

112330 124521 112540 :3

112340 :1

5625 / 1296 = 4.34028 average moves to finish!

16.0356 seconds

Press Enter to exit...

About

An even faster C++ classical Mastermind game optimal solver that uses a highly optimized recursive DFS algorithm to find the strategy with the lowest possible average number of moves (4.34028). Code can also be easily customized for different combinations of code breaking games other than 4 digits of 6 colors [4,6]

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages