// school projects / game of nim

Play NIM

A browser version of my CPE 300 project, which ran on an FPGA with 18 LEDs and two buttons. Each turn, turn off 1 or 2 lights. Whoever turns off the last light wins.

opponent
bot difficulty
first move

How to win

Since you can take 1 or 2, every round of two turns can always add up to 3. Leave your opponent a multiple of 3 lights (18, 15, 12…) and answer each of their moves with 3 minus what they took, and the last light will always be yours.

The FPGA bot plays exactly that way, like the opponent on my board. If you let it see a multiple of 3 on your turn, you can't win. Let the bot go first if you want a fair shot. Keyboard: press 1 or 2 to take, R for a new game.