Nim is an ancient mathematical strategy game. Players take turns removing objects from heaps.
Rules: On your turn, choose ONE heap and remove any number of items (at least 1) from that heap.
Normal play: The player who takes the LAST item wins.
Misère play: The player who takes the LAST item loses.
Strategy: The key is the Nim-sum (XOR of all heap sizes). A position with Nim-sum 0 is losing for the player about to move. The perfect strategy is to always leave your opponent with a Nim-sum of 0.
Difficulty:
Easy — AI plays randomly
Normal — AI plays optimal 50% of the time
Hard — AI plays optimal 85% of the time
Perfect — AI always plays optimally (unbeatable from a losing position!)