algorhino-anemone 0.1.1__tar.gz → 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {algorhino_anemone-0.1.1/src/algorhino_anemone.egg-info → algorhino_anemone-0.1.3}/PKG-INFO +7 -7
  2. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/README.md +4 -4
  3. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/pyproject.toml +16 -9
  4. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3/src/algorhino_anemone.egg-info}/PKG-INFO +7 -7
  5. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/algorhino_anemone.egg-info/requires.txt +2 -2
  6. algorhino_anemone-0.1.3/src/anemone/basics.py +23 -0
  7. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/factory.py +13 -20
  8. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/index_manager/node_exploration_manager.py +12 -13
  9. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/node_direct_evaluation/node_direct_evaluator.py +2 -22
  10. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/node_tree_evaluation/node_minmax_evaluation.py +3 -3
  11. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation.py +3 -3
  12. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_factory/__init__.py +2 -2
  13. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_factory/algorithm_node_factory.py +8 -8
  14. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_factory/base.py +8 -7
  15. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/factory.py +7 -5
  16. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/node_selector.py +2 -2
  17. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/opening_instructions.py +8 -9
  18. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/recurzipf/recur_zipf_base.py +6 -6
  19. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/sequool/factory.py +3 -8
  20. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/sequool/sequool.py +26 -41
  21. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/uniform/uniform.py +9 -7
  22. algorhino_anemone-0.1.3/src/anemone/nodes/__init__.py +15 -0
  23. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/nodes/algorithm_node/algorithm_node.py +6 -6
  24. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/nodes/itree_node.py +21 -20
  25. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/nodes/tree_node.py +29 -35
  26. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/nodes/tree_traversal.py +1 -1
  27. algorhino_anemone-0.1.3/src/anemone/nodes/utils.py +138 -0
  28. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/progress_monitor/progress_monitor.py +32 -30
  29. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/recommender_rule/recommender_rule.py +7 -15
  30. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_and_value_branch_selector.py +14 -26
  31. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_exploration.py +44 -53
  32. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_manager/algorithm_node_tree_manager.py +25 -20
  33. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_manager/tree_expander.py +15 -15
  34. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_manager/tree_manager.py +18 -15
  35. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/trees/descendants.py +42 -42
  36. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/trees/tree.py +7 -9
  37. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/trees/tree_visualization.py +9 -9
  38. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/__init__.py +1 -1
  39. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/index_block.py +3 -3
  40. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/minmax_evaluation_updater.py +3 -3
  41. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/updates_file.py +1 -1
  42. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/value_block.py +5 -5
  43. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/utils/dict_of_numbered_dict_with_pointer_on_max.py +6 -6
  44. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/tests/test_indices.py +2 -2
  45. algorhino_anemone-0.1.1/src/anemone/basics.py +0 -36
  46. algorhino_anemone-0.1.1/src/anemone/nodes/__init__.py +0 -15
  47. algorhino_anemone-0.1.1/src/anemone/nodes/utils.py +0 -146
  48. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/LICENSE +0 -0
  49. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/setup.cfg +0 -0
  50. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/algorhino_anemone.egg-info/SOURCES.txt +0 -0
  51. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/algorhino_anemone.egg-info/dependency_links.txt +0 -0
  52. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/algorhino_anemone.egg-info/top_level.txt +0 -0
  53. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/__init__.py +0 -0
  54. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/__init__.py +0 -0
  55. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/index_manager/__init__.py +0 -0
  56. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/index_manager/factory.py +0 -0
  57. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/node_indices/__init__.py +0 -0
  58. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/node_indices/factory.py +0 -0
  59. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/node_indices/index_data.py +0 -0
  60. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/indices/node_indices/index_types.py +0 -0
  61. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/nn/torch_evaluator.py +0 -0
  62. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/__init__.py +0 -0
  63. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/node_direct_evaluation/__init__.py +0 -0
  64. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/node_direct_evaluation/factory.py +0 -0
  65. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation_factory.py +0 -0
  66. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/__init__.py +0 -0
  67. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/branch_explorer.py +0 -0
  68. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/node_selector_args.py +0 -0
  69. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/node_selector_types.py +0 -0
  70. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/notations_and_statics.py +0 -0
  71. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/recurzipf/__init__.py +0 -0
  72. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/sequool/__init__.py +0 -0
  73. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/node_selector/uniform/__init__.py +0 -0
  74. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/nodes/algorithm_node/__init__.py +0 -0
  75. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/progress_monitor/__init__.py +0 -0
  76. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/recommender_rule/__init__.py +0 -0
  77. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/search_factory/__init__.py +0 -0
  78. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/search_factory/search_factory.py +0 -0
  79. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/state_transition.py +0 -0
  80. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_manager/__init__.py +0 -0
  81. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/tree_manager/factory.py +0 -0
  82. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/trees/__init__.py +0 -0
  83. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/trees/factory.py +0 -0
  84. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/algorithm_node_updater.py +0 -0
  85. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/factory.py +0 -0
  86. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/updates/index_updater.py +0 -0
  87. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/utils/comparable.py +0 -0
  88. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/utils/dataclass.py +0 -0
  89. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/utils/logger.py +0 -0
  90. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/utils/my_value_sorted_dict.py +0 -0
  91. {algorhino_anemone-0.1.1 → algorhino_anemone-0.1.3}/src/anemone/utils/small_tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: algorhino-anemone
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: anemone searches trees
5
5
  Author-email: Victor Gabillon <victorgabillon@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.13
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: valanga
16
- Requires-Dist: atomheart
15
+ Requires-Dist: valanga>=0.1.4
16
+ Requires-Dist: atomheart>=0.1.2
17
17
  Requires-Dist: rich
