chipiron.players.move_selector.treevalue.node_selector.sequool package
Submodules
chipiron.players.move_selector.treevalue.node_selector.sequool.factory module
factory for sequool node selector
- class chipiron.players.move_selector.treevalue.node_selector.sequool.factory.SequoolArgs(type: ~typing.Literal[<NodeSelectorType.Sequool: 'Sequool'>], recursive_selection_on_all_nodes: bool, random_depth_pick: bool, consider_all_lesser_half_move: bool)[source]
Bases:
objectArguments for the Sequool node selector.
- Variables:
recursive_selection_on_all_nodes (bool) – Flag indicating whether to perform recursive selection on all nodes.
random_depth_pick (bool) – Flag indicating whether to randomly pick a depth for selection.
consider_all_lesser_half_move (bool) – Flag indicating whether to consider all lesser half moves.
- consider_all_lesser_half_move: bool
- random_depth_pick: bool
- recursive_selection_on_all_nodes: bool
- type: Sequool: 'Sequool'>]
- chipiron.players.move_selector.treevalue.node_selector.sequool.factory.create_sequool(opening_instructor: OpeningInstructor, args: SequoolArgs, random_generator: Random) Sequool[source]
Create a sequool node selector object.
- Parameters:
opening_instructor – An opening instructor object.
args – Dictionary of arguments.
random_generator – Random generator object.
- Returns:
A sequool node selector object.
chipiron.players.move_selector.treevalue.node_selector.sequool.sequool module
Sequool
This module contains the implementation of the Sequool node selector. The Sequool node selector is responsible for choosing the best node to open in a move tree based on various selection strategies.
Classes: - HalfMoveSelector: Protocol defining the interface for a half-move selector. - StaticNotOpenedSelector: A node selector that considers the number of visits and selects half-moves based on zipf distribution. - RandomAllSelector: A node selector that selects half-moves randomly. - Sequool: The main class implementing the Sequool node selector.
Functions: - consider_nodes_from_all_lesser_half_moves_in_descendants: Consider all nodes in smaller half-moves than the picked half-move using the descendants object. - consider_nodes_from_all_lesser_half_moves_in_sub_stree: Consider all nodes in smaller half-moves than the picked half-move using tree traversal. - consider_nodes_only_from_half_moves_in_descendants: Consider only the nodes at the picked depth. - get_best_node_from_candidates: Get the best node from a list of candidate nodes based on their exploration index data.
- class chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.HalfMoveSelector(*args, **kwargs)[source]
Bases:
ProtocolProtocol defining the interface for a half-move selector.
- select_half_move(from_node: AlgorithmNode, random_generator: Random) HalfMove[source]
Select the next half-move to consider based on the given node and random generator.
- Parameters:
from_node – The current node.
random_generator – The random generator.
- Returns:
The selected half-move.
- class chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.RandomAllSelector[source]
Bases:
objectA node selector that selects half-moves randomly.
- select_half_move(from_node: AlgorithmNode, random_generator: Random) HalfMove[source]
Select the next half-move to consider based on the given node and random generator.
- Parameters:
from_node – The current node.
random_generator – The random generator.
- Returns:
The selected half-move.
- class chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.Sequool(opening_instructor: OpeningInstructor, all_nodes_not_opened: Descendants, recursif: bool, random_depth_pick: bool, half_move_selector: HalfMoveSelector, random_generator: Random, consider_nodes_from_half_moves: Callable[[HalfMove, AlgorithmNode], list[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[Any]]])[source]
Bases:
objectThe main class implementing the Sequool node selector.
- all_nodes_not_opened: Descendants
- choose_node_and_move_to_open(tree: MoveAndValueTree, latest_tree_expansions: tree_man.TreeExpansions) OpeningInstructions[source]
Choose the best node to open in the move tree and return the opening instructions.
- Parameters:
tree – The move tree.
latest_tree_expansions – The latest tree expansions.
- Returns:
The opening instructions.
- choose_node_and_move_to_open_recur(from_node: AlgorithmNode) OpeningInstructions[source]
Recursively choose the best node to open in the move tree and return the opening instructions.
- Parameters:
from_node – The current node.
- Returns:
The opening instructions.
- consider_nodes_from_half_moves: Callable[[HalfMove, AlgorithmNode], list[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[Any]]]
- half_move_selector: HalfMoveSelector
- opening_instructor: OpeningInstructor
- random_depth_pick: bool
- recursif: bool
- class chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.StaticNotOpenedSelector(all_nodes_not_opened: ~chipiron.players.move_selector.treevalue.trees.descendants.Descendants, count_visits: dict[HalfMove, int] = <factory>)[source]
Bases:
objectA node selector that considers the number of visits and selects half-moves based on zipf distribution.
- all_nodes_not_opened: Descendants
- count_visits: dict[HalfMove, int]
- select_half_move(from_node: AlgorithmNode, random_generator: Random) HalfMove[source]
Select the next half-move to consider based on the given node and random generator.
- Parameters:
from_node – The current node.
random_generator – The random generator.
- Returns:
The selected half-move.
- chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.consider_nodes_from_all_lesser_half_moves_in_descendants(half_move_picked: HalfMove, from_node: AlgorithmNode, descendants: Descendants) list[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[Any]][source]
Consider all the nodes that are in smaller half-moves than the picked half-move using the descendants object.
- Parameters:
half_move_picked – The picked half-move.
from_node – The current node.
descendants – The descendants object.
- Returns:
A list of nodes to consider.
- chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.consider_nodes_from_all_lesser_half_moves_in_sub_stree(half_move_picked: HalfMove, from_node: AlgorithmNode) list[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[Any]][source]
Consider all the nodes that are in smaller half-moves than the picked half-move using tree traversal.
- Parameters:
half_move_picked – The picked half-move.
from_node – The current node.
- Returns:
A list of nodes to consider.
- chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.consider_nodes_only_from_half_moves_in_descendants(half_move_picked: HalfMove, from_node: AlgorithmNode, descendants: Descendants) list[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[Any]][source]
Consider only the nodes at the picked depth.
- Parameters:
half_move_picked – The picked half-move.
from_node – The current node.
descendants – The descendants object.
- Returns:
A list of nodes to consider.
- chipiron.players.move_selector.treevalue.node_selector.sequool.sequool.get_best_node_from_candidates(nodes_to_consider: list[chipiron.players.move_selector.treevalue.nodes.itree_node.ITreeNode[Any]]) AlgorithmNode[source]
Returns the best node from a list of candidate nodes based on their exploration index and half move.
- Parameters:
nodes_to_consider (list[ITreeNode]) – A list of candidate nodes to consider.
- Returns:
The best node from the list of candidates.
- Return type:
Module contents
This module provides functionality for creating and managing Sequool objects.
A Sequool object represents a sequence of operations that can be applied to a dataset.
- Example usage:
from .factory import create_sequool, SequoolArgs
# Create a Sequool object sequool = create_sequool()
# Define the arguments for the Sequool object sequool_args = SequoolArgs()
- class chipiron.players.move_selector.treevalue.node_selector.sequool.SequoolArgs(type: ~typing.Literal[<NodeSelectorType.Sequool: 'Sequool'>], recursive_selection_on_all_nodes: bool, random_depth_pick: bool, consider_all_lesser_half_move: bool)[source]
Bases:
objectArguments for the Sequool node selector.
- Variables:
recursive_selection_on_all_nodes (bool) – Flag indicating whether to perform recursive selection on all nodes.
random_depth_pick (bool) – Flag indicating whether to randomly pick a depth for selection.
consider_all_lesser_half_move (bool) – Flag indicating whether to consider all lesser half moves.
- consider_all_lesser_half_move: bool
- random_depth_pick: bool
- recursive_selection_on_all_nodes: bool
- type: Sequool: 'Sequool'>]
- chipiron.players.move_selector.treevalue.node_selector.sequool.create_sequool(opening_instructor: OpeningInstructor, args: SequoolArgs, random_generator: Random) Sequool[source]
Create a sequool node selector object.
- Parameters:
opening_instructor – An opening instructor object.
args – Dictionary of arguments.
random_generator – Random generator object.
- Returns:
A sequool node selector object.