Connect 4 with AlphaGo Zero
To see the method in action, let’s implement AlphaGo Zero for a relatively simple game, Connect 4. The game is for two players with a field size of 6 × 7. Each player has disks of a certain color, which they drop in turn into any of the seven columns. The disks fall to the bottom, stacking vertically. The game objective is to be the first to form a horizontal, vertical, or diagonal line of four disks of the same color. To illustrate the game, two positions are shown in Figure 20.2. In the first situation, the first player has just won, while in the second, the second player is going to form a group.
Figure 20.2: Two game positions in Connect 4
Despite its simplicity, this game has ≈ 4.5 ⋅ 1012 different game states, which is challenging for computers to solve with brute force. This example consists of several tools and library modules:
-
Chapter20/lib/game...