18
18
  Requires-Dist: sortedcollections>=2.1.0
19
19
  Requires-Dist: graphviz
@@ -83,7 +83,7 @@ from anemone.node_selector.factory import UniformArgs
83
83
  from anemone.node_selector.node_selector_types import NodeSelectorType
84
84
  from anemone.progress_monitor.progress_monitor import (
85
85
  StoppingCriterionTypes,
86
- TreeMoveLimitArgs,
86
+ TreeBranchLimitArgs,
87
87
  )
88
88
  from anemone.recommender_rule.recommender_rule import SoftmaxRule
89
89
 
@@ -91,9 +91,9 @@ from anemone.recommender_rule.recommender_rule import SoftmaxRule
91
91
  args = TreeAndValuePlayerArgs(
92
92
  node_selector=UniformArgs(type=NodeSelectorType.UNIFORM),
93
93
  opening_type=None,
94
- stopping_criterion=TreeMoveLimitArgs(
95
- type=StoppingCriterionTypes.TREE_MOVE_LIMIT,
96
- tree_move_limit=100,
94
+ stopping_criterion=TreeBranchLimitArgs(
95
+ type=StoppingCriterionTypes.TREE_BRANCH_LIMIT,
96
+ tree_branch_limit=100,
97
97
  ),
98
98
  recommender_rule=SoftmaxRule(type="softmax", temperature=1.0),
99
99
  )
@@ -39,7 +39,7 @@ from anemone.node_selector.factory import UniformArgs
39
39
  from anemone.node_selector.node_selector_types import NodeSelectorType
40
40
  from anemone.progress_monitor.progress_monitor import (
41
41
  StoppingCriterionTypes,
42
- TreeMoveLimitArgs,
42
+ TreeBranchLimitArgs,
43
43
  )
44
44
  from anemone.recommender_rule.recommender_rule import SoftmaxRule
45
45
 
@@ -47,9 +47,9 @@ from anemone.recommender_rule.recommender_rule import SoftmaxRule
47
47
  args = TreeAndValuePlayerArgs(
48
48
  node_selector=UniformArgs(type=NodeSelectorType.UNIFORM),
49
49
  opening_type=None,
50
- stopping_criterion=TreeMoveLimitArgs(
51
- type=StoppingCriterionTypes.TREE_MOVE_LIMIT,
52
- tree_move_limit=100,
50
+ stopping_criterion=TreeBranchLimitArgs(
51
+ type=StoppingCriterionTypes.TREE_BRANCH_LIMIT,
52
+ tree_branch_limit=100,
53
53
  ),
54
54
  recommender_rule=SoftmaxRule(type="softmax", temperature=1.0),
55
55
  )
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "algorhino-anemone"
8
- version = "0.1.1"
8
+ version = "0.1.3"
9
9
  description = "anemone searches trees"
10
10
  keywords = ["tree", "search"]
11
11
  classifiers = [
@@ -14,9 +14,8 @@ classifiers = [
14
14
  ]
15
15
  requires-python = ">=3.13"
16
16
  dependencies = [
17
- "valanga",
18
- "atomheart",
19
-
17
+ "valanga>=0.1.4",
18
+ "atomheart>=0.1.2",
20
19
  "rich",
21
20
  "sortedcollections>=2.1.0",
22
21
  "graphviz",
@@ -236,9 +235,17 @@ extraPaths = ["src"]
236
235
 
237
236
  [tool.tox]
238
237
  min_version = "4.32.0"
239
- env_list = ["py313", "lint", "typecheck"]
238
+ env_list = ["py313", "lint", "typecheck", "build"]
240
239
  isolated_build = true
241
240
 
241
+ [tool.tox.env.build]
242
+ deps = ["build", "twine"]
243
+ commands = [
244
+ ["python", "-m", "build"],
245
+ ["python", "-m", "twine", "check", "dist/*"],
246
+ ]
247
+
248
+
242
249
  [tool.tox.env_run_base]
243
250
  base_python = ["python3.13"]
244
251
 
@@ -258,8 +265,8 @@ description = "ruff + pylint (fast, no package build/install)"
258
265
  package = "skip"
259
266
  deps = [
260
267
  # runtime deps needed for pylint imports (match [project].dependencies)
261
- "valanga",
262
- "atomheart",
268
+ "valanga>=0.1.4",
269
+ "atomheart>=0.1.2",
263
270
  "rich",
264
271
  "sortedcollections>=2.1.0",
265
272
  "graphviz",
@@ -283,8 +290,8 @@ description = "mypy + pyright (fast, no package build/install)"
283
290
  package = "skip"
284
291
  deps = [
285
292
  # runtime deps for import resolution
286
- "valanga",
287
- "atomheart",
293
+ "valanga>=0.1.4",
294
+ "atomheart>=0.1.2",
288
295
  "rich",
289
296
  "sortedcollections>=2.1.0",
290
297
  "graphviz",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: algorhino-anemone
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: anemone searches trees
5
5
  Author-email: Victor Gabillon <victorgabillon@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.13
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: valanga
16
- Requires-Dist: atomheart
15
+ Requires-Dist: valanga>=0.1.4
16
+ Requires-Dist: atomheart>=0.1.2
17
17
  Requires-Dist: rich
18
18
  Requires-Dist: sortedcollections>=2.1.0
19
19
  Requires-Dist: graphviz
@@ -83,7 +83,7 @@ from anemone.node_selector.factory import UniformArgs
83
83
  from anemone.node_selector.node_selector_types import NodeSelectorType
84
84
  from anemone.progress_monitor.progress_monitor import (
85
85
  StoppingCriterionTypes,
86
- TreeMoveLimitArgs,
86
+ TreeBranchLimitArgs,
87
87
  )
88
88
  from anemone.recommender_rule.recommender_rule import SoftmaxRule
89
89
 
@@ -91,9 +91,9 @@ from anemone.recommender_rule.recommender_rule import SoftmaxRule
91
91
  args = TreeAndValuePlayerArgs(
92
92
  node_selector=UniformArgs(type=NodeSelectorType.UNIFORM),
93
93
  opening_type=None,
94
- stopping_criterion=TreeMoveLimitArgs(
95
- type=StoppingCriterionTypes.TREE_MOVE_LIMIT,
96
- tree_move_limit=100,
94
+ stopping_criterion=TreeBranchLimitArgs(
95
+ type=StoppingCriterionTypes.TREE_BRANCH_LIMIT,
96
+ tree_branch_limit=100,
97
97
  ),
98
98
  recommender_rule=SoftmaxRule(type="softmax", temperature=1.0),
99
99
  )
@@ -1,5 +1,5 @@
1
- valanga
2
- atomheart
1
+ valanga>=0.1.4
2
+ atomheart>=0.1.2
3
3
  rich
4
4
  sortedcollections>=2.1.0
5
5
  graphviz
@@ -0,0 +1,23 @@
1
+ """Basic types and protocols for Anemone."""
2
+
3
+ from typing import Annotated, Protocol
4
+
5
+ from valanga import Color, HasTurn, State
6
+
7
+ type Seed = Annotated[int, "seed"]
8
+ type TreeDepth = Annotated[int, "Depth level of a node in a tree structure"]
9
+
10
+
11
+ class StateWithTurn(State, HasTurn, Protocol):
12
+ """A `valanga.State` that also exposes turn information."""
13
+
14
+ ...
15
+
16
+
17
+ class HasBlackAndWhiteTurn(Protocol):
18
+ """Protocol for state that has black and white turns."""
19
+
20
+ @property
21
+ def turn(self) -> Color:
22
+ """Return the current player's turn color."""
23
+ ...
@@ -1,14 +1,5 @@
1
1
  """
2
- This module provides functions for creating a TreeAndValueMoveSelector object.
3
-
4
- The TreeAndValueMoveSelector is a player that uses a tree-based approach to select moves in a game. It evaluates the
5
- game tree using a node evaluator and selects moves based on a set of criteria defined by the node selector. The player
6
- uses a stopping criterion to determine when to stop the search and a recommender rule to recommend a move after
7
- exploration.
8
-
9
- This module also provides functions for creating the necessary components of the TreeAndValueMoveSelector, such as the
10
- node evaluator, node selector, tree factory, and tree manager.
11
-
2
+ Module for creating Tree and Value Branch Selector objects.
12
3
  """
13
4
 
14
5
  from dataclasses import dataclass
@@ -49,7 +40,7 @@ TREE_AND_VALUE_LITERAL_STRING: Literal["TreeAndValue"] = "TreeAndValue"
49
40
  @dataclass
50
41
  class TreeAndValuePlayerArgs:
51
42
  """
52
- Data class for the arguments of a TreeAndValueMoveSelector.
43
+ Dataclass for Tree and Value Player Arguments.
53
44
  """
54
45
 
55
46
  node_selector: node_selector_m.AllNodeSelectorArgs
@@ -149,13 +140,15 @@ def create_tree_and_value_branch_selector_with_tree_eval_factory[StateT: TurnSta
149
140
  index_updater=search_factory.create_node_index_updater(),
150
141
  )
151
142
 
152
- tree_move_selector: TreeAndValueBranchSelector[StateT] = TreeAndValueBranchSelector(
153
- tree_manager=tree_manager,
154
- random_generator=random_generator,
155
- tree_factory=tree_factory,
156
- node_selector_create=search_factory.create_node_selector_factory(),
157
- stopping_criterion_args=args.stopping_criterion,
158
- recommend_move_after_exploration=args.recommender_rule,
159
- queue_progress_player=queue_progress_player,
143
+ tree_branch_selector: TreeAndValueBranchSelector[StateT] = (
144
+ TreeAndValueBranchSelector(
145
+ tree_manager=tree_manager,
146
+ random_generator=random_generator,
147
+ tree_factory=tree_factory,
148
+ node_selector_create=search_factory.create_node_selector_factory(),
149
+ stopping_criterion_args=args.stopping_criterion,
150
+ recommend_branch_after_exploration=args.recommender_rule,
151
+ queue_progress_player=queue_progress_player,
152
+ )
160
153
  )
161
- return tree_move_selector
154
+ return tree_branch_selector
@@ -71,7 +71,7 @@ class NodeExplorationIndexManager(Protocol):
71
71
  Args:
72
72
  child_node (AlgorithmNode): The child node to update.
73
73
  parent_node (AlgorithmNode): The parent node of the child node.
74
- tree (trees.ValueTree): The tree containing the nodes.
74
+ tree (Tree): The tree containing the nodes.
75
75
  child_rank (int): The rank of the child node among its siblings.
76
76
  """
77
77
  ...
@@ -116,7 +116,7 @@ class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
116
116
  Args:
117
117
  child_node (AlgorithmNode): The child node to update.
118
118
  parent_node (AlgorithmNode): The parent node of the child node.
119
- tree (trees.ValueTree): The tree containing the nodes.
119
+ tree (Tree): The tree containing the nodes.
120
120
  child_rank (int): The rank of the child node among its siblings.
121
121
  """
122
122
  raise NotImplementedError("should not be raised")
@@ -164,7 +164,7 @@ class UpdateIndexGlobalMinChange:
164
164
  Args:
165
165
  child_node (AlgorithmNode): The child node to update.
166
166
  parent_node (AlgorithmNode): The parent node of the child node.
167
- tree (trees.ValueTree): The tree containing the nodes.
167
+ tree (Tree): The tree containing the nodes.
168
168
  child_rank (int): The rank of the child node among its siblings.
169
169
  """
170
170
 
@@ -261,7 +261,7 @@ class UpdateIndexZipfFactoredProba:
261
261
  Args:
262
262
  child_node (AlgorithmNode): The child node to update.
263
263
  parent_node (AlgorithmNode): The parent node of the child node.
264
- tree (trees.ValueTree): The tree containing the nodes.
264
+ tree (Tree): The tree containing the nodes.
265
265
  child_rank (int): The rank of the child node among its siblings.
266
266
  """
267
267
  _ = parent_node
@@ -347,7 +347,7 @@ class UpdateIndexLocalMinChange:
347
347
  Args:
348
348
  child_node (AlgorithmNode): The child node to update.
349
349
  parent_node (AlgorithmNode): The parent node of the child node.
350
- tree (trees.ValueTree): The tree containing the nodes.
350
+ tree (Tree): The tree containing the nodes.
351
351
  child_rank (int): The rank of the child node among its siblings.
352
352
  """
353
353
 
@@ -492,10 +492,9 @@ def update_all_indices[NodeT: AlgorithmNode[Any]](
492
492
  # todo how are we sure that the hm comes in order?
493
493
  parent_node: NodeT
494
494
  for parent_node in tree_nodes[tree_depth].values():
495
- # for child_node in parent_node.moves_children.values():
496
- move_rank: int
495
+ branch_rank: int
497
496
  branch: BranchKey
498
- for move_rank, branch in enumerate(
497
+ for branch_rank, branch in enumerate(
499
498
  parent_node.tree_evaluation.branches_sorted_by_value_
500
499
  ):
501
500
  child_node = parent_node.branches_children[branch]
@@ -511,7 +510,7 @@ def update_all_indices[NodeT: AlgorithmNode[Any]](
511
510
  index_manager.update_node_indices(
512
511
  child_node=child_node,
513
512
  tree=tree,
514
- child_rank=move_rank,
513
+ child_rank=branch_rank,
515
514
  parent_node=parent_node,
516
515
  parent_node_exploration_index_data=parent_node.exploration_index_data,
517
516
  child_node_exploration_index_data=child_node.exploration_index_data,
@@ -529,17 +528,17 @@ def print_all_indices[NodeT: AlgorithmNode[Any]](
529
528
  Prints the exploration indices of all nodes in the given tree.
530
529
 
531
530
  Args:
532
- tree (trees.ValueTree): The tree containing the nodes.
531
+ tree (Tree): The tree containing the nodes.
533
532
 
534
533
  Returns:
535
534
  None
536
535
  """
537
536
  tree_nodes: RangedDescendants[NodeT] = tree.descendants
538
537
 
539
- half_move: int
540
- for half_move in tree_nodes:
538
+ tree_depth: TreeDepth
539
+ for tree_depth in tree_nodes:
541
540
  # todo how are we sure that the hm comes in order?
542
- for parent_node in tree_nodes[half_move].values():
541
+ for parent_node in tree_nodes[tree_depth].values():
543
542
  assert isinstance(parent_node, AlgorithmNode)
544
543
  if parent_node.exploration_index_data is not None:
545
544
  print(
@@ -1,22 +1,5 @@
1
1
  """
2
- This module contains the implementation of the NodeEvaluator class, which is responsible for evaluating the value of
3
- nodes in a tree-based move selector.
4
-
5
- The NodeEvaluator class wraps a board evaluator and a syzygy table to provide more complex evaluations of chess
6
- positions. It handles queries for evaluating nodes and manages obvious over events.
7
-
8
- Classes:
9
- - NodeEvaluator: Wrapping node evaluator with syzygy and obvious over event.
10
-
11
- Enums:
12
- - NodeEvaluatorTypes: Types of node evaluators.
13
-
14
- Constants:
15
- - DISCOUNT: Discount factor used in the evaluation.
16
-
17
- Functions:
18
- - None
19
-
2
+ Module for evaluating algorithm nodes directly using a master state evaluator.
20
3
  """
21
4
 
22
5
  from enum import Enum
@@ -116,10 +99,7 @@ class NodeDirectEvaluator[StateT: State = State]:
116
99
  master_state_evaluator: MasterStateEvaluator,
117
100
  ) -> None:
118
101
  """
119
- Initializes a NodeEvaluator object.
120
-
121
- Args:
122
- state_evaluator (MasterStateEvaluator): The state evaluator used to evaluate the chess state.
102
+ Initializes a new instance of the NodeEvaluator class.
123
103
  """
124
104
  self.master_state_evaluator = master_state_evaluator
125
105
 
@@ -21,12 +21,12 @@ from random import choice
21
21
  from typing import Any, Protocol, Self, runtime_checkable
22
22
 
23
23
  from valanga import (
24
- BoardEvaluation,
25
24
  BranchKey,
26
25
  Color,
27
26
  FloatyStateEvaluation,
28
27
  ForcedOutcome,
29
28
  OverEvent,
29
+ StateEvaluation,
30
30
  TurnState,
31
31
  )
32
32
 
@@ -874,8 +874,8 @@ class NodeMinmaxEvaluation[
874
874
  best_branches.append(branch_key)
875
875
  return best_branches
876
876
 
877
- def evaluate(self) -> BoardEvaluation:
878
- """Build a BoardEvaluation from current minmax state."""
877
+ def evaluate(self) -> StateEvaluation:
878
+ """Build a StateEvaluation from current minmax state."""
879
879
  if self.over_event.is_over():
880
880
  return ForcedOutcome(
881
881
  outcome=self.over_event,
@@ -1,10 +1,10 @@
1
1
  from typing import TYPE_CHECKING, Protocol, Self
2
2
 
3
3
  from valanga import (
4
- BoardEvaluation,
5
4
  BranchKey,
6
5
  OverEvent,
7
6
  State,
7
+ StateEvaluation,
8
8
  )
9
9
 
10
10
  type BranchSortValue = tuple[float, int, int]
@@ -90,8 +90,8 @@ class NodeTreeEvaluation[StateT: State = State](Protocol):
90
90
  """Update terminal state based on updated branches."""
91
91
  ...
92
92
 
93
- def evaluate(self) -> BoardEvaluation:
94
- """Return a board evaluation for this node."""
93
+ def evaluate(self) -> StateEvaluation:
94
+ """Return a state evaluation for this node."""
95
95
  ...
96
96
 
97
97
  def description_tree_visualizer_branch(self, child: "ITreeNode[StateT]") -> str:
@@ -1,11 +1,11 @@
1
1
  """
2
- This module provides the node factory classes for creating tree nodes in the move selector algorithm.
2
+ This module provides the node factory classes for creating tree nodes in the branch selector algorithm.
3
3
 
4
4
  The available classes in this module are:
5
5
  - TreeNodeFactory: A base class for creating tree nodes.
6
6
  - Base: A base class for the node factory classes.
7
7
  - create_node_factory: A function for creating a node factory.
8
- - AlgorithmNodeFactory: A node factory class for the move selector algorithm.
8
+ - AlgorithmNodeFactory: A node factory class for the branch selector algorithm.
9
9
  """
10
10
 
11
11
  from .algorithm_node_factory import AlgorithmNodeFactory
@@ -33,7 +33,7 @@ if TYPE_CHECKING:
33
33
  @dataclass
34
34
  class AlgorithmNodeFactory[StateT: State = State]:
35
35
  """
36
- The classe creating Algorithm Nodes
36
+ Factory for building AlgorithmNode instances.
37
37
  """
38
38
 
39
39
  tree_node_factory: TreeNodeFactory[AlgorithmNode[StateT], StateT]
@@ -92,18 +92,18 @@ class AlgorithmNodeFactory[StateT: State = State]:
92
92
  modifications: StateModifications | None,
93
93
  ) -> AlgorithmNode[StateT]:
94
94
  """
95
- Creates an AlgorithmNode object.
95
+ Create an AlgorithmNode object.
96
96
 
97
97
  Args:
98
- branch_from_parent (BranchKey | None): the move that led to the node from the parent node
99
- state: The state object.
100
- tree_depth: The tree depth.
101
- count: The count.
98
+ branch_from_parent: The branch key leading from the parent node.
99
+ state: The state object for the node.
100
+ tree_depth: The depth of the node in the tree.
101
+ count: The node identifier.
102
102
  parent_node: The parent node object.
103
- modifications: The board modifications object.
103
+ modifications: The state modifications object.
104
104
 
105
105
  Returns:
106
- An AlgorithmNode object.
106
+ The created AlgorithmNode.
107
107
 
108
108
  """
109
109
  tree_node: TreeNode[AlgorithmNode[StateT], StateT] = (
@@ -44,17 +44,18 @@ class TreeNodeFactory[T: ITreeNode[Any] = ITreeNode[Any], StateT: State = State]
44
44
  modifications: StateModifications | None = None,
45
45
  ) -> TreeNode[T, StateT]:
46
46
  """
47
- Creates a new TreeNode object.
47
+ Create a new TreeNode object.
48
48
 
49
49
  Args:
50
- board (boards.BoardChi): The current board state.
51
- half_move (int): The half-move count.
52
- count (int): The ID of the new node.
53
- parent_node (ITreeNode | None): The parent node of the new node.
54
- move_from_parent (chess.Move | None): The move that leads to the new node.
50
+ state: The current state for the node.
51
+ tree_depth: The tree depth for the new node.
52
+ count: The ID of the new node.
53
+ parent_node: The parent node of the new node.
54
+ branch_from_parent: The branch key from the parent node.
55
+ modifications: The state modifications, if any.
55
56
 
56
57
  Returns:
57
- TreeNode: The newly created TreeNode object.
58
+ The newly created TreeNode object.
58
59
  """
59
60
 
60
61
  # TreeNode doesn't use modifications (it's a pure data container).
@@ -36,14 +36,16 @@ def create(
36
36
  Creation of a node selector
37
37
  """
38
38
 
39
- node_move_opening_selector: NodeSelector
39
+ node_branch_opening_selector: NodeSelector
40
40
 
41
41
  match args.type:
42
42
  case NodeSelectorType.UNIFORM:
43
- node_move_opening_selector = Uniform(opening_instructor=opening_instructor)
43
+ node_branch_opening_selector = Uniform(
44
+ opening_instructor=opening_instructor
45
+ )
44
46
  case NodeSelectorType.RECUR_ZIPF_BASE:
45
47
  assert isinstance(args, RecurZipfBaseArgs)
46
- node_move_opening_selector = RecurZipfBase(
48
+ node_branch_opening_selector = RecurZipfBase(
47
49
  args=args,
48
50
  random_generator=random_generator,
49
51
  opening_instructor=opening_instructor,
@@ -51,7 +53,7 @@ def create(
51
53
 
52
54
  case NodeSelectorType.SEQUOOL:
53
55
  assert isinstance(args, SequoolArgs)
54
- node_move_opening_selector = create_sequool(
56
+ node_branch_opening_selector = create_sequool(
55
57
  opening_instructor=opening_instructor,
56
58
  random_generator=random_generator,
57
59
  args=args,
@@ -62,4 +64,4 @@ def create(
62
64
  f"node selector construction: can not find {args.type} {args} in file {__name__}"
63
65
  )
64
66
 
65
- return node_move_opening_selector
67
+ return node_branch_opening_selector
@@ -32,13 +32,13 @@ class NodeSelector[NodeT: AlgorithmNode[Any] = AlgorithmNode[Any]](Protocol):
32
32
  latest_tree_expansions: "tree_man.TreeExpansions[NodeT]",
33
33
  ) -> OpeningInstructions[NodeT]:
34
34
  """
35
- Selects a node from the given tree and returns the instructions to move to an open position.
35
+ Selects a node from the given tree and returns the instructions to open a branch.
36
36
 
37
37
  Args:
38
38
  tree: The tree containing the nodes.
39
39
  latest_tree_expansions: The latest expansions of the tree.
40
40
 
41
41
  Returns:
42
- OpeningInstructions: The instructions to move to an open position.
42
+ OpeningInstructions: The instructions to open a branch.
43
43
  """
44
44
  raise NotImplementedError()
@@ -1,5 +1,5 @@
1
1
  """
2
- This module contains classes and functions related to opening instructions in a chess game.
2
+ This module contains classes and functions related to opening instructions in a game tree.
3
3
  """
4
4
 
5
5
  from dataclasses import dataclass
@@ -11,8 +11,8 @@ from valanga import BranchKey
11
11
 
12
12
  from anemone import nodes
13
13
  from anemone.nodes.utils import (
14
+ a_branch_key_sequence_from_root,
14
15
  a_branch_str_sequence_from_root,
15
- a_move_key_sequence_from_root,
16
16
  )
17
17
 
18
18
  type OpeningInstructionKey = tuple[int, BranchKey]
@@ -33,7 +33,7 @@ class OpeningInstruction[NodeT: nodes.ITreeNode[Any] = nodes.ITreeNode[Any]]:
33
33
  """
34
34
  print(
35
35
  f"OpeningInstruction: node_to_open {self.node_to_open.id} at hm {self.node_to_open.tree_depth} {self.node_to_open.state}| "
36
- f"a path from root to node_to_open is {a_move_key_sequence_from_root(self.node_to_open)} {a_branch_str_sequence_from_root(self.node_to_open)}| "
36
+ f"a path from root to node_to_open is {a_branch_key_sequence_from_root(self.node_to_open)} {a_branch_str_sequence_from_root(self.node_to_open)}| "
37
37
  f"self.branch {self.branch} {self.node_to_open.state.branch_name_from_key(self.branch)}"
38
38
  )
39
39
 
@@ -76,7 +76,7 @@ class OpeningInstructions[NodeT: nodes.ITreeNode[Any] = nodes.ITreeNode[Any]]:
76
76
  key: The key for the opening instruction.
77
77
  value: The opening instruction.
78
78
  """
79
- # key is supposed to be a tuple with (node_to_open, move_to_play)
79
+ # key is supposed to be a tuple with (node_to_open, branch)
80
80
  self.batch[key] = value
81
81
 
82
82
  def __getitem__(self, key: OpeningInstructionKey) -> OpeningInstruction[NodeT]:
@@ -177,10 +177,10 @@ def create_instructions_to_open_all_branches[NodeT: nodes.ITreeNode[Any]](
177
177
  branches_to_play: list[BranchKey], node_to_open: NodeT
178
178
  ) -> OpeningInstructions[NodeT]:
179
179
  """
180
- Creates opening instructions for all possible moves to play from a given node.
180
+ Create opening instructions for all possible branches from a given node.
181
181
 
182
182
  Args:
183
- moves_to_play: A list of chess moves.
183
+ branches_to_play: The branch keys to open.
184
184
  node_to_open: The node to open.
185
185
 
186
186
  Returns:
@@ -195,7 +195,6 @@ def create_instructions_to_open_all_branches[NodeT: nodes.ITreeNode[Any]](
195
195
  opening_instructions_batch[(node_to_open.id, branch_to_play)] = (
196
196
  OpeningInstruction(node_to_open=node_to_open, branch=branch_to_play)
197
197
  )
198
- # node_to_open.non_opened_legal_moves.add(move_to_play)
199
198
  return opening_instructions_batch
200
199
 
201
200
 
@@ -233,7 +232,7 @@ class OpeningInstructor:
233
232
  node_to_open: The node to open.
234
233
 
235
234
  Returns:
236
- A list of chess moves.
235
+ A list of branch keys.
237
236
  """
238
237
  if self.opening_type == OpeningType.ALL_CHILDREN:
239
238
  node_to_open.all_branches_generated = True
@@ -242,7 +241,7 @@ class OpeningInstructor:
242
241
  # this shuffling add randomness to the playing style
243
242
  # (it stills depends on the random seed, but if random seed varies then the behavior will be more random)
244
243
  # DEACTIVATED ATM BECAUSE I DO NOT UNDERSTAND or FORGOT THE USE CASE: MAYBE DEAD SINCE SEED SYSTEM CHANGED
245
- # self.random_generator.shuffle(moves_to_play)
244
+ # self.random_generator.shuffle(branches_to_play)
246
245
 
247
246
  else:
248
247
  raise NotImplementedError("Hello-la")
@@ -1,7 +1,7 @@
1
1
  """
2
- This module contains the implementation of the RecurZipfBase class, which is a node selector for a move selector tree.
2
+ This module contains the implementation of the RecurZipfBase class, which is a node selector for a branch selector tree.
3
3
 
4
- The RecurZipfBase class is responsible for selecting the next node to explore in a move selector tree based on the RecurZipf algorithm.
4
+ The RecurZipfBase class is responsible for selecting the next node to explore in a branch selector tree based on the RecurZipf algorithm.
5
5
 
6
6
  Classes:
7
7
  - RecurZipfBase: The RecurZipfBase Node selector.
@@ -32,7 +32,7 @@ class RecurZipfBaseArgs:
32
32
  Arguments for the RecurZipfBase node selector.
33
33
 
34
34
  Attributes:
35
- move_explorer_priority (SamplingPriorities): The priority for move exploration.
35
+ branch_explorer_priority (SamplingPriorities): The priority for branch exploration.
36
36
  """
37
37
 
38
38
  type: Literal[NodeSelectorType.RECUR_ZIPF_BASE]
@@ -71,14 +71,14 @@ class RecurZipfBase[NodeT: AlgorithmNode[Any] = AlgorithmNode[Any]]:
71
71
  latest_tree_expansions: "tree_man.TreeExpansions[NodeT]",
72
72
  ) -> OpeningInstructions[NodeT]:
73
73
  """
74
- Chooses the next node to explore and the move to open.
74
+ Chooses the next node to explore and the branch to open.
75
75
 
76
76
  Args:
77
- - tree (trees.Tree[AlgorithmNode]): The move selector tree.
77
+ - tree (trees.Tree[AlgorithmNode]): The branch selector tree.
78
78
  - latest_tree_expansions (tree_man.TreeExpansions): The latest tree expansions.
79
79
 
80
80
  Returns:
81
- - OpeningInstructions: The instructions for opening the selected move.
81
+ - OpeningInstructions: The instructions for opening the selected branch.
82
82
 
83
83
  """
84
84
  # todo maybe proportions and proportions can be valuesorted dict with smart updates