Nim
Rules
Nim is played across several separate piles of sticks. On your turn, choose one pile and remove any number of sticks from it — just the last one, the whole pile, or anywhere in between. You can only take from a single pile per turn.
Whoever is forced to take the very last stick on the board loses. Click a stick to take it and every stick after it in that pile — hover first to preview exactly how many you're about to take.
New to this one? Medium is a good place to start — on any given turn it's roughly a 60/40 shot between the mathematically correct move and a random one, so it's beatable but not an easy mark.
Controls
Piles are numbered from the top down — Pile 1 is the first row, Pile 2 the next, and so on.
With a mouse or touchscreen: click any stick to take it and every stick after it in that pile. Hover first to preview exactly how many you're about to take.
With a keyboard: type a move into the box below the board as pile.count — "2.3," for example, takes 3 sticks from pile 2 — then press Enter or Take.
Type status (or just the start of it, like "sta") and press Enter or Take at any time — even when it isn't your turn — to have whose turn it is and how many sticks are in each pile read back to you.
Roots
Nim is one of the oldest known take-away games, with roots going back centuries and a full mathematical solution published by Charles Bouton in 1901 — the same "nim-sum" logic (XOR the pile sizes) that a perfect player uses is what this game's Hard computer opponent actually runs, adjusted for the twist that taking the last stick loses here instead of winning. For this collection's own original take on the same shared-pool, take-away, stuck-with-the-last-one shape, see Dishpan Hands.
Under the hood
Easy plays a genuinely uniform random legal move every turn — no bias toward big piles, no avoidance of an obvious blunder, nothing. Medium mixes in the real optimal move about 60% of the time and a random one the rest, same ratio the rules panel already promises. Hard always plays optimally — there's no version of Hard that ever misses the correct move.
"Optimal" here means the misère variant of the nim-sum strategy, not the more commonly taught normal-play one, since taking the last stick loses in this game instead of winning. For most of the game the two variants agree: XOR every pile size together, and if the result isn't zero, there's always a move that zeroes it back out, which is the losing player's only escape. They only diverge in the endgame, once at most one pile still has more than a single stick in it — ordinary nim-sum play would walk straight into a loss there, so the AI switches to counting how many piles-of-exactly-one are already on the board and leaves either 0 or 1 stick in the last big pile, whichever keeps that count odd for the opponent. Getting that endgame case right is the actual hard part of implementing "solved" Nim; the nim-sum XOR trick everyone quotes is really only the easy 90% of it.