chipiron.players.boardevaluators.table_base package

Submodules

chipiron.players.boardevaluators.table_base.factory module

Module to create a SyzygyTable object if the path to the syzygy tables exists, otherwise return None.

class chipiron.players.boardevaluators.table_base.factory.SyzygyFactory(*args, **kwargs)[source]

Bases: Protocol

class chipiron.players.boardevaluators.table_base.factory.SyzygyProvider(*args, **kwargs)[source]

Bases: Protocol

provide() SyzygyChiTable | None[source]
chipiron.players.boardevaluators.table_base.factory.create_syzygy(use_rust: bool) SyzygyTable[Any] | None[source]

Create a SyzygyTable object

chipiron.players.boardevaluators.table_base.factory.create_syzygy_factory(use_rust: bool) SyzygyFactory[source]

Create a SyzygyTable object

chipiron.players.boardevaluators.table_base.factory.create_syzygy_python() SyzygyChiTable | None[source]

Create a SyzygyTable object if the path to the syzygy tables exists, otherwise return None.

Returns:

The created SyzygyTable object or None if the path does not exist.

Return type:

SyzygyTable | None

chipiron.players.boardevaluators.table_base.factory.create_syzygy_rust() SyzygyRustTable | None[source]

Create a SyzygyTable object if the path to the syzygy tables exists, otherwise return None.

Returns:

The created SyzygyTable object or None if the path does not exist.

Return type:

SyzygyTable | None

chipiron.players.boardevaluators.table_base.syzygy_python module

Module for the SyzygyTable class.

class chipiron.players.boardevaluators.table_base.syzygy_python.SyzygyChiTable(path_to_table: str | PathLike[str])[source]

Bases: SyzygyTable[BoardChi]

A class representing a Syzygy tablebase for chess endgame analysis.

table_base

The Syzygy tablebase object.

Type:

chess.syzygy.Tablebase

fast_in_table(board

boards.BoardChi) -> bool: Check if the given board is suitable for fast tablebase lookup.

in_table(board

boards.BoardChi) -> bool: Check if the given board is in the tablebase.

get_over_event(board

boards.BoardChi) -> tuple[Winner, HowOver]: Get the winner and how the game is over for the given board.

val(board

boards.BoardChi) -> int: Get the value of the given board from the tablebase.

value_white(board

boards.BoardChi) -> int: Get the value of the given board for the white player.

get_over_tag(board

boards.BoardChi) -> OverTags: Get the over tag for the given board.

string_result(board

boards.BoardChi) -> str: Get the string representation of the result for the given board.

dtz(board

boards.BoardChi) -> int: Get the distance-to-zero (DTZ) value for the given board.

best_move(board

boards.BoardChi) -> chess.Move: Get the best move according to the tablebase for the given board.

dtz(board: BoardChi) int[source]

Get the distance-to-zero (DTZ) value for the given board.

Parameters:

board (boards.BoardChi) – The board to get the DTZ value for.

Returns:

The DTZ value for the board.

Return type:

int

table_base: Tablebase
wdl(board: BoardChi) int[source]

chipiron.players.boardevaluators.table_base.syzygy_rust module

Module for the SyzygyTable class.

class chipiron.players.boardevaluators.table_base.syzygy_rust.SyzygyRustTable(path_to_table: str | PathLike[str])[source]

Bases: SyzygyTable[RustyBoardChi]

A class representing a Syzygy tablebase for chess endgame analysis.

table_base

The Syzygy tablebase object.

Type:

chess.syzygy.Tablebase

fast_in_table(board

boards.BoardChi) -> bool: Check if the given board is suitable for fast tablebase lookup.

in_table(board

boards.BoardChi) -> bool: Check if the given board is in the tablebase.

get_over_event(board

boards.BoardChi) -> tuple[Winner, HowOver]: Get the winner and how the game is over for the given board.

val(board

boards.BoardChi) -> int: Get the value of the given board from the tablebase.

value_white(board

boards.BoardChi) -> int: Get the value of the given board for the white player.

get_over_tag(board

boards.BoardChi) -> OverTags: Get the over tag for the given board.

string_result(board

boards.BoardChi) -> str: Get the string representation of the result for the given board.

dtz(board

boards.BoardChi) -> int: Get the distance-to-zero (DTZ) value for the given board.

