Thursday, July 7, 2016

Beat Dr. Nim! (Part 1)

YSP is a math summer camp that I go to with some of my friends from school. We learn about lots of different math, more specifically game theory and mathematical investigation around number theory.
Yesterday we looked into a game known as Nim. The setup of the game is putting sixteen objects down, with the last object being different from the others. Some gamblers may want to put money as a bet under the last object.
Image result for nim game
Here's an example with matchsticks. The top one is the last object.
The game begins with two players, who take turns taking 1-3 normal objects from the pile. The person who picks up the last, special object wins.
The game is seemingly simple and normal, like Tic Tac Toe, but there is a catch: There is a way to win every single game you play.
Image result for confused face memeImage result for confused face meme
In fact, Nim has a winning strategy that's so easy to follow, it was even implemented in one of the earliest computer games. It was called "Beat Dr. Nim", and was a simple, plastic board game. It had the same rules as Nim, and let the player go first. But, no matter what you did, "Dr. Nim" would always beat you, as long as you followed the rules (The game did have an option to make Dr. Nim beatable, albeit difficult.)
Here is the back of the box of "Beat Dr. Nim".
It has a picture of the computer game,
 (which you can learn more about -> here <-),
and also a somewhat casually racist
 depiction of "Dr. Nim", although
Nim most likely originated in China
a long time ago.
So, would you like to hear the strategy? It's really simple; As long as you go second, you must take the objects in groups of 4. So, if your opponent starts by taking 3 objects, you take 1, if your opponent takes 2 objects, you take 2, and if your opponent takes 1, you take 3. No matter what your opponent does, you will always be able to group the objects in fours. So, on the last turn, your opponent will have 4 objects left, but will only be able to grab 1-3 of them, guaranteeing you a win. 
Image result for yay cat meme
Yay you win Nim!!!
Actually, cool fact: NIM upside down looks like WIN.
The makers of "Beat Dr. Nim" noticed this, and you
can see it in the box art for the game a bit easier.
At YSP, they changed the game up a little bit. They called it "Race to 100", in which you had to take turns increasing a number from 0 to 100. You are allowed to add 1-10 to the number, and each player takes turns.
So, if you want to use the same strategy again... if the 1st player can add 1-10, then the number you will always be able to add up to is 11; if they add 1, you can add 10, if they add 2, you can add 11, etc., until you reach if they add 10, you can add 1. So, you can go in steps to reach 100. 
You will end up having the numbers 11, 22, 33, leading up to 99. Wait... if you end with 99, your opponent will just say 1, reach 100, and win the game! And you can't guarantee that you can make a number larger than 99. So, this strategy is flawed. Right...?

(TO BE CONTINUED)
(here's a dramatic sound effect to set the mood)
 


No comments:

Post a Comment