How to Use
Enter heap sizes:
- Nim-value: XOR of heaps
- Win/Lose: Position type
- Moves: Optimal play
XOR Strategy
Nim-sum = h₁ ⊕ h₂ ⊕ ... ⊕ hₖ. If 0: every move makes it >0 (losing). If >0: there exists a move to make it 0 (winning). The move: reduce heap i to hᵢ ⊕ nim-sum (if this is smaller).
Variants
- Misère Nim: last to move loses. Strategy: same XOR logic, but switch when all heaps ≤1
- Wythoff's game: remove from one pile or equal from both
- Fibonacci Nim: can remove up to 2× previous
Step-by-Step Instructions
- 1Enter heap sizes.
- 2Compute Nim-sum.
- 3Check win/lose.
- 4Find optimal move.
- 5Explore variants.