Building two bots to play Connect Four™ against each other
Connect Four™ is a popular two-player game sold under the Milton Bradley trademark. It is also known by other names such as Four in a Row or Four Up. In this game, the players take turns dropping discs into a vertical grid consisting of six rows and seven columns. The goal is to get four discs in a line. This is a variant of the Connect Four recipe given in the easyAI library. Let's see how to build it. In this recipe, instead of playing against the computer, we will create two bots that will play against each other. We will use a different algorithm for each to see which one wins. Create a new Python file and import the following packages:
import numpy as np from easyAI import TwoPlayersGame, Human_Player, AI_Player, \ Negamax, SSS
Define a class that contains all the methods needed to play the game:
class GameController(TwoPlayersGame): def __init__(self, players, board = None): # Define...