Per Person or Pair:
- A 9-square grid (3 rows across and 3 rows down) made from a template handout (glued to cardboard)
- 6 pawns: 3 white, 3 black. Can use checkers, chess pawns, pennies, nickels, or other objects that fit the squares
- 24 small containers with lids (examples: cardboard egg cartons cut apart with lid attached or 3 oz paper cups with another cup for a lid)
- Small marks in 4 different colors (such as beads, M&Ms, small Lego pieces, or bingo chips—sized to fit 4 in each small container)
- Pen or fine marker
- Tape or glue
In 1952, Arthur Samuel wrote a program for an IBM computer to play checkers. The program kept track of all the positions on the checkers board it had already seen and combined them with an algorithm that calculated the chances of winning. The more the computer played, the better it got at the game of checkers. The machine “learned” how to win, and Arthur Samuel called this type of programming machine learning.
Machine learning is a form of artificial intelligence (AI). AI describes how machines, in particular computers, can be programmed to think and perform like humans. Not only that, they can be trained to make the best choice every time. In the case of games, how can a computer learn to win every time? Hexapawn is a game designed to reveal how the process works.
Playing the game Hexapawn, your goal is to train a “machine” to beat you each time.
There are several materials that need to be assembled before gameplay. Instructions are in the How to Play handout.
Decide if you will pre-assemble the components for your students or if you will have the materials available for them to assemble themselves.
Practice playing so that you can answer any questions. As needed, amend the student instructions to make them as clear as possible for your students.
Define the Problem
- Set the context for students with a brief introduction. Tell them that in the early 1960s, a mathematician named Martin Gardner recognized that machine learning, a form of artificial intelligence (AI), would have an ever-growing impact on our lives. Accordingly, he wanted to help people understand the answers to these questions:
- How can a machine learn like a human?
- How can a machine get even better at playing games of strategy than a human?
In 1962 Gardner came up with a game he called Hexapawn. It demonstrates how a computer can be programmed to improve with experience, which is another way to describe machine learning. The students’ goal in playing this game isn’t to win against a computer; it’s to teach a computer to beat them every single time.
- Show students the 9 x 9 grid (game board) and explain how you play the game.
Any of these three results is considered a win:
- Get a pawn to the other side.
- Make the opponent unable to move.
- Take all of your opponent’s pawns.
Explain that the robot, or machine learner (Gardner called it HER, short for Hexapawn Educable Robot), is made out of 24 small containers that hold a varying number of different colored small pieces, such as beads, known as marks.
The containers are grouped by a round of play. Only certain moves are possible in any round, and these are represented by diagrams attached to each turn’s set of containers.
Summarize the instructions in the gameplay handout to get students familiar with the game: When it’s the robot’s turn, students find the container with the diagram that matches the board. They close their eyes, shake the container, open it, and pick a mark. They place this mark on top of the container and make this move for the robot.
Students take turns until they or the robot wins.
If the robot wins, students put all of the marks back in their containers. If the robot loses, students remove the mark that represents their robot’s last move. Then they play again.
What students will discover is that as they continue to play, only marks representing winning moves remain in each container. The robot has “learned” which moves are successful by having the losing moves pruned away.
Build and Test
Once students understand how to play, get them started with the first few rounds. If students are playing in pairs, one student can be the robot. Give students 15 minutes to play.
Stop play and troubleshoot in a class discussion. What are students discovering? What are they confused by? As much as possible, have other students answer so that they are teaching each other to teach the robot.
Evaluate and Redesign
When time is up, see if any students are consistently getting beaten by their robot.
Elicit reactions. How does playing Hexapawn help—or not help—them understand AI?
Use the additional information under Science & Engineering to further explain machine learning.
Science & Engineering Connections
The rules of the game represent an algorithm, a set of rules that is followed in a particular kind of problem-solving. In this case, the problem to be solved is a game to be won. Computer scientists use algorithms in the development of AI (and just about every form of machine learning).
Machine learning is similar to the way people learn through rewards and consequences. At first, when all the marks are in their respective containers, the robot is a blank slate. It has no strategy. Winning is a reward in that the robot loses no marks, but removing a mark when the robot loses is a form of negative consequence. Each negative consequence improves the likelihood of winning the next game. Eventually, as Gardner says, “Such machines do not do what they have been told to do but what they have learned to do.”
This activity was developed through the support of the Northrop Grumman Foundation.