best_move(board

boards.BoardChi) -> chess.Move: Get the best move according to the tablebase for the given board.

dtz(board: RustyBoardChi) int[source]

Get the distance-to-zero (DTZ) value for the given board.

Parameters:

board (boards.BoardChi) – The board to get the DTZ value for.

Returns:

The DTZ value for the board.

Return type:

int

table_base: MyTableBase
wdl(board: RustyBoardChi) int[source]

chipiron.players.boardevaluators.table_base.syzygy_table module

Module for the SyzygyTable class.

class chipiron.players.boardevaluators.table_base.syzygy_table.SyzygyTable(*args, **kwargs)[source]

Bases: Protocol, Generic

A class representing a Syzygy tablebase for chess endgame analysis.

table_base

The Syzygy tablebase object.

Type:

chess.syzygy.Tablebase

fast_in_table(board

boards.BoardChi) -> bool: Check if the given board is suitable for fast tablebase lookup.

in_table(board

boards.BoardChi) -> bool: Check if the given board is in the tablebase.

get_over_event(board

boards.BoardChi) -> tuple[Winner, HowOver]: Get the winner and how the game is over for the given board.

val(board

boards.BoardChi) -> int: Get the value of the given board from the tablebase.

value_white(board

boards.BoardChi) -> int: Get the value of the given board for the white player.

get_over_tag(board

boards.BoardChi) -> OverTags: Get the over tag for the given board.

string_result(board

boards.BoardChi) -> str: Get the string representation of the result for the given board.

dtz(board

boards.BoardChi) -> int: Get the distance-to-zero (DTZ) value for the given board.

best_move(board

boards.BoardChi) -> chess.Move: Get the best move according to the tablebase for the given board.

best_move(board: T_Board) int[source]

Get the best move according to the tablebase for the given board.

Parameters:

board (boards.BoardChi) – The board to find the best move for.

Returns:

The best move according to the tablebase.

Return type:

chess.Move

dtz(board: T_Board) int[source]

Get the distance-to-zero (DTZ) value for the given board.

Parameters:

board (boards.BoardChi) – The board to get the DTZ value for.

Returns:

The DTZ value for the board.

Return type:

int

fast_in_table(board: T_Board) bool[source]

Check if the given board is suitable for fast tablebase lookup.

Parameters:

board (boards.BoardChi) – The board to check.

Returns:

True if the board is suitable for fast lookup, False otherwise.

Return type:

bool

get_over_event(board: T_Board) tuple[chipiron.players.boardevaluators.over_event.Winner, chipiron.players.boardevaluators.over_event.HowOver][source]

Get the winner and how the game is over for the given board.

Parameters:

board (boards.BoardChi) – The board to analyze.

Returns:

The winner and how the game is over.

Return type:

tuple[Winner, HowOver]

get_over_tag(board: T_Board) OverTags[source]

Get the over tag for the given board.

Parameters:

board (boards.BoardChi) – The board to get the over tag for.

Returns:

The over tag for the board.

Return type:

OverTags

in_table(board: T_Board) bool[source]

Check if the given board is in the tablebase.

Parameters:

board (boards.BoardChi) – The board to check.

Returns:

True if the board is in the tablebase, False otherwise.

Return type:

bool

string_result(board: T_Board) str[source]

Get the string representation of the result for the given board.

Parameters:

board (boards.BoardChi) – The board to get the result for.

Returns:

The string representation of the result.

Return type:

str

val(board: T_Board) int[source]

Get the value of the given board from the tablebase.

Parameters:

board (boards.BoardChi) – The board to get the value for.

Returns:

The value of the board from the tablebase.

Return type:

int

value_white(board: T_Board) int[source]

Get the value of the given board for the white player.

Parameters:

board (boards.BoardChi) – The board to get the value for.

Returns:

The value of the board for the white player.

Return type:

int

wdl(board: T_Board) int[source]

chipiron.players.boardevaluators.table_base.syzygy_thread module

Module that contains the SyzygyProcess class.

class chipiron.players.boardevaluators.table_base.syzygy_thread.SyzygyProcess(syzygy_table: SyzygyTable[Any], queue_board: Queue[Any])[source]

Bases: Process

A class that extends the Process class from the multiprocessing module. This class represents a separate process that runs in parallel with the main program.

syzygy_table

The SyzygyTable object used for tablebase lookups.

Type:

SyzygyTable

queue_board

The queue used for receiving board messages from the main program.

Type:

queue.Queue

run() None[source]

Overrides the run() method of the Process class. This method is called when the process is started.

It continuously listens for board messages from the main program, performs tablebase lookups using the SyzygyTable object, and sends back the corresponding move messages.

stop() None[source]

Stops the SyzygyProcess by setting the stop event.

stopped() bool[source]

Checks if the SyzygyProcess is stopped.

Returns:

True if the process is stopped, False otherwise.

Return type:

bool

Module contents

This module provides functionality for creating and using table bases for board evaluation.

Table bases are precomputed endgame databases that store optimal moves for every possible position in a specific
endgame scenario. These databases can be used to improve the performance of board evaluation algorithms

by providing accurate evaluations for endgame positions.

This module exports the following functions and classes: - create_syzygy: A function for creating a SyzygyTable object. - SyzygyTable: A class representing a table base for endgame evaluation.

class chipiron.players.boardevaluators.table_base.SyzygyTable(*args, **kwargs)[source]

Bases: Protocol, Generic

A class representing a Syzygy tablebase for chess endgame analysis.

table_base

The Syzygy tablebase object.

Type:

chess.syzygy.Tablebase

fast_in_table(board

boards.BoardChi) -> bool: Check if the given board is suitable for fast tablebase lookup.

in_table(board

boards.BoardChi) -> bool: Check if the given board is in the tablebase.

get_over_event(board

boards.BoardChi) -> tuple[Winner, HowOver]: Get the winner and how the game is over for the given board.

val(board

boards.BoardChi) -> int: Get the value of the given board from the tablebase.

value_white(board

boards.BoardChi) -> int: Get the value of the given board for the white player.

get_over_tag(board

boards.BoardChi) -> OverTags: Get the over tag for the given board.

string_result(board

boards.BoardChi) -> str: Get the string representation of the result for the given board.

dtz(board

boards.BoardChi) -> int: Get the distance-to-zero (DTZ) value for the given board.

best_move(board

boards.BoardChi) -> chess.Move: Get the best move according to the tablebase for the given board.

best_move(board: T_Board) int[source]

Get the best move according to the tablebase for the given board.

Parameters:

board (boards.BoardChi) – The board to find the best move for.

Returns:

The best move according to the tablebase.

Return type:

chess.Move

dtz(board: T_Board) int[source]

Get the distance-to-zero (DTZ) value for the given board.

Parameters:

board (boards.BoardChi) – The board to get the DTZ value for.

Returns:

The DTZ value for the board.

Return type:

int

fast_in_table(board: T_Board) bool[source]

Check if the given board is suitable for fast tablebase lookup.

Parameters:

board (boards.BoardChi) – The board to check.

Returns:

True if the board is suitable for fast lookup, False otherwise.

Return type:

bool

get_over_event(board: T_Board) tuple[chipiron.players.boardevaluators.over_event.Winner, chipiron.players.boardevaluators.over_event.HowOver][source]

Get the winner and how the game is over for the given board.

Parameters:

board (boards.BoardChi) – The board to analyze.

Returns:

The winner and how the game is over.

Return type:

tuple[Winner, HowOver]

get_over_tag(board: T_Board) OverTags[source]

Get the over tag for the given board.

Parameters:

board (boards.BoardChi) – The board to get the over tag for.

Returns:

The over tag for the board.

Return type:

OverTags

in_table(board: T_Board) bool[source]

Check if the given board is in the tablebase.

Parameters:

board (boards.BoardChi) – The board to check.

Returns:

True if the board is in the tablebase, False otherwise.

Return type:

bool

string_result(board: T_Board) str[source]

Get the string representation of the result for the given board.

Parameters:

board (boards.BoardChi) – The board to get the result for.

Returns:

The string representation of the result.

Return type:

str

val(board: T_Board) int[source]

Get the value of the given board from the tablebase.

Parameters:

board (boards.BoardChi) – The board to get the value for.

Returns:

The value of the board from the tablebase.

Return type:

int

value_white(board: T_Board) int[source]

Get the value of the given board for the white player.

Parameters:

board (boards.BoardChi) – The board to get the value for.

Returns:

The value of the board for the white player.

Return type:

int

wdl(board: T_Board) int[source]