I am making a board game with a computer player. The game is on a 6x6 grid. It's like chess but with pawns only. Each player has 6 pawns; one player is circles and one is crosses. The goal is to be the first player to reach the other side of the board.

Each move is either one step forward, or a "jump" on a diagonal over a piece. When a jump is made over the opponent's piece, it is captured and removed from the board.

So far, I have written the code to initialise the board and to evaluate a position:

class SimpleBoardPlayer(BoardComputerPlayer):

    def __init__(self, the_mark):
        :param compatibility_score_set:
        super(SimpleBoardPlayer, self).__init__(the_mark)
        self.name = "Simple"

    def evaluate_game_status(self, a_board):
        GAMESIZE = 6
        CROSS = 'X'
        RING = '0'
        max_cross_row = 0
        max_ring_row = GAMESIZE-1
        for i in range(GAMESIZE):
            for j in range(GAMESIZE):
                if a_board.the_grid[i][j] == CROSS:
                    if i > max_cross_row:
                        max_cross_row = i
                if a_board.the_grid[i][j] == RING:
                    if i < max_ring_row:
                        max_ring_row = i
        score = 0
        if self.mark == CROSS:
            score = max_cross_row - (GAMESIZE-1-max_ring_row)
        if self.mark == RING:
            score = (GAMESIZE-1-max_ring_row) - max_cross_row
        return score
  • 1
    \$\begingroup\$ Please clarify the rules of the game. \$\endgroup\$ Commented Oct 19, 2022 at 16:47
  • \$\begingroup\$ Seems like simplified Checkers. \$\endgroup\$
    – Mast
    Commented Oct 19, 2022 at 18:35
  • \$\begingroup\$ It's like chess but with pawns only. You have 6 pawns on each side, one player is circles and one is crosses. The goal is to get to the other side of the board first. You can move one step forward, or "jump" on a diagonal over a piece. If you jump over the opponent's piece, you capture it and it is removed from the board. \$\endgroup\$
    – gustavo
    Commented Oct 20, 2022 at 18:49

2 Answers 2


This bot evaluates the position based solely on whoever is the closest to the finish line. The easiest way to improve it is to account for how many pawns you have on each row. For example:

score = (pawns_on_fifth_row * 1 +
         pawns_on_fourth_row * 0.5 +
         pawns_on_third_row * 0.25 +
         pawns_on_second_row * 0.1)

This however is pretty basic. To get a really strong bot you need to use search along with evaluation. This allows you to see N moves ahead, which increases bot's strength by a lot.

As for the code itself.

Don't use super like this. It was the only way in Python 2, but now you can just write super().__init__(the_mark).

I don't know what a in a_board stands for, it could be just board.

GAMESIZE, CROSS and RING are not specific for the function evaluate_game_status() and therefore should be defined outside (outside the class preferably).

With rules that simple it is even possible to write a perfect bot that can always find the best possible move and win every winnable game. Good luck with that, if you want to try it!


You are putting board- (or game-)logic inside a player class. This is probably a violation of the Separation of Concerns. A fairly common object oriented approach to a board game is to have:

  • a Game object, with all the game logic;
  • a Board object, with all the board representation logic;
  • a Player object or objects, with all the (human and/or computer) player logic

The players are registered with the game class, who calls a method for playing a move.

See this recent review answer, which provides a similar review on a game of tic-tac-toe. This should provide more than enough information to improve your setup.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.