Nim Game - Strategic Object Removal

Play Nim against AI. Take objects from piles strategically - whoever takes the last object loses. A classic mathematical strategy game.

Strategy GamesLogic GamesClassic Games
Your turn - Select a pile

Take Objects

How to Play

  • Click a pile to select it
  • Choose how many objects to take (at least 1)
  • You can only take from one pile per turn
  • The player who takes the last object loses!

FAQ

Nim is a mathematical strategy game. The game starts with several piles of objects. On your turn, you must take at least one object from exactly one pile. You can take as many objects as you want from that pile. The player who takes the last object loses the game.

The winning strategy involves calculating the "Nim sum" - the XOR of all pile sizes. If the Nim sum is non-zero, you can always make a move to make it zero, putting your opponent in a losing position. The AI on hard difficulty uses this optimal strategy.

Easy: AI makes random moves. Medium: AI plays optimally 50% of the time. Hard: AI always plays the optimal strategy using Nim sum calculations. Try to beat the AI on hard difficulty!