About NimForge

NimForge is a study hall for combinatorial game theory — the mathematics of two-player games with no chance and no hidden information, where perfect play is a theorem, not a guess. Play Nim against a bot that never errs, then turn the position over to the engine and ask the real question: who wins, and why?

For ages 15–18 (math-circle and competition-math flavour). Everything is computed on this device — the Nim-sum, Grundy values, and the exact win/loss of every small position — so nothing you type leaves your machine, and no AI is ever near the mathematics.

The one idea worth saying out loud

“Add the rows without carrying — leave your opponent a zero.”

That is the entire winning strategy for normal-play Nim: compute the Nim-sum (the bitwise XOR of the row sizes), and always move so that it becomes 0. If it is already 0 when it is your turn, the position is lost against perfect play — which is exactly why the classic (1, 2, 3) opening is a loss for whoever moves first.

What you can do here

  • Play — Nim or its misère twist, against a bot that always finds the winning move and explains the Nim-sum reasoning after each of its turns.
  • Solve — conjecture which positions win, then let the engine check every small position at once: the two-heap P/N map, Sprague–Grundy subtraction values, and Wythoff's golden-ratio cold squares.

Meet the cast

Each idea in NimForge is carried by a character whose one job IS that idea (the “cast is the curriculum”). No pictures here — at this age the mathematics is the star.

  • Nima — The Nim-sum — add the rows in binary with no carrying; the whole game lives in one number.
  • Bela — The balance (P-position) — you're safe exactly when the Nim-sum is zero, and every move breaks it.
  • Mirren — Symmetry — with two equal rows, copy the opponent and you cannot lose.
  • Gideon — The Sprague–Grundy value — every impartial game is secretly a single Nim heap.
  • Minu — The mex — a position’s value is the smallest number you cannot move to.
  • Sabra — Subtraction games — when you may only take from a fixed menu, the values fall into a period.
  • Iver — Misère — the twist where taking the last token loses; nearly the same rule, one careful exception.
  • Wyn — Wythoff's game — two heaps, a queen's move, and the golden ratio deciding who wins.
  • Hazel — Hackenbush — games that are worth fractions, where numbers themselves are born from play.
  • Professor Vera Kell — (Mentor) — sets the position and asks “who wins, and can you prove it?”

Two numbers for every start

For each starting position on the Play board, the engine played Nim against itself 1,000 times, choosing moves at random, and counted who won. Then it worked out who wins with perfect play. Random play is close to a coin toss; perfect play is decided before the first move. That gap is the whole subject.

Normal play: taking the last token wins. 1,000 random-play games per start.
Game Finished Typical length Ends with a winner First player wins (of games with a winner) Choices per turn Perfect play
(3, 4, 5) 100% 6 turns 100% 51% 6.3 first player wins
(1, 3, 5, 7) 100% 8 turns 100% 52% 7.7 second player wins
(2, 4, 6) 100% 6 turns 100% 51% 6.1 second player wins
(5, 6, 7) 100% 7 turns 100% 49% 8.8 first player wins
(1, 2, 3) 100% 4 turns 100% 50% 3.5 second player wins
(3, 5, 7) 100% 7 turns 100% 51% 7.4 first player wins
Misère play: taking the last token loses. Random games are the same games with the result flipped.
Game Finished Typical length Ends with a winner First player wins (of games with a winner) Choices per turn Perfect play
(3, 4, 5) 100% 6 turns 100% 49% 6.3 first player wins
(1, 3, 5, 7) 100% 8 turns 100% 48% 7.7 second player wins
(2, 4, 6) 100% 6 turns 100% 49% 6.1 second player wins
(5, 6, 7) 100% 7 turns 100% 51% 8.8 first player wins
(1, 2, 3) 100% 4 turns 100% 50% 3.5 second player wins
(3, 5, 7) 100% 7 turns 100% 50% 7.4 first player wins

Honest note

NimForge builds intuition for winning positions and the beautiful bridge from a game to a number (mex, Grundy values, the golden ratio). It is a place to play and prove — not a test-prep guarantee, and not a claim about grades or IQ.