chipiron.players.move_selector package
Subpackages
- chipiron.players.move_selector.treevalue package
- Subpackages
- chipiron.players.move_selector.treevalue.indices package
- chipiron.players.move_selector.treevalue.node_evaluator package
- Subpackages
- Submodules
- chipiron.players.move_selector.treevalue.node_evaluator.all_node_evaluators module
- chipiron.players.move_selector.treevalue.node_evaluator.factory module
- chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator module
- chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator_args module
- Module contents
- chipiron.players.move_selector.treevalue.node_factory package
- Submodules
- chipiron.players.move_selector.treevalue.node_factory.algorithm_node_factory module
- chipiron.players.move_selector.treevalue.node_factory.base module
- chipiron.players.move_selector.treevalue.node_factory.factory module
- chipiron.players.move_selector.treevalue.node_factory.node_factory module
- Module contents
- chipiron.players.move_selector.treevalue.node_selector package
- Subpackages
- Submodules
- chipiron.players.move_selector.treevalue.node_selector.factory module
- chipiron.players.move_selector.treevalue.node_selector.move_explorer module
- chipiron.players.move_selector.treevalue.node_selector.node_selector module
- chipiron.players.move_selector.treevalue.node_selector.node_selector_args module
- chipiron.players.move_selector.treevalue.node_selector.node_selector_types module
- chipiron.players.move_selector.treevalue.node_selector.notations_and_statics module
- chipiron.players.move_selector.treevalue.node_selector.opening_instructions module
- Module contents
- chipiron.players.move_selector.treevalue.nodes package
- Subpackages
- Submodules
- chipiron.players.move_selector.treevalue.nodes.itree_node module
- chipiron.players.move_selector.treevalue.nodes.noisy_value_tree_node module
- chipiron.players.move_selector.treevalue.nodes.test_nodes module
- chipiron.players.move_selector.treevalue.nodes.tree_node module
- chipiron.players.move_selector.treevalue.nodes.tree_traversal module
- chipiron.players.move_selector.treevalue.nodes.utils module
- Module contents
- chipiron.players.move_selector.treevalue.progress_monitor package
- chipiron.players.move_selector.treevalue.recommender_rule package
- chipiron.players.move_selector.treevalue.search_factory package
- chipiron.players.move_selector.treevalue.tree_manager package
- Submodules
- chipiron.players.move_selector.treevalue.tree_manager.algorithm_node_tree_manager module
- chipiron.players.move_selector.treevalue.tree_manager.factory module
- chipiron.players.move_selector.treevalue.tree_manager.tree_expander module
- chipiron.players.move_selector.treevalue.tree_manager.tree_manager module
- Module contents
- chipiron.players.move_selector.treevalue.trees package
- Submodules
- chipiron.players.move_selector.treevalue.trees.descendants module
- chipiron.players.move_selector.treevalue.trees.factory module
- chipiron.players.move_selector.treevalue.trees.move_and_value_tree module
- chipiron.players.move_selector.treevalue.trees.tree_visualization module
- Module contents
- chipiron.players.move_selector.treevalue.updates package
- Submodules
- chipiron.players.move_selector.treevalue.updates.algorithm_node_updater module
- chipiron.players.move_selector.treevalue.updates.factory module
- chipiron.players.move_selector.treevalue.updates.index_block module
- chipiron.players.move_selector.treevalue.updates.index_updater module
- chipiron.players.move_selector.treevalue.updates.minmax_evaluation_updater module
- chipiron.players.move_selector.treevalue.updates.updates_file module
- chipiron.players.move_selector.treevalue.updates.value_block module
- Module contents
- Submodules
- chipiron.players.move_selector.treevalue.factory module
- chipiron.players.move_selector.treevalue.tree_and_value_move_selector module
TreeAndValueMoveSelectorTreeAndValueMoveSelector.create_tree_exploration()TreeAndValueMoveSelector.node_selector_createTreeAndValueMoveSelector.print_info()TreeAndValueMoveSelector.queue_progress_playerTreeAndValueMoveSelector.random_generatorTreeAndValueMoveSelector.recommend_move_after_explorationTreeAndValueMoveSelector.select_move()TreeAndValueMoveSelector.stopping_criterion_argsTreeAndValueMoveSelector.tree_factoryTreeAndValueMoveSelector.tree_manager
- chipiron.players.move_selector.treevalue.tree_exploration module
- Module contents
- Subpackages
Submodules
chipiron.players.move_selector.factory module
This module provides a factory function for creating the main move selector based on the given arguments.
- chipiron.players.move_selector.factory.create_main_move_selector(move_selector_instance_or_args: TreeAndValuePlayerArgs | CommandLineHumanPlayerArgs | GuiHumanPlayerArgs | Random | StockfishPlayer, syzygy: SyzygyTable[Any] | None, random_generator: Random, queue_progress_player: Queue[IsDataclass] | None) MoveSelector[source]
Create the main move selector based on the given arguments.
- Parameters:
move_selector_instance_or_args (AllMoveSelectorArgs) – The arguments or instance of the move selector.
syzygy (SyzygyTable | None) – The syzygy table.
random_generator (random.Random) – The random number generator.
- Returns:
The main move selector.
- Return type:
- Raises:
ValueErr or – If the given move selector instance or arguments are invalid.
chipiron.players.move_selector.human module
- This module contains the implementation of the CommandLineHumanMoveSelector class, which allows a human player
to select moves through the command line interface.
- class chipiron.players.move_selector.human.CommandLineHumanMoveSelector[source]
Bases:
objectA move selector that allows a human player to select moves through the command line interface.
- select_move(board: IBoard, move_seed: int) MoveRecommendation[source]
Selects a move based on user input through the command line interface.
- Parameters:
board (boards.BoardChi) – The current state of the chess board.
move_seed (seed) – The seed used for move selection.
- Returns:
The selected move recommendation.
- Return type:
- Raises:
AssertionError – If the selected move is not a legal move.
- class chipiron.players.move_selector.human.CommandLineHumanPlayerArgs(type: ~typing.Literal[<MoveSelectorTypes.CommandLineHuman: 'CommandLineHuman'>])[source]
Bases:
objectRepresents the arguments for a human player that selects moves through the command line interface.
- type: CommandLineHuman: 'CommandLineHuman'>]
chipiron.players.move_selector.move_selector module
This module defines the MoveSelector class and related data structures for selecting moves in a chess game.
- class chipiron.players.move_selector.move_selector.MoveRecommendation(move: str, evaluation: FloatyBoardEvaluation | ForcedOutcome | None = None)[source]
Bases:
objectRepresents a recommended move to play along with an optional evaluation score.
- evaluation: FloatyBoardEvaluation | ForcedOutcome | None = None
- move: str
- class chipiron.players.move_selector.move_selector.MoveSelector(*args, **kwargs)[source]
Bases:
ProtocolProtocol for move selectors in a chess game.
Move selectors are responsible for selecting the best move to play given a chess board and a move seed.
- select_move(board: IBoard, move_seed: int) MoveRecommendation[source]
Selects the best move to play given a chess board and a move seed.
- Parameters:
board – The current chess board.
move_seed – The seed for move selection.
- Returns:
The recommended move to play along with an optional evaluation score.
chipiron.players.move_selector.move_selector_args module
This module defines the MoveSelectorArgs protocol for specifying arguments for MoveSelector construction.
chipiron.players.move_selector.move_selector_types module
This module defines an enumeration class for Move Selector Types.
The MoveSelectorTypes class is a subclass of the str class and the Enum class. It represents different types of move selectors that can be used in a game.
- ivar Random:
Represents a random move selector.
- ivar TreeAndValue:
Represents a move selector based on tree and value.
- ivar Stockfish:
Represents a move selector using the Stockfish engine.
- ivar CommandLineHuman:
Represents a move selector for a human player using the command line.
- ivar GuiHuman:
Represents a move selector for a human player using a graphical user interface.
- class chipiron.players.move_selector.move_selector_types.MoveSelectorTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumEnumeration class representing different types of move selectors.
- CommandLineHuman = 'CommandLineHuman'
- GuiHuman = 'GuiHuman'
- Random = 'Random'
- Stockfish = 'Stockfish'
- TreeAndValue = 'TreeAndValue'
chipiron.players.move_selector.random module
This module provides a random move selector for a chess game.
The Random class in this module implements a move selector that randomly selects a legal move from the given chess board. It uses a random number generator to make the selection.
- Example usage:
random_selector = create_random(random_generator) move = random_selector.select_move(board, move_seed)
- class chipiron.players.move_selector.random.Random(type: ~typing.Literal[<MoveSelectorTypes.Random: 'Random'>], random_generator: ~random.Random = <factory>)[source]
Bases:
objectRandom move selector class.
This class implements a move selector that randomly selects a legal move from the given chess board.
- Variables:
type (Literal[MoveSelectorTypes.Random]) – The type of move selector (for serialization).
random_generator (random.Random) – The random number generator used for making the selection.
- select_move(board: IBoard, move_seed: int) MoveRecommendation[source]
Selects a random move from the given chess board.
- Parameters:
board (boards.BoardChi) – The chess board.
move_seed (seed) – The seed for the random number generator.
- Returns:
The selected move recommendation.
- Return type:
- type: Random: 'Random'>]
chipiron.players.move_selector.stockfish module
- This module contains the implementation of the StockfishPlayer class, which i if self.engine is None:
# Check if Stockfish binary exists if not STOCKFISH_BINARY_PATH.exists():
- raise FileNotFoundError(
f”Stockfish binary not found at {STOCKFISH_BINARY_PATH}.
- “
f”Please install Stockfish by running:
- “
f” make stockfish
- “
f”This will download and install Stockfish to the appropriate location.”
)lector that uses the Stockfish chess engine to recommend moves.
The StockfishPlayer class is a dataclass that represents a player that selects moves using the Stockfish engine. It has the following attributes: - type: A literal value representing the type of move selector (in this case, MoveSelectorTypes.Stockfish). - depth: An integer representing the depth to which Stockfish should search for moves (default is 20). - time_limit: A float representing the time limit (in seconds) for Stockfish to search for moves (default is 0.1). - engine: An instance of the Stockfish engine.
The StockfishPlayer class has the following methods: - select_move: Selects a move based on the given board state and move seed. Returns a MoveRecommendation object. - print_info: Prints the type of move selector.
Note: The Stockfish engine is initialized lazily when the first move is selected, and it is automatically closed after each move is selected.
- class chipiron.players.move_selector.stockfish.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.
- Variables:
type (Literal[MoveSelectorTypes.Stockfish]) – The type of move selector (for serialization).
depth (int) – The depth to which Stockfish should search for moves.
time_limit (float) – The time limit (in seconds) for Stockfish to search for moves.
engine (Any) – The Stockfish chess engine instance.
- 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
- static is_stockfish_available() bool[source]
Check if Stockfish is properly installed and available.
- Returns:
True if Stockfish binary exists and appears to be executable.
- Return type:
bool
- 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:
- Raises:
FileNotFoundError – If Stockfish binary is not found, with instructions to install it.
- time_limit: float = 0.1
- type: Stockfish: 'Stockfish'>]
Module contents
Module for move selection in a chess game.
- class chipiron.players.move_selector.MoveSelector(*args, **kwargs)[source]
Bases:
ProtocolProtocol for move selectors in a chess game.
Move selectors are responsible for selecting the best move to play given a chess board and a move seed.
- select_move(board: IBoard, move_seed: int) MoveRecommendation[source]
Selects the best move to play given a chess board and a move seed.
- Parameters:
board – The current chess board.
move_seed – The seed for move selection.
- Returns:
The recommended move to play along with an optional evaluation score.
- class chipiron.players.move_selector.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.
- Variables:
type (Literal[MoveSelectorTypes.Stockfish]) – The type of move selector (for serialization).
depth (int) – The depth to which Stockfish should search for moves.
time_limit (float) – The time limit (in seconds) for Stockfish to search for moves.
engine (Any) – The Stockfish chess engine instance.
- 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
- static is_stockfish_available() bool[source]
Check if Stockfish is properly installed and available.
- Returns:
True if Stockfish binary exists and appears to be executable.
- Return type:
bool
- 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:
- Raises:
FileNotFoundError – If Stockfish binary is not found, with instructions to install it.
- time_limit: float = 0.1
- type: Stockfish: 'Stockfish'>]
- chipiron.players.move_selector.create_main_move_selector(move_selector_instance_or_args: TreeAndValuePlayerArgs | CommandLineHumanPlayerArgs | GuiHumanPlayerArgs | Random | StockfishPlayer, syzygy: SyzygyTable[Any] | None, random_generator: Random, queue_progress_player: Queue[IsDataclass] | None) MoveSelector[source]
Create the main move selector based on the given arguments.
- Parameters:
move_selector_instance_or_args (AllMoveSelectorArgs) – The arguments or instance of the move selector.
syzygy (SyzygyTable | None) – The syzygy table.
random_generator (random.Random) – The random number generator.
- Returns:
The main move selector.
- Return type:
- Raises:
ValueErr or – If the given move selector instance or arguments are invalid.