chipiron.players.move_selector.treevalue.node_evaluator package
Subpackages
Submodules
chipiron.players.move_selector.treevalue.node_evaluator.all_node_evaluators module
This module defines the different types of node evaluators used in the tree value calculation.
- class chipiron.players.move_selector.treevalue.node_evaluator.all_node_evaluators.NodeEvaluatorTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumEnum class representing different types of node evaluators.
- BasicEvaluation = 'basic_evaluation'
- NeuralNetwork = 'neural_network'
chipiron.players.move_selector.treevalue.node_evaluator.factory module
This module provides a factory function for creating node evaluators based on different types of board evaluators.
- chipiron.players.move_selector.treevalue.node_evaluator.factory.create_node_evaluator(arg_board_evaluator: NeuralNetNodeEvalArgs | BasicEvaluationNodeEvaluatorArgs, syzygy: SyzygyTable[Any] | None) NodeEvaluator[source]
Create a node evaluator based on the given board evaluator argument and syzygy table.
- Parameters:
arg_board_evaluator (AllNodeEvaluatorArgs) – The argument for the board evaluator.
syzygy (SyzygyTable | None) – The syzygy table to be used for evaluation.
- Returns:
The created node evaluator.
- Return type:
- Raises:
SystemExit – If the given board evaluator type is not found.
chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator module
- This module contains the implementation of the NodeEvaluator class, which is responsible for evaluating the value of
nodes in a tree-based move selector.
- The NodeEvaluator class wraps a board evaluator and a syzygy table to provide more complex evaluations of chess
positions. It handles queries for evaluating nodes and manages obvious over events.
Classes: - NodeEvaluator: Wrapping node evaluator with syzygy and obvious over event.
Enums: - NodeEvaluatorTypes: Types of node evaluators.
Constants: - DISCOUNT: Discount factor used in the evaluation.
Functions: - None
- class chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator.EvaluationQueries[source]
Bases:
objectA class that represents evaluation queries for algorithm nodes.
- over_nodes
A list of algorithm nodes that are considered “over”.
- Type:
list[AlgorithmNode]
- not_over_nodes
A list of algorithm nodes that are not considered “over”.
- Type:
list[AlgorithmNode]
- clear_queries() None[source]
Clears the evaluation queries by resetting the over_nodes and not_over_nodes lists.
- class chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator.NodeEvaluator(board_evaluator: BoardEvaluator, syzygy: SyzygyTable[Any] | None)[source]
Bases:
objectThe NodeEvaluator class is responsible for evaluating the value of nodes in a tree structure. It uses a board evaluator and a syzygy evaluator to calculate the value of the nodes.
- add_evaluation_query(node: AlgorithmNode, evaluation_queries: EvaluationQueries) None[source]
Adds an evaluation query for a node.
- board_evaluator: BoardEvaluator
- check_obvious_over_events(node: AlgorithmNode) None[source]
Updates the node.over object if the game is obviously over.
- evaluate_all_not_over(not_over_nodes: list[chipiron.players.move_selector.treevalue.nodes.algorithm_node.algorithm_node.AlgorithmNode]) None[source]
Evaluates all the nodes that are not over.
- evaluate_all_queried_nodes(evaluation_queries: EvaluationQueries) None[source]
Evaluates all the queried nodes.
- evaluate_over(node: AlgorithmNode) None[source]
Evaluates the node when the game is over.
- process_evalution_not_over(evaluation: float, node: AlgorithmNode) float[source]
Processes the evaluation for a node that is not over.
- syzygy_evaluator: SyzygyTable[Any] | None
- syzygy_value_white(board: IBoard) float | None[source]
Calculates the value for the white player of a given board using the syzygy evaluator. If the syzygy evaluator is not available or the board is not in the syzygy table, None is returned.
- value_white(node: ITreeNode[Any]) float[source]
Calculates the value for the white player of a given node. If the value can be obtained from the syzygy evaluator, it is used. Otherwise, the board evaluator is used.
- value_white_from_over_event(over_event: OverEvent) ValueWhiteWhenOver[source]
Returns the value white given an over event.
- class chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator.NodeEvaluatorTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumEnum class representing different types of node evaluators.
- NeuralNetwork = 'neural_network'
chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator_args module
This module defines the NodeEvaluatorArgs class, which represents the arguments for a node evaluator.
Classes: - NodeEvaluatorArgs: Represents the arguments for a node evaluator.
- class chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator_args.BasicEvaluationNodeEvaluatorArgs(syzygy_evaluation: bool, internal_representation_type: ~chipiron.players.boardevaluators.neural_networks.input_converters.ModelInputRepresentationType.InternalTensorRepresentationType, type: ~typing.Literal[<NodeEvaluatorTypes.BasicEvaluation: 'basic_evaluation'>])[source]
Bases:
NodeEvaluatorArgsRepresents the arguments for a node evaluator.
- type: BasicEvaluation: 'basic_evaluation'>]
- class chipiron.players.move_selector.treevalue.node_evaluator.node_evaluator_args.NodeEvaluatorArgs(syzygy_evaluation: bool, internal_representation_type: InternalTensorRepresentationType)[source]
Bases:
objectRepresents the arguments for a node evaluator.
Attributes: - type: The type of the node evaluator. - syzygy_evaluation: A boolean indicating whether syzygy evaluation is enabled. - representation: The representation of the node evaluator.
- internal_representation_type: InternalTensorRepresentationType
- syzygy_evaluation: bool
Module contents
This module provides functionality for evaluating nodes in a tree structure.
The module includes a factory function for creating node evaluators, as well as classes for representing node evaluators, evaluation queries, and node evaluator arguments.
Available objects: - AllNodeEvaluatorArgs: A named tuple representing all the arguments for creating a node evaluator. - NodeEvaluator: A class representing a node evaluator. - create_node_evaluator: A factory function for creating a node evaluator. - EvaluationQueries: An enumeration representing different types of evaluation queries. - NodeEvaluatorArgs: A class representing the arguments for creating a node evaluator.
- class chipiron.players.move_selector.treevalue.node_evaluator.EvaluationQueries[source]
Bases:
objectA class that represents evaluation queries for algorithm nodes.
- over_nodes
A list of algorithm nodes that are considered “over”.
- Type:
list[AlgorithmNode]
- not_over_nodes
A list of algorithm nodes that are not considered “over”.
- Type:
list[AlgorithmNode]
- clear_queries() None[source]
Clears the evaluation queries by resetting the over_nodes and not_over_nodes lists.
- class chipiron.players.move_selector.treevalue.node_evaluator.NodeEvaluator(board_evaluator: BoardEvaluator, syzygy: SyzygyTable[Any] | None)[source]
Bases:
objectThe NodeEvaluator class is responsible for evaluating the value of nodes in a tree structure. It uses a board evaluator and a syzygy evaluator to calculate the value of the nodes.
- add_evaluation_query(node: AlgorithmNode, evaluation_queries: EvaluationQueries) None[source]
Adds an evaluation query for a node.
- board_evaluator: BoardEvaluator
- check_obvious_over_events(node: AlgorithmNode) None[source]
Updates the node.over object if the game is obviously over.
- evaluate_all_not_over(not_over_nodes: list[chipiron.players.move_selector.treevalue.nodes.algorithm_node.algorithm_node.AlgorithmNode]) None[source]
Evaluates all the nodes that are not over.
- evaluate_all_queried_nodes(evaluation_queries: EvaluationQueries) None[source]
Evaluates all the queried nodes.
- evaluate_over(node: AlgorithmNode) None[source]
Evaluates the node when the game is over.
- process_evalution_not_over(evaluation: float, node: AlgorithmNode) float[source]
Processes the evaluation for a node that is not over.
- syzygy_evaluator: SyzygyTable[Any] | None
- syzygy_value_white(board: IBoard) float | None[source]
Calculates the value for the white player of a given board using the syzygy evaluator. If the syzygy evaluator is not available or the board is not in the syzygy table, None is returned.
- value_white(node: ITreeNode[Any]) float[source]
Calculates the value for the white player of a given node. If the value can be obtained from the syzygy evaluator, it is used. Otherwise, the board evaluator is used.
- value_white_from_over_event(over_event: OverEvent) ValueWhiteWhenOver[source]
Returns the value white given an over event.
- class chipiron.players.move_selector.treevalue.node_evaluator.NodeEvaluatorArgs(syzygy_evaluation: bool, internal_representation_type: InternalTensorRepresentationType)[source]
Bases:
objectRepresents the arguments for a node evaluator.
Attributes: - type: The type of the node evaluator. - syzygy_evaluation: A boolean indicating whether syzygy evaluation is enabled. - representation: The representation of the node evaluator.
- internal_representation_type: InternalTensorRepresentationType
- syzygy_evaluation: bool
- chipiron.players.move_selector.treevalue.node_evaluator.create_node_evaluator(arg_board_evaluator: NeuralNetNodeEvalArgs | BasicEvaluationNodeEvaluatorArgs, syzygy: SyzygyTable[Any] | None) NodeEvaluator[source]
Create a node evaluator based on the given board evaluator argument and syzygy table.
- Parameters:
arg_board_evaluator (AllNodeEvaluatorArgs) – The argument for the board evaluator.
syzygy (SyzygyTable | None) – The syzygy table to be used for evaluation.
- Returns:
The created node evaluator.
- Return type:
- Raises:
SystemExit – If the given board evaluator type is not found.