NIM with Reinforcement Learning

See how an AI system learns to play the game NIM from scratch, just by playing against itself. The rule is simple: take 1–3 sticks per turn, and whoever is forced to take the last stick loses.

1
Train the AI system. Choose how many games the AI should practise. Watch how the Q-table changes during training!
2
Explore the Q-table. The table on the right shows what the AI has learned. Green = good move, red = bad. Can you spot a pattern?
3
Play against the AI. Challenge a half-trained or fully trained AI. Can you beat it?
AI Activities

NIM

See how an AI system learns to play NIM using reinforcement learning. Then try playing against it!

Svenska
The rules of NIM Reinforcement learning Q-value Explore vs exploit
Settings
Q-table: the AI's brain
Each row = sticks remaining. Each column = move. Green = good move, red = bad. Gold border = best move in that state.
Good move
Bad move
Best move
The strategy the AI has learned
Train the AI to see the Q-table fill in.