chipiron.players.move_selector.treevalue.indices.index_manager package
Submodules
chipiron.players.move_selector.treevalue.indices.index_manager.factory module
This module contains the factory function to create a node exploration index manager based on the given index computation
- chipiron.players.move_selector.treevalue.indices.index_manager.factory.create_exploration_index_manager(index_computation: IndexComputationType | None = None) NodeExplorationIndexManager[source]
Creates a node exploration index manager based on the given index computation type.
- Parameters:
index_computation (IndexComputationType | None) – The type of index computation to be used.
None. (Defaults to) –
- Returns:
The created node exploration index manager.
- Return type:
- Raises:
ValueError – If the given index computation type is not found.
chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager module
Module that contains the logic to compute the exploration index of a node in a tree.
- class chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.NodeExplorationIndexManager(*args, **kwargs)[source]
Bases:
ProtocolA protocol for managing the exploration indices of nodes in a tree.
This protocol defines methods for updating the exploration indices of nodes in a tree.
- Parameters:
Protocol (type) – The base protocol type.
- update_node_indices(child_node: AlgorithmNode, parent_node: AlgorithmNode, tree: MoveAndValueTree, child_rank: int) None[source]
Updates the exploration index of a child node in the tree.
- Parameters:
child_node (AlgorithmNode) – The child node to update.
parent_node (AlgorithmNode) – The parent node of the child node.
tree (trees.MoveAndValueTree) – The tree containing the nodes.
child_rank (int) – The rank of the child node among its siblings.
- update_root_node_index(root_node: AlgorithmNode) None[source]
Updates the exploration index of the root node in the tree.
- Parameters:
root_node (AlgorithmNode) – The root node of the tree.
- class chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.NullNodeExplorationIndexManager(*args, **kwargs)[source]
Bases:
NodeExplorationIndexManagerA class representing a null node exploration index manager.
This class is used when there is no need to update the exploration index of nodes in a tree. It inherits from the NodeExplorationIndexManager class.
- update_node_indices(child_node: AlgorithmNode, parent_node: AlgorithmNode, tree: MoveAndValueTree, child_rank: int) None[source]
Updates the exploration index of a child node in the tree.
- Parameters:
child_node (AlgorithmNode) – The child node to update.
parent_node (AlgorithmNode) – The parent node of the child node.
tree (trees.MoveAndValueTree) – The tree containing the nodes.
child_rank (int) – The rank of the child node among its siblings.
- update_root_node_index(root_node: AlgorithmNode) None[source]
Updates the exploration index of the root node in the tree.
- Parameters:
root_node (AlgorithmNode) – The root node of the tree.
- class chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.UpdateIndexGlobalMinChange[source]
Bases:
objectA class that updates the exploration index of nodes in a tree using the global minimum change strategy.
- update_node_indices(child_node: AlgorithmNode, parent_node: AlgorithmNode, tree: MoveAndValueTree, child_rank: int) None[source]
Updates the exploration index of a child node in the tree using the global minimum change strategy.
- Parameters:
child_node (AlgorithmNode) – The child node to update.
parent_node (AlgorithmNode) – The parent node of the child node.
tree (trees.MoveAndValueTree) – The tree containing the nodes.
child_rank (int) – The rank of the child node among its siblings.
- update_root_node_index(root_node: AlgorithmNode) None[source]
Updates the exploration index of the root node in the tree using the global minimum change strategy.
- Parameters:
root_node (AlgorithmNode) – The root node of the tree.
- class chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.UpdateIndexLocalMinChange[source]
Bases:
objectA class that updates the exploration index of nodes in a tree using the local minimum change strategy.
- update_node_indices(child_node: AlgorithmNode, parent_node: AlgorithmNode, tree: MoveAndValueTree, child_rank: int) None[source]
Updates the exploration index of a child node in the tree using the local minimum change strategy.
- Parameters:
child_node (AlgorithmNode) – The child node to update.
parent_node (AlgorithmNode) – The parent node of the child node.
tree (trees.MoveAndValueTree) – The tree containing the nodes.
child_rank (int) – The rank of the child node among its siblings.
- update_root_node_index(root_node: AlgorithmNode) None[source]
Updates the exploration index of the root node in the tree using the local minimum change strategy.
- Parameters:
root_node (AlgorithmNode) – The root node of the tree.
- class chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.UpdateIndexZipfFactoredProba[source]
Bases:
objectA class that updates the exploration index of nodes in a tree using the Zipf factored probability strategy.
- update_node_indices(child_node: AlgorithmNode, parent_node: AlgorithmNode, tree: MoveAndValueTree, child_rank: int) None[source]
Updates the exploration index of a child node in the tree using the Zipf factored probability strategy.
- Parameters:
child_node (AlgorithmNode) – The child node to update.
parent_node (AlgorithmNode) – The parent node of the child node.
tree (trees.MoveAndValueTree) – The tree containing the nodes.
child_rank (int) – The rank of the child node among its siblings.
- update_root_node_index(root_node: AlgorithmNode) None[source]
Updates the exploration index of the root node in the tree using the Zipf factored probability strategy.
- Parameters:
root_node (AlgorithmNode) – The root node of the tree.
- chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.print_all_indices(tree: MoveAndValueTree) None[source]
Prints the exploration indices of all nodes in the given tree.
- Parameters:
tree (trees.MoveAndValueTree) – The tree containing the nodes.
- Returns:
None
- chipiron.players.move_selector.treevalue.indices.index_manager.node_exploration_manager.update_all_indices(tree: MoveAndValueTree, index_manager: NodeExplorationIndexManager) None[source]
- The idea is to compute an index $ind(n)$ for a node $n$ that measures the minimum amount of change
in the value of all the nodes such that this node $n$ becomes the best.
This can be computed recursively as : ind(n) = max( ind(parent(n),.5*abs(value(n)-value(parent(n))))
- Parameters:
index_manager –
tree – a tree
Returns:
Module contents
This module provides functionality for managing exploration index managers.
The module includes the following functions and classes: - create_exploration_index_manager: A function to create an exploration index manager. - NodeExplorationIndexManager: A class representing a node exploration index manager.
- class chipiron.players.move_selector.treevalue.indices.index_manager.NodeExplorationIndexManager(*args, **kwargs)[source]
Bases:
ProtocolA protocol for managing the exploration indices of nodes in a tree.
This protocol defines methods for updating the exploration indices of nodes in a tree.
- Parameters:
Protocol (type) – The base protocol type.
- update_node_indices(child_node: AlgorithmNode, parent_node: AlgorithmNode, tree: MoveAndValueTree, child_rank: int) None[source]
Updates the exploration index of a child node in the tree.
- Parameters:
child_node (AlgorithmNode) – The child node to update.
parent_node (AlgorithmNode) – The parent node of the child node.
tree (trees.MoveAndValueTree) – The tree containing the nodes.
child_rank (int) – The rank of the child node among its siblings.
- update_root_node_index(root_node: AlgorithmNode) None[source]
Updates the exploration index of the root node in the tree.
- Parameters:
root_node (AlgorithmNode) – The root node of the tree.
- chipiron.players.move_selector.treevalue.indices.index_manager.create_exploration_index_manager(index_computation: IndexComputationType | None = None) NodeExplorationIndexManager[source]
Creates a node exploration index manager based on the given index computation type.
- Parameters:
index_computation (IndexComputationType | None) – The type of index computation to be used.
None. (Defaults to) –
- Returns:
The created node exploration index manager.
- Return type:
- Raises:
ValueError – If the given index computation type is not found.