chipiron.players package
Subpackages
- chipiron.players.boardevaluators package
- Subpackages
- chipiron.players.boardevaluators.board_evaluation package
- chipiron.players.boardevaluators.datasets package
- chipiron.players.boardevaluators.neural_networks package
- Subpackages
- Submodules
- chipiron.players.boardevaluators.neural_networks.NNModelType module
- chipiron.players.boardevaluators.neural_networks.NNModelTypeArgs module
- chipiron.players.boardevaluators.neural_networks.board_to_tensor module
- chipiron.players.boardevaluators.neural_networks.factory module
- chipiron.players.boardevaluators.neural_networks.neural_net_board_eval_args module
- chipiron.players.boardevaluators.neural_networks.nn_board_evaluator module
- Module contents
- chipiron.players.boardevaluators.table_base package
- Submodules
- chipiron.players.boardevaluators.table_base.factory module
- chipiron.players.boardevaluators.table_base.syzygy_python module
- chipiron.players.boardevaluators.table_base.syzygy_rust module
- chipiron.players.boardevaluators.table_base.syzygy_table module
- chipiron.players.boardevaluators.table_base.syzygy_thread module
- Module contents
- Submodules
- chipiron.players.boardevaluators.basic_evaluation module
- chipiron.players.boardevaluators.board_evaluator module
BoardEvaluatorGameBoardEvaluatorIGameBoardEvaluatorObservableBoardEvaluatorObservableBoardEvaluator.add_evaluation()ObservableBoardEvaluator.evaluate()ObservableBoardEvaluator.evaluation_chiObservableBoardEvaluator.evaluation_player_blackObservableBoardEvaluator.evaluation_player_whiteObservableBoardEvaluator.evaluation_stockObservableBoardEvaluator.game_board_evaluatorObservableBoardEvaluator.mailboxesObservableBoardEvaluator.notify_new_results()ObservableBoardEvaluator.subscribe()
ValueWhiteWhenOver
- chipiron.players.boardevaluators.factory module
- chipiron.players.boardevaluators.over_event module
HowOverOverEventOverEvent.how_overOverEvent.who_is_winnerOverEvent.__post_init__()OverEvent.becomes_over()OverEvent.get_over_tag()OverEvent.__bool__()OverEvent.is_over()OverEvent.is_win()OverEvent.is_draw()OverEvent.is_winner()OverEvent.print_info()OverEvent.test()OverEvent.becomes_over()OverEvent.get_over_tag()OverEvent.how_overOverEvent.is_draw()OverEvent.is_over()OverEvent.is_win()OverEvent.is_winner()OverEvent.print_info()OverEvent.terminationOverEvent.test()OverEvent.who_is_winner
OverTagsWinner
- chipiron.players.boardevaluators.stockfish_board_evaluator module
- chipiron.players.boardevaluators.test_over_event module
- Module contents
- Subpackages
- chipiron.players.move_selector package
- Subpackages
- Submodules
- chipiron.players.move_selector.factory module
- chipiron.players.move_selector.human module
- chipiron.players.move_selector.move_selector module
- chipiron.players.move_selector.move_selector_args module
- chipiron.players.move_selector.move_selector_types module
- chipiron.players.move_selector.random module
- chipiron.players.move_selector.stockfish module
- Module contents
Submodules
chipiron.players.factory module
Module for creating players.
- chipiron.players.factory.create_chipiron_player(implementation_args: ImplementationArgs, universal_behavior: bool, random_generator: Random, queue_progress_player: Queue[IsDataclass] | None = None, tree_move_limit: int | None = None) Player[source]
Creates the chipiron champion/representative/standard/default player
- Parameters:
depth – int, the depth at which computation should be made.
Returns: the player
- chipiron.players.factory.create_game_player(player_factory_args: PlayerFactoryArgs, player_color: bool, syzygy_table: SyzygyTable[Any] | None, queue_progress_player: Queue[IsDataclass] | None, implementation_args: ImplementationArgs, universal_behavior: bool) GamePlayer[source]
Create a game player
This function creates a game player using the provided player factory arguments and player color.
- Parameters:
player_factory_args (PlayerFactoryArgs) – The arguments for creating the player.
player_color (chess.Color) – The color of the player.
- Returns:
The created game player.
- Return type:
- chipiron.players.factory.create_player(args: PlayerArgs, syzygy: SyzygyTable[Any] | None, random_generator: Random, implementation_args: ImplementationArgs, universal_behavior: bool, queue_progress_player: Queue[IsDataclass] | None = None) Player[source]
Create a player object.
This function creates a player object based on the provided arguments.
- Parameters:
args (PlayerArgs) – The arguments for creating the player.
syzygy (SyzygyTable | None) – The Syzygy table to be used by the player, or None if not available.
random_generator (random.Random) – The random number generator to be used by the player.
- Returns:
The created player object.
- Return type:
chipiron.players.factory_higher_level module
Module for creating player observers.
- class chipiron.players.factory_higher_level.MoveFunction(*args, **kwargs)[source]
Bases:
ProtocolRepresents a move function that can be called on a game board.
- Parameters:
board (BoardChi) – The game board on which the move function is applied.
seed_int (seed) – The seed used for the move function.
- Returns:
This function does not return any value.
- Return type:
None
- class chipiron.players.factory_higher_level.PlayerObserverFactory(*args, **kwargs)[source]
Bases:
Protocolcreates the player and the means to communicate with it
- chipiron.players.factory_higher_level.create_player_observer_distributed_players(player_factory_args: PlayerFactoryArgs, player_color: bool, main_thread_mailbox: Queue[IsDataclass], implementation_args: ImplementationArgs, universal_behavior: bool) tuple[chipiron.players.game_player.GamePlayer | chipiron.players.player_thread.PlayerProcess, chipiron.players.factory_higher_level.MoveFunction][source]
Create a player observer.
This function creates a player observer based on the given parameters.
- Parameters:
board_factory – the board factory to create a board
player_factory_args (PlayerFactoryArgs) – The arguments for creating the player.
player_color (chess.Color) – The color of the player.
main_thread_mailbox (queue.Queue[IsDataclass]) – The mailbox for communication between the main thread
player. (and the) –
- Returns:
A tuple containing the player observer and the move function.
- Return type:
tuple[ PlayerProcess, MoveFunction]
- chipiron.players.factory_higher_level.create_player_observer_factory(each_player_has_its_own_thread: bool, implementation_args: ImplementationArgs, universal_behavior: bool, syzygy_table: SyzygyTable[Any] | None) PlayerObserverFactory[source]
Create a player observer factory. This function creates a player observer factory based on the given parameters. The factory can create player observers that either run in separate threads or in the same process. The choice is determined by the each_player_has_its_own_thread parameter. The factory also takes into account the implementation_args and universal_behavior parameters to customize the behavior of the created player observers. The syzygy_table parameter is used to provide a syzygy table for the player observers. The factory returns a callable that can be used to create player observers with the specified arguments. The created player observers can be used to interact with the game and make moves. The each_player_has_its_own_thread parameter determines whether each player runs in its own thread or in the same process. The implementation_args parameter provides additional arguments for the implementation of the player observers. The universal_behavior parameter determines whether the player observers should exhibit universal behavior.
- Parameters:
each_player_has_its_own_thread (bool) – _description_
implementation_args (ImplementationArgs) – _description_
universal_behavior (bool) – _description_
syzygy_table (SyzygyTable[Any] | None) – _description_
- Returns:
_description_
- Return type:
- chipiron.players.factory_higher_level.create_player_observer_mono_process(player_factory_args: PlayerFactoryArgs, player_color: bool, main_thread_mailbox: Queue[IsDataclass], syzygy_table: SyzygyTable[Any] | None, implementation_args: ImplementationArgs, universal_behavior: bool) tuple[chipiron.players.game_player.GamePlayer, chipiron.players.factory_higher_level.MoveFunction][source]
Create a player observer.
This function creates a player observer based on the given parameters.
- Parameters:
player_factory_args (PlayerFactoryArgs) – The arguments for creating the player.
player_color (chess.Color) – The color of the player.
main_thread_mailbox (queue.Queue[IsDataclass]) – The mailbox for communication between the main thread
player. (and the) –
- Returns:
A tuple containing the player observer and the move function.
- Return type:
tuple[GamePlayer | PlayerProcess, MoveFunction]
- chipiron.players.factory_higher_level.send_board_to_player_process_mailbox(fen_plus_history: FenPlusHistory, seed_int: int, player_process_mailbox: Queue[BoardMessage]) None[source]
Sends the board and seed to the player process mailbox.
This function creates a BoardMessage object with the given board and seed, and puts it into the player_process_mailbox.
- Parameters:
seed_int (int) – The seed to send.
player_process_mailbox (queue.Queue[BoardMessage]) – The mailbox to put the message into.
chipiron.players.game_player module
Module for the GamePlayer class.
- class chipiron.players.game_player.GamePlayer(player: Player, color: bool)[source]
Bases:
objectA class that wraps a player for a game purposes it adds the color information and probably stuff to continue the computation when the opponent is computing
- color: bool
- select_move(fen_plus_history: FenPlusHistory, seed_int: int | None = None) MoveRecommendation[source]
Selects the best move to play based on the current board position.
- Parameters:
seed_int (seed | None, optional) – The seed value for randomization. Defaults to None.
- Raises:
Exception – If there are no legal moves in the current position.
- Returns:
The recommended move to play.
- Return type:
- chipiron.players.game_player.game_player_computes_move_on_board_and_send_move_in_queue(fen_plus_history: FenPlusHistory, game_player: GamePlayer, queue_move: Queue[IsDataclass], seed_int: int) None[source]
Computes the move for the game player on the given board and sends the move in the queue.
- Parameters:
game_player (GamePlayer) – The game player.
queue_move (queue.Queue[IsDataclass]) – The queue to send the move.
seed_int (seed) – The seed for move selection.
- Returns:
None
chipiron.players.player module
Module for the Player class.
- class chipiron.players.player.Player(name: str, syzygy: SyzygyTable[Any] | None, main_move_selector: MoveSelector, board_factory: BoardFactory)[source]
Bases:
objectPlayer selects moves on a given board
- board_factory: BoardFactory
- id: str
- main_move_selector: MoveSelector
- select_move(fen_plus_history: FenPlusHistory, seed_int: int) MoveRecommendation[source]
Returns the best move computed by the player. The player has the option to ask the syzygy table to play it.
- Parameters:
board (BoardChi) – The current board state.
seed_int (seed) – The seed for move selection.
- Returns:
The recommended move.
- Return type:
- syzygy: SyzygyTable[Any] | None
chipiron.players.player_args module
Module for player arguments.
- class chipiron.players.player_args.PlayerArgs(name: str, main_move_selector: TreeAndValuePlayerArgs | CommandLineHumanPlayerArgs | GuiHumanPlayerArgs | Random | StockfishPlayer, syzygy_play: bool)[source]
Bases:
objectRepresents the arguments for a player.
- name
The name of the player.
- Type:
str
- main_move_selector
The main move selector for the player.
- Type:
move_selector.AllMoveSelectorArgs
- syzygy_play
Whether to play with syzygy when possible.
- Type:
bool
- is_human() bool[source]
Check if the player is a human player.
- Returns:
bool: True if the player is a human player, False otherwise.
- main_move_selector: TreeAndValuePlayerArgs | CommandLineHumanPlayerArgs | GuiHumanPlayerArgs | Random | StockfishPlayer
- name: str
- syzygy_play: bool
- class chipiron.players.player_args.PlayerFactoryArgs(player_args: PlayerArgs, seed: int)[source]
Bases:
objectA class representing the arguments for creating a player factory.
- player_args
The arguments for the player.
- Type:
- seed
The seed value for random number generation.
- Type:
int
- player_args: PlayerArgs
- seed: int
chipiron.players.player_ids module
- class chipiron.players.player_ids.PlayerConfigTag(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumThis class is used to identify the player configuration files. Each player configuration file should be listed here as a class attribute. The class also provides methods to check if a player is human and to get the YAML file path for the player configuration.
- CHIPIRON = 'Chipiron'
- COMMAND_LINE_HUMAN = 'Command_Line_Human'
- GUI_HUMAN = 'Gui_Human'
- RANDOM = 'Random'
- RECUR_ZIPF_BASE_3 = 'RecurZipfBase3'
- RECUR_ZIPF_BASE_4 = 'RecurZipfBase4'
- SEQUOOL = 'Sequool'
- Stockfish = 'Stockfish'
- Test_RecurZipfBase3 = 'players_for_test_purposes/RecurZipfBase3'
- Test_RecurZipfBase4 = 'players_for_test_purposes/RecurZipfBase4'
- Test_RecurZipfSequool = 'players_for_test_purposes/RecurZipfSequool'
- Test_Sequool = 'players_for_test_purposes/Sequool'
- Test_Uniform = 'players_for_test_purposes/Uniform'
- UNIFORM = 'Uniform'
- UNIFORM_DEPTH = 'UniformDepth'
- UNIFORM_DEPTH_2 = 'UniformDepth2'
- UNIFORM_DEPTH_3 = 'UniformDepth3'
- get_players_args() PlayerArgs[source]
Get the player arguments from the YAML file. This method fetches the player arguments from the YAML file corresponding to the player’s configuration tag.
- Returns:
The player arguments as a dataclass.
- Return type:
- get_yaml_file_path() str | PathLike[str][source]
Get the YAML file path for the player configuration. This method constructs the file path for the player configuration YAML file based on the player’s configuration tag. It returns the file path as a string.
- Returns:
The file path for the player configuration YAML file.
- Return type:
path
- Raises:
ValueError – If the player configuration tag is not recognized.
chipiron.players.player_thread module
player_thread.py
- class chipiron.players.player_thread.PlayerProcess(player_factory_args: PlayerFactoryArgs, queue_receiving_board: Queue[DataClass], queue_sending_move: Queue[IsDataclass], player_color: bool, implementation_args: ImplementationArgs, universal_behavior: bool)[source]
Bases:
ProcessA class representing a player process.
- This class extends the multiprocessing.Process class and is responsible for running a player
in a separate process.
- game_player
The game player object.
- Type:
- queue_move
The queue for sending move messages.
- Type:
queue.Queue[IsDataclass]
- player_color
The color of the player.
- Type:
chess.Color
- Parameters:
player_factory_args (PlayerFactoryArgs) – The arguments for creating the game player.
queue_board (queue.Queue[DataClass]) – The queue for receiving board messages.
queue_move (queue.Queue[IsDataclass]) – The queue for sending move messages.
player_color (chess.Color) – The color of the player.
- board_factory: BoardFactory
- game_player: GamePlayer
- player_color: bool
- queue_sending_move: Queue[IsDataclass]
- run() None[source]
Executes the player thread.
This method is called when the player thread is started. It continuously checks for messages in the message queue and handles them accordingly. If a message is a BoardMessage, it retrieves the board and seed from the message, computes the move for the board using the game_player, and sends the move to the move queue. If the message is not a BoardMessage, it simply prints the message.
Note: This method runs indefinitely until the thread is stopped externally.
- Returns:
None
chipiron.players.test_creation module
chipiron.players.test_tree_value module
Module contents
Module for players in the game.
- class chipiron.players.GamePlayer(player: Player, color: bool)[source]
Bases:
objectA class that wraps a player for a game purposes it adds the color information and probably stuff to continue the computation when the opponent is computing
- color: bool
- select_move(fen_plus_history: FenPlusHistory, seed_int: int | None = None) MoveRecommendation[source]
Selects the best move to play based on the current board position.
- Parameters:
seed_int (seed | None, optional) – The seed value for randomization. Defaults to None.
- Raises:
Exception – If there are no legal moves in the current position.
- Returns:
The recommended move to play.
- Return type:
- class chipiron.players.Player(name: str, syzygy: SyzygyTable[Any] | None, main_move_selector: MoveSelector, board_factory: BoardFactory)[source]
Bases:
objectPlayer selects moves on a given board
- board_factory: BoardFactory
- id: str
- main_move_selector: MoveSelector
- select_move(fen_plus_history: FenPlusHistory, seed_int: int) MoveRecommendation[source]
Returns the best move computed by the player. The player has the option to ask the syzygy table to play it.
- Parameters:
board (BoardChi) – The current board state.
seed_int (seed) – The seed for move selection.
- Returns:
The recommended move.
- Return type:
- syzygy: SyzygyTable[Any] | None
- class chipiron.players.PlayerArgs(name: str, main_move_selector: TreeAndValuePlayerArgs | CommandLineHumanPlayerArgs | GuiHumanPlayerArgs | Random | StockfishPlayer, syzygy_play: bool)[source]
Bases:
objectRepresents the arguments for a player.
- name
The name of the player.
- Type:
str
- main_move_selector
The main move selector for the player.
- Type:
move_selector.AllMoveSelectorArgs
- syzygy_play
Whether to play with syzygy when possible.
- Type:
bool
- is_human() bool[source]
Check if the player is a human player.
- Returns:
bool: True if the player is a human player, False otherwise.
- main_move_selector: TreeAndValuePlayerArgs | CommandLineHumanPlayerArgs | GuiHumanPlayerArgs | Random | StockfishPlayer
- name: str
- syzygy_play: bool
- class chipiron.players.PlayerFactoryArgs(player_args: PlayerArgs, seed: int)[source]
Bases:
objectA class representing the arguments for creating a player factory.
- player_args
The arguments for the player.
- Type:
- seed
The seed value for random number generation.
- Type:
int
- player_args: PlayerArgs
- seed: int
- class chipiron.players.PlayerProcess(player_factory_args: PlayerFactoryArgs, queue_receiving_board: Queue[DataClass], queue_sending_move: Queue[IsDataclass], player_color: bool, implementation_args: ImplementationArgs, universal_behavior: bool)[source]
Bases:
ProcessA class representing a player process.
- This class extends the multiprocessing.Process class and is responsible for running a player
in a separate process.
- game_player
The game player object.
- Type:
- queue_move
The queue for sending move messages.
- Type:
queue.Queue[IsDataclass]
- player_color
The color of the player.
- Type:
chess.Color
- Parameters:
player_factory_args (PlayerFactoryArgs) – The arguments for creating the game player.
queue_board (queue.Queue[DataClass]) – The queue for receiving board messages.
queue_move (queue.Queue[IsDataclass]) – The queue for sending move messages.
player_color (chess.Color) – The color of the player.
- board_factory: BoardFactory
- game_player: GamePlayer
- player_color: bool
- queue_sending_move: Queue[IsDataclass]
- run() None[source]
Executes the player thread.
This method is called when the player thread is started. It continuously checks for messages in the message queue and handles them accordingly. If a message is a BoardMessage, it retrieves the board and seed from the message, computes the move for the board using the game_player, and sends the move to the move queue. If the message is not a BoardMessage, it simply prints the message.
Note: This method runs indefinitely until the thread is stopped externally.
- Returns:
None
- class chipiron.players.StockfishPlayer(type: ~typing.Literal[<MoveSelectorTypes.Stockfish: 'Stockfish'>], depth: int = 20, time_limit: float = 0.1, engine: ~typing.Any = None)[source]
Bases:
objectA player that selects moves using the Stockfish chess engine.
- type
The type of move selector (for serialization).
- Type:
Literal[MoveSelectorTypes.Stockfish]
- depth
The depth to which Stockfish should search for moves.
- Type:
int
- time_limit
The time limit (in seconds) for Stockfish to search for moves.
- Type:
float
- engine
The Stockfish chess engine instance.
- Type:
Any
- select_move(board
boards.BoardChi, move_seed: int) -> MoveRecommendation: Selects a move based on the given board state and move seed.
- depth: int = 20
- engine: Any = None
- select_move(board: IBoard, move_seed: int) MoveRecommendation[source]
Selects a move based on the given board state and move seed.
- Parameters:
board (boards.BoardChi) – The current board state.
move_seed (int) – The seed for move selection.
- Returns:
A MoveRecommendation object representing the selected move.
- Return type:
- time_limit: float = 0.1
- type: Stockfish: 'Stockfish'>]