Artificial intelligence (AI) is the ability of a computer program or a machine to think and learn. It is also a field of study which tries to make computers "smart". What we will try to do in this experiment is to make a game that works using artificial intelligence.
The game Nim, is an ancient game with many different variants. For your own home made artificial intelligence, we will have to play the simplest version of it. The idea of the game is as follows: You line up 10 pencils, (or, coins, or acorns or whatever you have handy) and on each players turn you may take one, two or three of the items at once. Who ever takes the last item looses.
The goal is to build an artificial intelligence that will always win the game provided the AI is the first player.
What you need:
Take a look at the detailed instructions here, including a video tutorial.
Step 1: Prepare the AI
- Label all the 9 cups with numbers between 2 and 10
Step 2: Train you AI
In order to train the AI you need to play the game many times, until there is exactly one piece of paper left in each cup. Ideally find yourself someone in your family to play with.
You take turns as the AI. When it is your turn look how many items (e.g. pens) are left and then take one piece of paper out of the cup that corresponds to the number of pens left. E.g. If you have 7 pens left and it is the AIs turn you take a piece of paper from cup 7. The number on the pice of paper is the number of pens you will then take. Place the piece of paper in front of the cup. Once a winner is determined it depends on the outcome what happens next.
After playing enough times, each cup will end with only one piece of paper: the perfect move in that situation. Now your 9 cups will win against any player, as long as you make sure you get to go first!
Want to learn more about AI, why not check out the virtual interactive exhibition on machine learning and artificial intelligence at http://i-am.ai.