Card Nim

The classic 21-game. Take 1, 2, or 3 cards from the pile each turn. Whoever is forced to grab the last card LOSES. Out-think the AI with pure combinatorial game theory.

Pile of 21 real sports cards • AI goes first • Misère Nim • Strategy taught in every game theory course

New Game Setup

Difficulty
Sport Pool
How it works: 21 real cards in the pile. AI goes first. You each take 1, 2, or 3 per turn. Whoever takes the LAST card loses. On Expert, the AI plays perfectly but starts in a losing position — if you play optimally, you should always win.

The Math Behind Card Nim

Call a pile "safe" if its size minus 1 is divisible by 4 — that is, sizes 1, 5, 9, 13, 17, 21. If you hand your opponent a safe pile, they are guaranteed to lose against perfect play.

The 21-pile is itself safe, which is why the AI (moving first) starts in the losing seat. Whatever it takes (1, 2, or 3), the remaining pile (20, 19, or 18) is not safe. Your job: subtract enough to hand the AI another safe pile.

The rule-of-thumb: if the opponent takes k, you take (4 − k). AI takes 1 → you take 3. AI takes 2 → you take 2. AI takes 3 → you take 1. Repeat. Eventually the pile reaches 1 and the AI has to take it.

This is the entire strategy. Once you internalize it, you should never lose an Expert match.

Card collecting connection: the same "parity counting" logic applies when you commit to a grading-submission schedule, a set-build order, or deciding which card of a pair to flip first. Discipline of counting multiples pays.

Related