AI Agents

class ai.brain.AlphaBetaPruner[source]

Bases: Brain

AI agent following an alpha-beta pruning policy.

class ai.brain.Brain[source]

Bases: ABC

Base abstract class for AI agents.

find_best_move(board: Board, max_branching_factor: int, max_depth: int = 0, time_limit: int = 0) str[source]

Finds the best move for the given board state, following the agent’s policy.

Parameters:
  • board (Board) – Current playing board.

  • max_branching_factor (int) – Maximum branching factor.

  • max_depth (int, optional) – Maximum lookahead depth, defaults to 0.

  • time_limit (int, optional) – Maximum time (in seconds) to calculate the best move, defaults to 0.

Returns:

Stringified best move.

Return type:

str

class ai.brain.Random[source]

Bases: Brain

Random acting AI agent.