Skip to content

A mastermind solver for finding optimal worst-case guesses with SIMD and multithreading support

Notifications You must be signed in to change notification settings

0xbe7a/mastermind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Mastermind solver for optimal worst-case guesses

This is a solver for the Mastermind board game which finds guesses that minimize the maximum number of possibilities that remain after receiving the corresponding hint

Image source

It is implemented using the new std::simd SIMD Abstraction from Rust to target NEON, SSE2, AVX2 and WebAssembly SIMD from a shared implementation

Additionally, it uses rayon to enable multithreading

It finds optimal worst-case guesses 1 from all non-equivalent 2 guesses that minimize the maximum number of remaining possibilities

The core solver is implemented in libmastermind alongside a CLI-Solver and a Web frontend

Play

https://0xbe7a.github.io/mastermind/

NOTE: No fallback for browsers without WASM and WebAssembly SIMD has been provided (Not Safari and Firefox is currently flaky)

Building the Application

  1. Run nix develop on Nix (or)
    1. install rust-nightly with the wasm32-unknown-unknown target and rust-src component
    2. install wasm-pack
    3. install npm
    4. target the native CPU Features using export RUSTFLAGS="-C target-cpu=native"
  2. To build the CLI-Solver use cargo build --release
  3. To build the WebApp
    1. Go to "web/www"
    2. use npm install
    3. build the application with npm run build

References:

Footnotes

  1. Knuth, D. E. (1976). The computer as master mind. Journal of Recreational Mathematics, 9(1), 1-6.

  2. Ville, G. (2013). An optimal mastermind (4, 7) strategy and more results in the expected case. arXiv preprint arXiv:1305.1010.

About

A mastermind solver for finding optimal worst-case guesses with SIMD and multithreading support

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published