chipiron.players.move_selector.treevalue.search_factory package
Submodules
chipiron.players.move_selector.treevalue.search_factory.search_factory module
This module contains the implementation of the SearchFactory class, which is an abstract factory that creates dependent factories for selecting nodes to open, creating indices, and updating indices. These factories need to operate on the same data, so they are created in a coherent way.
The SearchFactory class provides methods to create the node selector factory, the index updater, and to create node indices for a given tree node.
Classes: - SearchFactory: An abstract factory for creating dependent factories for selecting nodes to open, creating indices, and updating indices.
Protocols: - SearchFactoryP: A protocol that defines the abstract methods for the SearchFactory class.
Functions: - create_node_selector_factory: A function that creates the node selector factory. - create_node_index_updater: A function that creates the index updater. - node_index_create: A function that creates node indices for a given tree node.
- class chipiron.players.move_selector.treevalue.search_factory.search_factory.SearchFactory(node_selector_args: RecurZipfBaseArgs | SequoolArgs | UniformArgs | None, opening_type: OpeningType | None, random_generator: Random | None, index_computation: IndexComputationType | None, depth_index: bool = False)[source]
Bases:
objectThe abstract Factory that creates the following dependent factories in charge of selecting nodes to open - the node selector - the index creator - the index updater These three classes needs to operate on the same data, so they need to be created in a coherent way
- create_node_index_updater() IndexUpdater | None[source]
Creates the index updater.
- Returns:
An instance of the IndexUpdater class if depth indexing is enabled, otherwise None.
- create_node_selector_factory() Callable[[], NodeSelector][source]
Creates the node selector factory .
- Returns:
A callable object that creates the node selector.
- Raises:
AssertionError – If the random generator is not provided.
- depth_index: bool = False
- index_computation: IndexComputationType | None
- node_index_create(tree_node: TreeNode[Any]) NodeExplorationData | None[source]
Creates node indices for a given tree node.
- Parameters:
tree_node – The tree node for which to create the node indices.
- Returns:
An instance of the NodeExplorationData class if depth indexing is enabled, otherwise None.
- node_selector_args: RecurZipfBaseArgs | SequoolArgs | UniformArgs | None
- opening_type: OpeningType | None
- class chipiron.players.move_selector.treevalue.search_factory.search_factory.SearchFactoryP(*args, **kwargs)[source]
Bases:
ProtocolThe abstract Factory that creates the following dependent factories in charge of selecting nodes to open - the node selector - the index creator - the index updater These three classes needs to operate on the same data, so they need to be created in a coherent way
- create_node_index_updater() IndexUpdater | None[source]
Creates and returns an instance of the IndexUpdater class, which is responsible for updating the node index.
- Returns:
An instance of the IndexUpdater class if successful, None otherwise.
- Return type:
IndexUpdater | None
- create_node_selector_factory() Callable[[], NodeSelector][source]
Creates a NodeSelectorFactory object.
- Returns:
The created NodeSelectorFactory object.
- Return type:
NodeSelectorFactory
- node_index_create(tree_node: TreeNode[Any]) NodeExplorationData | None[source]
Creates a node index for the given tree node.
- Parameters:
tree_node (nodes.TreeNode) – The tree node for which to create the index.
- Returns:
The created node index, or None if the index could not be created.
- Return type:
Module contents
This module provides factories for creating search objects and node selectors.
The factories included in this module are: - SearchFactoryP: A factory for creating search objects with parallel execution. - SearchFactory: A factory for creating search objects with sequential execution. - NodeSelectorFactory: A factory for creating node selectors.
To use this module, import the desired factory class from this module and use it to create the desired objects.
- class chipiron.players.move_selector.treevalue.search_factory.SearchFactory(node_selector_args: RecurZipfBaseArgs | SequoolArgs | UniformArgs | None, opening_type: OpeningType | None, random_generator: Random | None, index_computation: IndexComputationType | None, depth_index: bool = False)[source]
Bases:
objectThe abstract Factory that creates the following dependent factories in charge of selecting nodes to open - the node selector - the index creator - the index updater These three classes needs to operate on the same data, so they need to be created in a coherent way
- create_node_index_updater() IndexUpdater | None[source]
Creates the index updater.
- Returns:
An instance of the IndexUpdater class if depth indexing is enabled, otherwise None.
- create_node_selector_factory() Callable[[], NodeSelector][source]
Creates the node selector factory .
- Returns:
A callable object that creates the node selector.
- Raises:
AssertionError – If the random generator is not provided.
- depth_index: bool = False
- index_computation: IndexComputationType | None
- node_index_create(tree_node: TreeNode[Any]) NodeExplorationData | None[source]
Creates node indices for a given tree node.
- Parameters:
tree_node – The tree node for which to create the node indices.
- Returns:
An instance of the NodeExplorationData class if depth indexing is enabled, otherwise None.
- node_selector_args: RecurZipfBaseArgs | SequoolArgs | UniformArgs | None
- opening_type: OpeningType | None
- class chipiron.players.move_selector.treevalue.search_factory.SearchFactoryP(*args, **kwargs)[source]
Bases:
ProtocolThe abstract Factory that creates the following dependent factories in charge of selecting nodes to open - the node selector - the index creator - the index updater These three classes needs to operate on the same data, so they need to be created in a coherent way
- create_node_index_updater() IndexUpdater | None[source]
Creates and returns an instance of the IndexUpdater class, which is responsible for updating the node index.
- Returns:
An instance of the IndexUpdater class if successful, None otherwise.
- Return type:
IndexUpdater | None
- create_node_selector_factory() Callable[[], NodeSelector][source]
Creates a NodeSelectorFactory object.
- Returns:
The created NodeSelectorFactory object.
- Return type:
NodeSelectorFactory
- node_index_create(tree_node: TreeNode[Any]) NodeExplorationData | None[source]
Creates a node index for the given tree node.
- Parameters:
tree_node (nodes.TreeNode) – The tree node for which to create the index.
- Returns:
The created node index, or None if the index could not be created.
- Return type: