Building two bots to play Hexapawn against each other
Hexapawn is a two-player game where we start with a chessboard of size NxM. We have pawns on each side of the board and the goal is to advance a pawn all the way to the other end of the board. The standard pawn rules of chess are applicable here. This is a variant of the Hexapawn recipe given in the easyAI library. We will create two bots and pit an algorithm against itself to see what happens.
Create a new Python file and import the following packages:
from easyAI import TwoPlayersGame, AI_Player, \
Human_Player, Negamax
Define a class that contains all the methods necessary to control the game. Start by defining the number of pawns on each side and the length of the board. Create a list of tuples containing the positions:
class GameController(TwoPlayersGame):
def __init__(self, players, size = (4, 4)):
self.size = size
num_pawns, len_board = size
p = [[(i, j) for...