chipiron.players.move_selector.treevalue package

Subpackages

Submodules

chipiron.players.move_selector.treevalue.factory module

This module provides functions for creating a TreeAndValueMoveSelector object.

The TreeAndValueMoveSelector is a player that uses a tree-based approach to select moves in a game. It evaluates the game tree using a node evaluator and selects moves based on a set of criteria defined by the node selector. The player uses a stopping criterion to determine when to stop the search and a recommender rule to recommend a move after exploration.

This module also provides functions for creating the necessary components of the TreeAndValueMoveSelector, such as the node evaluator, node selector, tree factory, and tree manager.

class chipiron.players.move_selector.treevalue.factory.TreeAndValuePlayerArgs(type: ~typing.Literal[<MoveSelectorTypes.TreeAndValue: 'TreeAndValue'>], node_selector: ~chipiron.players.move_selector.treevalue.node_selector.recurzipf.recur_zipf_base.RecurZipfBaseArgs | ~chipiron.players.move_selector.treevalue.node_selector.sequool.factory.SequoolArgs | ~chipiron.players.move_selector.treevalue.node_selector.factory.UniformArgs, opening_type: ~chipiron.players.move_selector.treevalue.node_selector.opening_instructions.OpeningType, board_evaluator: ~chipiron.players.move_selector.treevalue.node_evaluator.neural_networks.factory.NeuralNetNodeEvalArgs | ~chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator_args.BasicEvaluationNodeEvaluatorArgs, stopping_criterion: ~chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.TreeMoveLimitArgs | ~chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.DepthLimitArgs, recommender_rule: ~chipiron.players.move_selector.treevalue.recommender_rule.recommender_rule.AlmostEqualLogistic | ~chipiron.players.move_selector.treevalue.recommender_rule.recommender_rule.SoftmaxRule, index_computation: ~chipiron.players.move_selector.treevalue.indices.node_indices.index_types.IndexComputationType | None = None)[source]

Bases: object

Data class for the arguments of a TreeAndValueMoveSelector.

board_evaluator: NeuralNetNodeEvalArgs | BasicEvaluationNodeEvaluatorArgs
index_computation: IndexComputationType | None = None
node_selector: RecurZipfBaseArgs | SequoolArgs | UniformArgs
opening_type: OpeningType
recommender_rule: AlmostEqualLogistic | SoftmaxRule
stopping_criterion: TreeMoveLimitArgs | DepthLimitArgs
type: TreeAndValue: 'TreeAndValue'>]
chipiron.players.move_selector.treevalue.factory.create_tree_and_value_builders(args: TreeAndValuePlayerArgs, syzygy: SyzygyTable[Any] | None, random_generator: Random, queue_progress_player: Queue[IsDataclass] | None) TreeAndValueMoveSelector[source]

Create a TreeAndValueMoveSelector object with the given arguments.

Parameters:
  • args (TreeAndValuePlayerArgs) – The arguments for creating the TreeAndValueMoveSelector.

  • syzygy (SyzygyTable | None) – The SyzygyTable object for tablebase endgame evaluation.

  • random_generator (random.Random) – The random number generator.

Returns:

The created TreeAndValueMoveSelector object.

Return type:

TreeAndValueMoveSelector

chipiron.players.move_selector.treevalue.tree_and_value_move_selector module

This module contains the implementation of the TreeAndValueMoveSelector class, which is responsible for selecting moves based on a tree and value strategy.

The TreeAndValueMoveSelector class uses a tree-based approach to explore possible moves and select the best move based on a value function. It utilizes a tree manager, a tree factory, stopping criterion arguments, a node selector factory, a random generator, and recommendation functions to guide the move selection process.

The TreeAndValueMoveSelector class provides the following methods: - select_move: Selects the best move based on the tree and value strategy. - print_info: Prints information about the move selector type.

class chipiron.players.move_selector.treevalue.tree_and_value_move_selector.TreeAndValueMoveSelector(tree_manager: AlgorithmNodeTreeManager, tree_factory: MoveAndValueTreeFactory, stopping_criterion_args: TreeMoveLimitArgs | DepthLimitArgs, node_selector_create: Callable[[], NodeSelector], random_generator: Random, recommend_move_after_exploration: AlmostEqualLogistic | SoftmaxRule, queue_progress_player: Queue[IsDataclass] | None)[source]

