Hexapawn: Introduction to Machine Learning

Some machines are capable of improving over time as they get more experience and more information. Computers using a similar idea, called machine learning, have been used to beat the world’s best Chess and video game players, to optimize search results on the internet, and to solve extremely complicated scientific problems, like predicting what new proteins will look like. In this activity  you can build a computer that learns how to play a game and improves the more you play!

Suggested Age: 11+

Approximate Time: 30 minutes

Photo source: https://www.thedarkimp.com/blog/2019/10/17/try-this-hexapawn/

This is an accordion element with a series of buttons that open and close related content panels.


Hexpawn is a chess adaptation played on a 3×3 board. With only 3 moves needed to win, every possible move can be mapped out. By removing each losing play by the computer, the computer quickly improves and only makes winning moves. In the graph below plotting computer wins over multiple games, you can see how quickly the computer begins to dominate.


Assembling the Hexapawn Computer

Supplies needed for this activity:

  • 1 Board 
  • 3 Blue Chips (Viewed as black pawns)
  • 3 Yellow Chips (Viewed as white pawns)
  • 1 Plastic Bag
  • Computer Move Possibility Diagram Sheet
  • 1 Green Bead
  • 1 Blue Bead
  • 1 Purple Bead
  • 1 Orange Bead

Setup and Procedure

Setup: Hexapawn is played on a 3 by 3 grid. Each side starts with 3 pawns, as seen to the right. Place all your beads in one bag and set up blue and yellow chips on board.  

Pawn Movement: Pawns can make one of two moves. They can move forward 1 space at a time OR they can move forward diagonally one space to capture another pawn in that space. When capturing another pawn, the captured pawn is removed from the board.

Turn Order: White (or in our case yellow) always starts the game. Turns alternate between white/yellow and black/blue, with only one move allowed each turn. You always play as white/yellow, so you will always move first. The computer always plays as black/blue.

Winning the Game: A player wins the game when one of three conditions is met:

  1. One of their pawns makes it to the opposite side of the board.
  2. All the opponent’s pawns have been captured.
  3. The opponent has no legal moves to make.

The game will be won or lost by the end of turn 7, so if you end up needing a turn 8, something went wrong along the way.

Playing Hexapawn and Training the Computer

  1. On your turn, make one legal move with a yellow pawn.
  2. On the computer’s turn, find the computer move possibility diagram that both matches the turn number and has the corresponding situation on the board. (Note: the positions of the pawns may be a mirror image of what is on the move diagram, so select the situation that is either exactly the same or a mirror image.) Place the beads that match the colors of possible moves on the selected board diagram into the plastic bag. Close your eyes, randomly pick one bead out of the bag, and note its color. The computer will make the move that corresponds with the same colored arrow on the move possibility diagram. Make note of what color bead/move was used.
  3. Repeat steps 1 and 2 until someone wins the game.
  4. At the end of the game:
    1. If the computer won, no changes need to be made.
    2. If the computer lost, cross off the arrow corresponding to the computer’s last move.
  5. Keep playing games against the computer with all sorts of different strategies. Different moves from you lets the computer train against different strategies. As you play more games against the computer, the computer will become a better player. Use the scoring sheet included in the playing board PDF below to keep track of wins! 

Printable Game PDFs

Hexapawn Game Board and Score Table

Computer Moves

Computer Moves PDF credit: @Vsauce2, Twitter

Safety and References


This kit includes small parts that are a choking hazard for young kids.


Mathematical Games, Scientific American, March 1962, reprinted in The Unexpected Hanging and Other Mathematical Diversions, by Martin Gardner, pp. 93ff