chipiron.players.move_selector.treevalue.progress_monitor package

Submodules

chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor module

This module defines stopping criteria for a move selector in a game tree.

The stopping criteria determine when the move selector should stop exploring the game tree and make a decision.

The module includes the following classes:

  • StoppingCriterion: The general stopping criterion class.

  • TreeMoveLimit: A stopping criterion based on a tree move limit.

  • DepthLimit: A stopping criterion based on a depth limit.

It also includes helper classes and functions for creating and managing stopping criteria.

class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.DepthLimit(depth_limit: int, node_selector: DepthToExpendP)[source]

Bases: ProgressMonitor

The stopping criterion based on a depth limit

depth_limit: int
get_percent_of_progress(tree: MoveAndValueTree) int[source]
get_string_of_progress(tree: MoveAndValueTree) str[source]

compute the string that display the progress in the terminal

Returns:

a string that display the progress in the terminal

node_selector: DepthToExpendP
should_we_continue(tree: MoveAndValueTree) bool[source]

Determines whether the search should continue expanding nodes in the tree.

Parameters:

tree (MoveAndValueTree) – The tree containing the moves and their corresponding values.

Returns:

True if the search should continue, False otherwise.

Return type:

bool

class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.DepthLimitArgs(type: ~typing.Literal[<StoppingCriterionTypes.DepthLimit: 'depth_limit'>], depth_limit: int)[source]

Bases: object

Arguments for the depth limit stopping criterion.

depth_limit

The maximum depth allowed for the search.

Type:

int

depth_limit: int
type: DepthLimit: 'depth_limit'>]
class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.DepthToExpendP(*args, **kwargs)[source]

Bases: Protocol

Protocol for objects that provide the current depth to expand.

This protocol defines a single method get_current_depth_to_expand that should be implemented by classes that want to provide the current depth to expand.

None
get_current_depth_to_expand()[source]

Returns the current depth to expand as an integer.

Examples

>>> class MyDepthToExpend(DepthToExpendP):
...     def get_current_depth_to_expand(self) -> int:
...         return 5
...
>>> obj = MyDepthToExpend()
>>> obj.get_current_depth_to_expand()
5
get_current_depth_to_expand() int[source]

Returns the current depth to expand as an integer.

Returns:

The current depth to expand.

Raises:

None

class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.ProgressMonitor[source]

Bases: object

The general stopping criterion base class

abstract get_percent_of_progress(tree: MoveAndValueTree) int[source]
get_string_of_progress(tree: MoveAndValueTree) str[source]

Returns a string representation of the progress made by the stopping criterion.

Parameters:

tree (MoveAndValueTree) – The move and value tree.

Returns:

A string representation of the progress.

Return type:

str

notify_percent_progress(tree: MoveAndValueTree, notify_percent_function: Callable[[int], None] | None) None[source]
respectful_opening_instructions(opening_instructions: OpeningInstructions, tree: MoveAndValueTree) OpeningInstructions[source]

Ensures the opening request do not exceed the stopping criterion

should_we_continue(tree: MoveAndValueTree) bool[source]

Asking should we continue

Returns:

boolean of should we continue

class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.ProgressMonitorP(*args, **kwargs)[source]

Bases: Protocol

The general stopping criterion Protocol

get_percent_of_progress(tree: MoveAndValueTree, notify_function: Callable[[int], None] | None) str[source]
get_string_of_progress(tree: MoveAndValueTree) str[source]

Returns a string representation of the progress made by the stopping criterion.

Parameters:

tree (MoveAndValueTree) – The move and value tree.

Returns:

A string representation of the progress.

Return type:

str

respectful_opening_instructions(opening_instructions: OpeningInstructions, tree: MoveAndValueTree) OpeningInstructions[source]

Ensures the opening request do not exceed the stopping criterion

should_we_continue(tree: MoveAndValueTree) bool[source]

Asking should we continue

Returns:

boolean of should we continue

class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.StoppingCriterionArgs(type: StoppingCriterionTypes)[source]

Bases: object

Represents the arguments for a stopping criterion.

type

The type of stopping criterion.

Type:

StoppingCriterionTypes

type: StoppingCriterionTypes
class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.StoppingCriterionTypes(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Enum class representing different types of stopping criteria for tree value calculation.

DepthLimit = 'depth_limit'
TreeMoveLimit = 'tree_move_limit'
class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.TreeMoveLimit(tree_move_limit: int)[source]

Bases: ProgressMonitor

The stopping criterion based on a tree move limit

get_percent_of_progress(tree: MoveAndValueTree) int[source]
get_string_of_progress(tree: MoveAndValueTree) str[source]

compute the string that display the progress in the terminal

Returns:

a string that display the progress in the terminal

respectful_opening_instructions(opening_instructions: OpeningInstructions, tree: MoveAndValueTree) OpeningInstructions[source]

Ensures the opening request do not exceed the stopping criterion

should_we_continue(tree: MoveAndValueTree) bool[source]

Asking should we continue

Returns:

boolean of should we continue

tree_move_limit: int
class chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.TreeMoveLimitArgs(type: ~typing.Literal[<StoppingCriterionTypes.TreeMoveLimit: 'tree_move_limit'>], tree_move_limit: int)[source]

Bases: object

Arguments for the tree move limit stopping criterion.

tree_move_limit: int
type: TreeMoveLimit: 'tree_move_limit'>]
chipiron.players.move_selector.treevalue.progress_monitor.progress_monitor.create_stopping_criterion(args: TreeMoveLimitArgs | DepthLimitArgs, node_selector: NodeSelector) ProgressMonitor[source]

creating the stopping criterion

Parameters:
  • args

  • node_selector

Returns:

A stopping criterion

Module contents