Enums

class core.enums.BugType(*values)[source]

Bases: StrEnum

Bug type.

BEETLE = 'B'
Beetle.
Moves by 1 cell, but can also go above the hive.
Pieces below the Beetle cannot move and the cell is now considered of the Beetle’s color.
Can go above other pieces already above the hive, piling up.
GRASSHOPPER = 'G'
Grasshopper.
Moves in a straight by jumping over other pieces.
LADYBUG = 'L'
Ladybug.
Available with GameType expansion L.
Moves by exactly 3 cells, like a Spider, but the first 2 steps must be above the hive.
MOSQUITO = 'M'
Mosquito.
Available with GameType expansion M.
Moves by coping adiacent pieces’ moveset.
If it goes above the hive by coping a Beetle, it can keep moving like a Beetle until it goes back down.
If it’s only neighboring piece is another Mosquito, it cannot move.
PILLBUG = 'P'
Pillbug.
Available with GameType expansion P.
Moves by 1 cell.
Instead of moving itself, it can move a neighboring piece above itself, and then back down on a neighboring empty cell.
QUEEN_BEE = 'Q'
Queen Bee.
Moves by 1 cell.
Must be placed after the first turn and by the fourth.
Surrounding this piece with other pieces is the win condition.
SOLDIER_ANT = 'A'
Soldier Ant.
Moves by any amount of cells around the hive.
SPIDER = 'S'
Spider.
Moves by exactly 3 cells around the hive.
class core.enums.Command(*values)[source]

Bases: StrEnum

Available command.

BESTMOVE = 'bestmove'
Search for the best move for the current game.
EXIT = 'exit'

Exits the engine.

HELP = 'help'
Displays the list of available commands.
If a command is specified, displays the help for that command.
INFO = 'info'
Displays the identifier string of the engine and list of its capabilities.
NEWGAME = 'newgame'
Starts a game. The game type and state depend on the command arguments.
OPTIONS = 'options'
Displays the available options for the engine.
PASS = 'pass'
Plays a passing move in the current game.
PLAY = 'play'
Plays the specified MoveString in the current game.
UNDO = 'undo'
Undoes the specified amount of moves in the current game.
VALIDMOVES = 'validmoves'
Displays a list of every valid move in the current game.
class core.enums.Direction(*values)[source]

Bases: StrEnum

Hexagonal multi-layered grid direction.
The grid is assumed to be oriented with cells point-up.
DOWN_LEFT = '/|'

Down left side of the hex: /bug

DOWN_RIGHT = '|\\'

Down right side of the hex: bug

LEFT = '-|'

Left side of the hex: -bug

RIGHT = '|-'

Right side of the hex: bug-

UP_LEFT = '\\|'

Up left side of the hex: bug

UP_RIGHT = '|/'

Up right side of the hex: bug/

property anticlockwise

Direction to the left (anticlockwise).

Return type:

Direction

property clockwise

Direction to the right (clockwise).

Return type:

Direction

property delta_index: int

Direction index.

Return type:

int

property is_left: bool

Whether it’s a left direction.

Return type:

bool

property is_right: bool

Whether it’s a right direction.

Return type:

bool

classmethod lefts()[source]

Returns all left directions.

Returns:

List of left directions.

Return type:

list[Direction]

property opposite

Opposite direction.

Return type:

Direction

classmethod rights()[source]

Returns all right directions.

Returns:

List of right directions.

Return type:

list[Direction]

class core.enums.GameState(*values)[source]

Bases: StrEnum

Game state.

BLACK_WINS = 'BlackWins'

Game ended with victory for black.

DRAW = 'Draw'

Game ended with a draw.

IN_PROGRESS = 'InProgress'

Game in progress.

NOT_STARTED = 'NotStarted'

Game not started yet.

WHITE_WINS = 'WhiteWins'

Game ended with victory for white.

classmethod parse(state: str)[source]

Parses a GameStateString.

Parameters:

state (str) – GameStateString.

Returns:

GameState.

Return type:

GameState

class core.enums.GameType(*values)[source]

Bases: Flag

Game type.
Determines the available pieces.
BASE = 1

Base GameType, without expansions.

L = 4

Ladybug GameType, with the Ladybug expansion.

M = 2

Mosquito GameType, with the Mosquito expansion.

P = 8

Pillbug GameType, with the Pillbug expansion.

property index: int
classmethod parse(game_type: str)[source]
Parses a GameTypeString.
The GameTypeString always needs to include the Base GameType.
Parameters:

type (str) – GameTypeString.

Raises:

ValueError – If it’s not a valid GameTypeString.

Returns:

GameType.

Return type:

GameType

property tag: str
class core.enums.Option(*values)[source]

Bases: StrEnum

Engine option.

MAX_BRANCHING_FACTOR = 'MaxBranchingFactor'

Maximum amount of moves that can be considered for each node by Negamax agents.

NUM_THREADS = 'NumThreads'

Available threads to parallelize AI thinking.

STRATEGY_BLACK = 'StrategyBlack'

AI strategy for player black.

STRATEGY_WHITE = 'StrategyWhite'

AI strategy for player white.

class core.enums.OptionType(*values)[source]

Bases: StrEnum

Option type.

BOOL = 'bool'

Boolean type.

ENUM = 'enum'

Enum type.

FLOAT = 'double'

Decimal type.

INT = 'int'

Integer type.

class core.enums.PlayerColor(*values)[source]

Bases: StrEnum

Player color.

BLACK = 'Black'

Black.

WHITE = 'White'

White.

property code: str

Short string representation.

Return type:

str

property opposite

Opposite color.

Return type:

PlayerColor

class core.enums.Strategy(*values)[source]

Bases: StrEnum

Possible AI strategy.

NEGAMAX = 'Negamax'

Negamax with alpha-beta pruning strategy.

RANDOM = 'Random'

Random strategy.