Nim

Version 1.0.0 · The Arcade · Catalogue 50

Three rows. One move at a time. Take the last counter to win.

Start a game

The table opens with 3 amber counters, 5 coral counters and 7 sage counters. You move first against the Casual computer. Pick a counter, inspect the highlighted selection, then press Take. The computer replies after a brief pause.

You can change Your opponent to Perfect and First move to Computer. Either change immediately starts a fresh game. The starting player is a real strategic choice: from 3–5–7, the first player can force a win with perfect play.

The exact rules

The row counts and total remaining counters always describe the current position. Both players see the complete position; there are no hidden counters or private information.

Touch, mouse and keyboard

Tap or click a counter to preview it and the counters to its right. The selected counters lift and gain an outline. The Take button tells you exactly how many will go, and the note states how many will remain in that row. No counters move until you press Take. You may select another counter or another row before committing.

The Take button is disabled when no selection is ready, while the computer is moving, or after the game ends. The current-turn label makes that state explicit.

A worked example

Start at 3 / 5 / 7. Tap the rightmost amber counter in row 1. Only that counter lifts; Take reads one counter and the note says two will remain. Press Take. The position becomes 2 / 5 / 7.

Suppose the computer takes two coral counters from row 2, leaving 2 / 3 / 7. You could take six counters from row 3, leaving 2 / 3 / 1. Each of these human moves leaves a nim-sum of zero, which is the strategy described below.

Near the end, a position such as 0 / 0 / 3 is an immediate win for the player to move: select all three counters in the last row and press Take. You do not have to leave a counter behind.

A little strategy

The useful calculation is the nim-sum, found by taking the bitwise xor of the row sizes. The opening position has 3 xor 5 xor 7 = 1. Changing 3 to 2 makes 2 xor 5 xor 7 = 0.

If the nim-sum is nonzero, a move exists that leaves zero. A perfect player repeatedly returns the position to zero after the opponent’s move. If the nim-sum is already zero, every legal move leaves a nonzero sum; there is no forced winning move against a perfect reply.

You do not need to calculate in binary to enjoy a game. Open A little strategy hint to see the current xor and a suggested move, or an explanation of a balanced position. The hint is hidden on a newly loaded page. Restart keeps its current open/closed state.

Opponents and settings

Casual mixes optimal choices with random legal moves, giving you chances to recover. Perfect always chooses a mathematically optimal move. If Perfect starts from 3–5–7, it cannot be beaten. If you start and keep making the correct replies, you can beat it.

The two first-move settings are You and Computer. Changing either the opponent or starting player clears the existing position and move history. It does not preserve a half-finished game.

Results, hints and replay

The result states You win or Computer wins, the total number of committed moves and the chosen opponent. The move count includes both players’ turns. The short history shows only the five most recent moves, not the entire count.

Hints do not subtract points or change the winner. This game has no points, timer, hint-use counter or separate assisted-result category. In an embedded host, a completed game reports one win/loss outcome with its total move count; looking at the result again does not create a second result.

Press Restart for a new 3–5–7 position with the current opponent and starting-player settings. The selected counters, winner and move history are cleared. Changing settings also restarts. There is no undo after Take.

Session-only progress

Everything about the current game lives in the open page. Reloading, closing and reopening, or reconnecting an embedded game starts a fresh session with the initial settings. There is no saved game, account, leaderboard or cumulative win record. Keep the game page open while reading this guide in its separate tab.

Install and play offline

Open the standalone game online over HTTPS, or localhost during local use. Use Install if your browser offers installation; otherwise follow the displayed browser instructions for adding the page as an app or to the home screen. Availability and wording depend on the browser. An installed web app uses the same rules and controls.

After the first online load has cached the game, you can reload its standalone page and open this guide offline. The cache stores application files, not the current rows or move history. Visit online first on each browser or device, and again if its storage has been cleared.

When the game is inside another page, it does not register an offline worker. The host handles an embedded Install request; opening the standalone game gives you its own install/offline flow. Separate embedded instances do not share game state.

If something seems stuck

About this edition

Nim is a local single-player game with one computer opponent, the fixed 3–5–7 opening and normal-play rules. It contains no network play or additional modes. The engine, instructional copy and CSS pebble artwork are original. It uses local files and system fonts, with no external asset or runtime library. The accepted game’s rules and presentation are retained in this release.