Bases: object

The TreeAndValueMoveSelector class is responsible for selecting moves based on a tree and value strategy.

Attributes: - tree_manager: The tree manager responsible for managing the algorithm nodes. - tree_factory: The tree factory responsible for creating move and value trees. - stopping_criterion_args: The stopping criterion arguments used to determine when to stop the tree exploration. - node_selector_create: The node selector factory used to create node selectors for tree exploration. - random_generator: The random generator used for randomization during tree exploration. - recommend_move_after_exploration: The recommendation functions used to recommend a move after tree exploration.

create_tree_exploration(board: IBoard) TreeExploration[source]
node_selector_create: Callable[[], NodeSelector]
print_info() None[source]

Prints information about the move selector type.

queue_progress_player: Queue[IsDataclass] | None
random_generator: Random
recommend_move_after_exploration: AlmostEqualLogistic | SoftmaxRule
select_move(board: IBoard, move_seed: int) MoveRecommendation[source]

Selects the best move based on the tree and value strategy.

Args: - board: The current board state. - move_seed: The seed used for randomization during move selection.

Returns: - The recommended move based on the tree and value strategy.

stopping_criterion_args: TreeMoveLimitArgs | DepthLimitArgs
tree_factory: MoveAndValueTreeFactory
tree_manager: AlgorithmNodeTreeManager

chipiron.players.move_selector.treevalue.tree_exploration module

This module contains the implementation of the TreeExploration class, which is responsible for managing a search

for the best move in a given chess position using a tree-based approach.

The TreeExploration class is used to create and manage a tree structure that represents the possible moves and
their evaluations in a chess position. It provides methods for exploring the tree, selecting the best move,

and printing information during the move computation.

The module also includes helper functions for creating a TreeExploration object and its dependencies.

Classes: - TreeExploration: Manages the search for the best move using a tree-based approach.

Functions: - create_tree_exploration: Creates a TreeExploration object with the specified dependencies.

class chipiron.players.move_selector.treevalue.tree_exploration.TreeExploration(tree: MoveAndValueTree, tree_manager: AlgorithmNodeTreeManager, node_selector: NodeSelector, recommend_move_after_exploration: AlmostEqualLogistic | SoftmaxRule, stopping_criterion: ProgressMonitor, notify_percent_function: Callable[[int], None] | None)[source]

Bases: object

Tree Exploration is an object to manage one best move search.

Attributes: - tree: The tree structure representing the possible moves and their evaluations. - tree_manager: The manager for the tree structure. - node_selector: The selector for choosing nodes and moves to open in the tree. - recommend_move_after_exploration: The recommender rule for selecting the best move after the tree exploration. - stopping_criterion: The stopping criterion for determining when to stop the tree exploration.

Methods: - print_info_during_move_computation: Prints information during the move computation. - explore: Explores the tree to find the best move.

explore(random_generator: Random) TreeExplorationResult[source]

Explores the tree to find the best move.

Args: - random_generator: The random number generator.

Returns: - MoveRecommendation: The recommended move and its evaluation.

node_selector: NodeSelector
notify_percent_function: Callable[[int], None] | None
print_info_during_move_computation(random_generator: Random) None[source]

Prints information during the move computation.

Args: - random_generator: The random number generator.

Returns: - None

recommend_move_after_exploration: AlmostEqualLogistic | SoftmaxRule
stopping_criterion: ProgressMonitor
tree: MoveAndValueTree
tree_manager: AlgorithmNodeTreeManager
class chipiron.players.move_selector.treevalue.tree_exploration.TreeExplorationResult(move_recommendation: chipiron.players.move_selector.move_selector.MoveRecommendation, tree: chipiron.players.move_selector.treevalue.trees.move_and_value_tree.MoveAndValueTree)[source]

Bases: object

