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 ...

Get Artificial Intelligence with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.