Andur Carr / Projects A game of deduction

Mastermind

Four pegs. Six colors. Twelve guesses.

Changing solver starts a new round.
The code0 / 12
    Exact Partial

    Loading the game…

    How to play

    In Break, tap the numbered pegs at the top to fill the highlighted guess row. The fourth peg submits automatically. Repeats are allowed. In Make, fill the code row instead; the computer then plays its guesses automatically.

    Tap any peg in an unfinished guess or code to remove it. Later pegs slide left. Once four pegs are submitted, that row is fixed. You can also type 1–6 and use Backspace to remove the last peg.

    Each red grading peg means a correct color in the correct position. Each white peg means a correct color elsewhere. Grading pegs are grouped together and do not identify individual positions.

    ↻ starts a new round; 🏳️ ends the round and reveals the code. The 🛟 beside your current guess chooses and immediately submits a minimax guess, replacing any unfinished pegs in that row.

    From Swift to the browser

    This version adapts Andur Carr’s original Swift implementation, including its code generator, duplicate-aware scoring, twelve-turn game, and Knuth-style minimax solver. The JavaScript translation and browser interface were built with AI assistance. The oak board texture comes from the procedural wood generator in my RegimeWeb project.

    The solver begins with two pairs, then keeps every code consistent with the feedback. It considers all 1,296 guesses and picks the one that leaves the smallest possible worst-case set of answers. Ties favor a possible answer. This version uses a fixed color order to make ties reproducible, where the original command-line Swift version chooses randomly.

    “Minimax” describes the next-guess objective, not a claim of globally optimal average play. The included exhaustive check tests every possible secret. The solver runs in a Web Worker and receives only previous guesses and their feedback—not the secret.

    The Swift / WebAssembly option runs a newly adapted Swift solver compiled to a 20 KB module. The board, random code generator and round management remain JavaScript. Both solvers use the same fixed opening and tie order; the Swift source is also a standalone package for a future native app. This browser demo does not emulate iOS.

    Timings describe the last call on your device, not a controlled speed comparison. Swift load/init includes download, compilation and its feedback-table setup; JavaScript builds its table within its first solver call. Later calls reuse each worker’s table. New rounds and engine changes discard the worker.

    Everything runs in your browser. No account, backend, or AI API is used. A new round or page reload starts fresh.

    Implementation notes (Markdown) · JavaScript checks · Swift/Wasm parity checks · Swift source