move_recommendation: MoveRecommendation
tree: MoveAndValueTree
chipiron.players.move_selector.treevalue.tree_exploration.create_tree_exploration(node_selector_create: Callable[[], NodeSelector], starting_board: IBoard, tree_manager: AlgorithmNodeTreeManager, tree_factory: MoveAndValueTreeFactory, stopping_criterion_args: TreeMoveLimitArgs | DepthLimitArgs, recommend_move_after_exploration: AlmostEqualLogistic | SoftmaxRule, queue_progress_player: Queue[IsDataclass] | None) TreeExploration[source]

Creates a TreeExploration object with the specified dependencies.

Args: - node_selector_create: The factory function for creating the node selector. - starting_board: The starting chess board position. - tree_manager: The manager for the tree structure. - tree_factory: The factory for creating the tree structure. - stopping_criterion_args: The arguments for creating the stopping criterion. - recommend_move_after_exploration: The recommender rule for selecting the best move after the tree exploration.

Returns: - TreeExploration: The created TreeExploration object.

Module contents

This module provides functionality for creating tree and value builders for the TreeAndValuePlayer.

The TreeAndValuePlayerArgs class represents the arguments for configuring the TreeAndValuePlayer. The create_tree_and_value_builders function is used to create the tree and value builders.

Example usage:

from chipiron.players.move_selector.treevalue import TreeAndValuePlayerArgs, create_tree_and_value_builders

args = TreeAndValuePlayerArgs(…) builders = create_tree_and_value_builders(args)

# Use the builders to create the TreeAndValuePlayer player = TreeAndValuePlayer(builders.tree_builder, builders.value_builder)

class chipiron.players.move_selector.treevalue.TreeAndValuePlayerArgs(type: ~typing.Literal[<MoveSelectorTypes.TreeAndValue: 'TreeAndValue'>], node_selector: ~chipiron.players.move_selector.treevalue.node_selector.recurzipf.recur_zipf_base.RecurZipfBaseArgs | ~chipiron.players.move_selector.treevalue.node_selector.sequool.factory.SequoolArgs | ~chipiron.players.move_selector.treevalue.node_selector.factory.UniformArgs, opening_type: ~chipiron.players.move_selector.treevalue.node_selector.opening_instructions.OpeningType, board_evaluator: ~chipiron.players.move_selector.treevalue.node_evaluator.neural_networks.factory.NeuralNetNodeEvalArgs | ~chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator_args.BasicEvaluationNodeEvaluatorArgs, stopping_criterion: ~chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.TreeMoveLimitArgs | ~chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.DepthLimitArgs, recommender_rule: ~chipiron.players.move_selector.treevalue.recommender_rule.recommender_rule.AlmostEqualLogistic | ~chipiron.players.move_selector.treevalue.recommender_rule.recommender_rule.SoftmaxRule, index_computation: ~chipiron.players.move_selector.treevalue.indices.node_indices.index_types.IndexComputationType | None = None)[source]

Bases: object

Data class for the arguments of a TreeAndValueMoveSelector.

board_evaluator: NeuralNetNodeEvalArgs | BasicEvaluationNodeEvaluatorArgs
index_computation: IndexComputationType | None = None
node_selector: RecurZipfBaseArgs | SequoolArgs | UniformArgs
opening_type: OpeningType
recommender_rule: AlmostEqualLogistic | SoftmaxRule
stopping_criterion: TreeMoveLimitArgs | DepthLimitArgs
type: TreeAndValue: 'TreeAndValue'>]
chipiron.players.move_selector.treevalue.create_tree_and_value_builders(args: TreeAndValuePlayerArgs, syzygy: SyzygyTable[Any] | None, random_generator: Random, queue_progress_player: Queue[IsDataclass] | None) TreeAndValueMoveSelector[source]

Create a TreeAndValueMoveSelector object with the given arguments.

Parameters:
  • args (TreeAndValuePlayerArgs) – The arguments for creating the TreeAndValueMoveSelector.

  • syzygy (SyzygyTable | None) – The SyzygyTable object for tablebase endgame evaluation.

  • random_generator (random.Random) – The random number generator.

Returns:

The created TreeAndValueMoveSelector object.

Return type:

TreeAndValueMoveSelector