chipiron.players.move_selector.treevalue.updates package
Submodules
chipiron.players.move_selector.treevalue.updates.algorithm_node_updater module
- This module contains the AlgorithmNodeUpdater class, which is responsible for updating AlgorithmNode objects in a
tree structure.
- The AlgorithmNodeUpdater class provides methods for creating update instructions after a node is added to the
- tree, generating update instructions for a batch of tree expansions, and performing updates on a specific node
based on the given update instructions.
- class chipiron.players.move_selector.treevalue.updates.algorithm_node_updater.AlgorithmNodeUpdater(minmax_evaluation_updater: MinMaxEvaluationUpdater, index_updater: IndexUpdater | None = None)[source]
Bases:
objectThe AlgorithmNodeUpdater class is responsible for updating AlgorithmNode objects in a tree.
- Variables:
minmax_evaluation_updater (MinMaxEvaluationUpdater) – The updater for min-max evaluation values.
index_updater (IndexUpdater | None) – The updater for node indices, if available.
- create_update_instructions_after_node_birth(new_node: AlgorithmNode) UpdateInstructionsFromOneNode[source]
Creates update instructions after a new node is added to the tree.
- Parameters:
new_node (AlgorithmNode) – The newly added AlgorithmNode.
- Returns:
The update instructions for the new node.
- Return type:
UpdateInstructions
- generate_update_instructions(tree_expansions: tree_man.TreeExpansions) UpdateInstructionsTowardsMultipleNodes[source]
Generates update instructions for a batch of tree expansions.
- Parameters:
tree_expansions (tree_man.TreeExpansions) – The batch of tree expansions.
- Returns:
The update instructions for the batch of tree expansions.
- Return type:
UpdateInstructionsBatch
- index_updater: IndexUpdater | None = None
- minmax_evaluation_updater: MinMaxEvaluationUpdater
- perform_updates(node_to_update: AlgorithmNode, update_instructions: UpdateInstructionsTowardsOneParentNode) UpdateInstructionsFromOneNode[source]
Performs updates on a specific node based on the given update instructions.
- Parameters:
node_to_update (AlgorithmNode) – The node to update.
update_instructions (UpdateInstructions) – The update instructions for the node.
- Returns:
The new update instructions after performing the updates.
- Return type:
UpdateInstructions
chipiron.players.move_selector.treevalue.updates.factory module
This module provides a factory function to create an instance of AlgorithmNodeUpdater.
The AlgorithmNodeUpdater is responsible for updating the algorithm node in a tree structure.
The factory function create_algorithm_node_updater takes an optional index_updater parameter and returns an instance of AlgorithmNodeUpdater.
- Example usage:
algorithm_node_updater = create_algorithm_node_updater(index_updater)
- chipiron.players.move_selector.treevalue.updates.factory.create_algorithm_node_updater(index_updater: IndexUpdater | None) AlgorithmNodeUpdater[source]
Creates an instance of AlgorithmNodeUpdater.
- Parameters:
index_updater (IndexUpdater | None) – The index updater object.
- Returns:
An instance of AlgorithmNodeUpdater.
- Return type:
chipiron.players.move_selector.treevalue.updates.index_block module
This module defines the IndexUpdateInstructionsBlock class, which represents a block of update instructions for index values in a tree structure.
The IndexUpdateInstructionsBlock class is a dataclass that contains a set of AlgorithmNode objects representing children with updated index values. It provides methods for merging update instructions and printing information about the block.
- class chipiron.players.move_selector.treevalue.updates.index_block.IndexUpdateInstructionsFromOneNode(node_sending_update: AlgorithmNode, updated_index: bool)[source]
Bases:
objectRepresents a block of instructions for updating an index.
- Variables:
node_sending_update (AlgorithmNode) – The node sending the update.
updated_index (bool) – Indicates whether the index has been updated.
- node_sending_update: AlgorithmNode
- updated_index: bool
- class chipiron.players.move_selector.treevalue.updates.index_block.IndexUpdateInstructionsTowardsOneParentNode(moves_with_updated_index: set[int] = <factory>)[source]
Bases:
objectRepresents a block of index update instructions intended to a specific node in the algorithm tree.
This class is used to store and manipulate sets of children with updated index values.
- Variables:
moves_with_updated_index (Set[IMove]) – A set of children with updated index values.
- add_update_from_one_child_node(update_from_one_child_node: IndexUpdateInstructionsFromOneNode, move_from_parent_to_child: int) None[source]
- empty() bool[source]
Check if the IndexUpdateInstructionsBlock is empty.
- Returns:
True if the block is empty, False otherwise.
- Return type:
bool
- moves_with_updated_index: set[int]
chipiron.players.move_selector.treevalue.updates.index_updater module
This module contains the IndexUpdater class, which is responsible for updating the indices of AlgorithmNode objects in a tree structure.
- class chipiron.players.move_selector.treevalue.updates.index_updater.IndexUpdater[source]
Bases:
objectThe IndexUpdater class is responsible for updating the indices of AlgorithmNode objects in a tree structure.
- create_update_instructions_after_node_birth(new_node: AlgorithmNode) IndexUpdateInstructionsFromOneNode[source]
Creates the update instructions block after a new node is added to the tree.
- Parameters:
new_node (AlgorithmNode) – The newly added node.
- Returns:
The update instructions block.
- Return type:
IndexUpdateInstructionsBlock
- perform_updates(node_to_update: AlgorithmNode, updates_instructions: UpdateInstructionsTowardsOneParentNode) IndexUpdateInstructionsFromOneNode[source]
Performs the index updates based on the given update instructions.
- Parameters:
node_to_update (AlgorithmNode) – The node to update.
updates_instructions (UpdateInstructionsTowardsOneParentNode) – The update instructions toward this node.
- Returns:
The update instructions coming from the updated node.
- Return type:
chipiron.players.move_selector.treevalue.updates.minmax_evaluation_updater module
This module contains the MinMaxEvaluationUpdater class, which is responsible for updating the min-max evaluation values of AlgorithmNode objects.
- class chipiron.players.move_selector.treevalue.updates.minmax_evaluation_updater.MinMaxEvaluationUpdater[source]
Bases:
objectThe MinMaxEvaluationUpdater class is responsible for updating the min-max evaluation values of AlgorithmNode objects.
- create_update_instructions_after_node_birth(new_node: AlgorithmNode) ValueUpdateInstructionsFromOneNode[source]
Creates the update instructions for a newly created AlgorithmNode.
- Parameters:
new_node (AlgorithmNode) – The newly created AlgorithmNode.
- Returns:
The update instructions for the newly created node.
- Return type:
ValueUpdateInstructionsBlock
- perform_updates(node_to_update: AlgorithmNode, updates_instructions: UpdateInstructionsTowardsOneParentNode) ValueUpdateInstructionsFromOneNode[source]
Performs the updates on an AlgorithmNode based on the given update instructions.
- Parameters:
node_to_update (AlgorithmNode) – The AlgorithmNode to update.
updates_instructions (UpdateInstructionsTowardsOneParentNode) – The update instructions.
- Returns:
The update instructions for the parents of the updated node.
- Return type:
chipiron.players.move_selector.treevalue.updates.updates_file module
This module contains classes for managing update instructions in a batch.
Classes: - UpdateInstructions: Represents update instructions for a single node. - UpdateInstructionsBatch: Represents a batch of update instructions for multiple nodes.
- class chipiron.players.move_selector.treevalue.updates.updates_file.UpdateInstructionsFromOneNode(value_block: ValueUpdateInstructionsFromOneNode | None = None, index_block: IndexUpdateInstructionsFromOneNode | None = None)[source]
Bases:
objectRepresents update instructions generated from a single node.
Attributes: - value_block: The value update instructions generated from a single node. - index_block: The index update instructions generated from a single node.
- index_block: IndexUpdateInstructionsFromOneNode | None
- value_block: ValueUpdateInstructionsFromOneNode | None
- class chipiron.players.move_selector.treevalue.updates.updates_file.UpdateInstructionsTowardsMultipleNodes(one_node_instructions: chipiron.utils.dict_of_numbered_dict_with_pointer_on_max.DictOfNumberedDictWithPointerOnMax[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[typing.Any], chipiron.players.move_selector.treevalue.updates.updates_file.UpdateInstructionsTowardsOneParentNode] = <factory>)[source]
Bases:
object- __bool__() bool[source]
Checks if the data structure is non-empty.
- Returns:
True if the data structure is non-empty, False otherwise.
- Return type:
bool
- add_update_from_one_child_node(update_from_child_node: UpdateInstructionsFromOneNode, parent_node: ITreeNode[Any], move_from_parent: int) None[source]
- add_updates_towards_one_parent_node(update_from_child_node: UpdateInstructionsTowardsOneParentNode, parent_node: ITreeNode[Any]) None[source]
- one_node_instructions: DictOfNumberedDictWithPointerOnMax[ITreeNode[Any], UpdateInstructionsTowardsOneParentNode]
- class chipiron.players.move_selector.treevalue.updates.updates_file.UpdateInstructionsTowardsOneParentNode(value_updates_toward_one_parent_node: ValueUpdateInstructionsTowardsOneParentNode | None = None, index_updates_toward_one_parent_node: IndexUpdateInstructionsTowardsOneParentNode | None = None)[source]
Bases:
objectRepresents update instructions for a single node.
Attributes: - value_block: The value update instructions block. - index_block: The index update instructions block.
- add_update_from_a_child_node(update_from_a_child_node: UpdateInstructionsFromOneNode, move_from_parent_to_child: int) None[source]
- empty() bool[source]
Checks if the update instructions are empty.
Returns: - True if the update instructions are empty, False otherwise.
- index_updates_toward_one_parent_node: IndexUpdateInstructionsTowardsOneParentNode | None
- value_updates_toward_one_parent_node: ValueUpdateInstructionsTowardsOneParentNode | None
chipiron.players.move_selector.treevalue.updates.value_block module
This module defines the ValueUpdateInstructionsBlock class and a helper function to create instances of it.
- The ValueUpdateInstructionsBlock class represents a block of update instructions for a tree value node in
- a move selector algorithm. It contains sets of moves that have been updated with new values,
best moves, or are newly over.
- The create_value_update_instructions_block function is a helper function that creates an instance of
the ValueUpdateInstructionsBlock class with the specified update instructions.
- class chipiron.players.move_selector.treevalue.updates.value_block.ValueUpdateInstructionsFromOneNode(node_sending_update: chipiron.players.move_selector.treevalue.nodes.algorithm_node.algorithm_node.AlgorithmNode, is_node_newly_over: bool, new_value_for_node: bool, new_best_move_for_node: bool)[source]
Bases:
object- is_node_newly_over: bool
- new_best_move_for_node: bool
- new_value_for_node: bool
- node_sending_update: AlgorithmNode
- class chipiron.players.move_selector.treevalue.updates.value_block.ValueUpdateInstructionsTowardsOneParentNode(moves_with_updated_over: set[int] = <factory>, moves_with_updated_value: set[int] = <factory>, moves_with_updated_best_move: set[int] = <factory>)[source]
Bases:
objectRepresents a block of value-update instructions intended to a specific node in the algorithm tree.
- Variables:
moves_with_updated_over (Set[AlgorithmNode]) – Set of moves with updated ‘over’ value.
moves_with_updated_value (Set[AlgorithmNode]) – Set of moves with updated ‘value’ value.
moves_with_updated_best_move (Set[AlgorithmNode]) – Set of moves with updated ‘best_move’ value.
- add_update_from_one_child_node(update_from_one_child_node: ValueUpdateInstructionsFromOneNode, move_from_parent_to_child: int) None[source]
- empty() bool[source]
Check if all the components of the update instructions block are empty.
- Returns:
True if all components are empty, False otherwise.
- Return type:
bool
- moves_with_updated_best_move: set[int]
- moves_with_updated_over: set[int]
- moves_with_updated_value: set[int]
Module contents
This module provides classes and functions for updating tree values in the move selector.
Classes: - AlgorithmNodeUpdater: A class for updating algorithm nodes in the tree. - MinMaxEvaluationUpdater: A class for updating min-max evaluation values in the tree.
Functions: - create_algorithm_node_updater: A function for creating an instance of AlgorithmNodeUpdater.
Other: - UpdateInstructions: A class representing update instructions for a single node. - UpdateInstructionsBatch: A class representing a batch of update instructions.
- class chipiron.players.move_selector.treevalue.updates.AlgorithmNodeUpdater(minmax_evaluation_updater: MinMaxEvaluationUpdater, index_updater: IndexUpdater | None = None)[source]
Bases:
objectThe AlgorithmNodeUpdater class is responsible for updating AlgorithmNode objects in a tree.
- Variables:
minmax_evaluation_updater (MinMaxEvaluationUpdater) – The updater for min-max evaluation values.
index_updater (IndexUpdater | None) – The updater for node indices, if available.
- create_update_instructions_after_node_birth(new_node: AlgorithmNode) UpdateInstructionsFromOneNode[source]
Creates update instructions after a new node is added to the tree.
- Parameters:
new_node (AlgorithmNode) – The newly added AlgorithmNode.
- Returns:
The update instructions for the new node.
- Return type:
UpdateInstructions
- generate_update_instructions(tree_expansions: tree_man.TreeExpansions) UpdateInstructionsTowardsMultipleNodes[source]
Generates update instructions for a batch of tree expansions.
- Parameters:
tree_expansions (tree_man.TreeExpansions) – The batch of tree expansions.
- Returns:
The update instructions for the batch of tree expansions.
- Return type:
UpdateInstructionsBatch
- index_updater: IndexUpdater | None = None
- minmax_evaluation_updater: MinMaxEvaluationUpdater
- perform_updates(node_to_update: AlgorithmNode, update_instructions: UpdateInstructionsTowardsOneParentNode) UpdateInstructionsFromOneNode[source]
Performs updates on a specific node based on the given update instructions.
- Parameters:
node_to_update (AlgorithmNode) – The node to update.
update_instructions (UpdateInstructions) – The update instructions for the node.
- Returns:
The new update instructions after performing the updates.
- Return type:
UpdateInstructions
- class chipiron.players.move_selector.treevalue.updates.MinMaxEvaluationUpdater[source]
Bases:
objectThe MinMaxEvaluationUpdater class is responsible for updating the min-max evaluation values of AlgorithmNode objects.
- create_update_instructions_after_node_birth(new_node: AlgorithmNode) ValueUpdateInstructionsFromOneNode[source]
Creates the update instructions for a newly created AlgorithmNode.
- Parameters:
new_node (AlgorithmNode) – The newly created AlgorithmNode.
- Returns:
The update instructions for the newly created node.
- Return type:
ValueUpdateInstructionsBlock
- perform_updates(node_to_update: AlgorithmNode, updates_instructions: UpdateInstructionsTowardsOneParentNode) ValueUpdateInstructionsFromOneNode[source]
Performs the updates on an AlgorithmNode based on the given update instructions.
- Parameters:
node_to_update (AlgorithmNode) – The AlgorithmNode to update.
updates_instructions (UpdateInstructionsTowardsOneParentNode) – The update instructions.
- Returns:
The update instructions for the parents of the updated node.
- Return type:
- class chipiron.players.move_selector.treevalue.updates.UpdateInstructionsFromOneNode(value_block: ValueUpdateInstructionsFromOneNode | None = None, index_block: IndexUpdateInstructionsFromOneNode | None = None)[source]
Bases:
objectRepresents update instructions generated from a single node.
Attributes: - value_block: The value update instructions generated from a single node. - index_block: The index update instructions generated from a single node.
- index_block: IndexUpdateInstructionsFromOneNode | None
- value_block: ValueUpdateInstructionsFromOneNode | None
- class chipiron.players.move_selector.treevalue.updates.UpdateInstructionsTowardsMultipleNodes(one_node_instructions: chipiron.utils.dict_of_numbered_dict_with_pointer_on_max.DictOfNumberedDictWithPointerOnMax[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[typing.Any], chipiron.players.move_selector.treevalue.updates.updates_file.UpdateInstructionsTowardsOneParentNode] = <factory>)[source]
Bases:
object- __bool__() bool[source]
Checks if the data structure is non-empty.
- Returns:
True if the data structure is non-empty, False otherwise.
- Return type:
bool
- add_update_from_one_child_node(update_from_child_node: UpdateInstructionsFromOneNode, parent_node: ITreeNode[Any], move_from_parent: int) None[source]
- add_updates_towards_one_parent_node(update_from_child_node: UpdateInstructionsTowardsOneParentNode, parent_node: ITreeNode[Any]) None[source]
- one_node_instructions: DictOfNumberedDictWithPointerOnMax[ITreeNode[Any], UpdateInstructionsTowardsOneParentNode]
- class chipiron.players.move_selector.treevalue.updates.UpdateInstructionsTowardsOneParentNode(value_updates_toward_one_parent_node: ValueUpdateInstructionsTowardsOneParentNode | None = None, index_updates_toward_one_parent_node: IndexUpdateInstructionsTowardsOneParentNode | None = None)[source]
Bases:
objectRepresents update instructions for a single node.
Attributes: - value_block: The value update instructions block. - index_block: The index update instructions block.
- add_update_from_a_child_node(update_from_a_child_node: UpdateInstructionsFromOneNode, move_from_parent_to_child: int) None[source]
- empty() bool[source]
Checks if the update instructions are empty.
Returns: - True if the update instructions are empty, False otherwise.
- index_updates_toward_one_parent_node: IndexUpdateInstructionsTowardsOneParentNode | None
- value_updates_toward_one_parent_node: ValueUpdateInstructionsTowardsOneParentNode | None
- chipiron.players.move_selector.treevalue.updates.create_algorithm_node_updater(index_updater: IndexUpdater | None) AlgorithmNodeUpdater[source]
Creates an instance of AlgorithmNodeUpdater.
- Parameters:
index_updater (IndexUpdater | None) – The index updater object.
- Returns:
An instance of AlgorithmNodeUpdater.
- Return type: