algorhino-anemone 0.1.10__py3-none-any.whl → 0.1.11__py3-none-any.whl

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 (82) hide show
  1. {algorhino_anemone-0.1.10.dist-info → algorhino_anemone-0.1.11.dist-info}/METADATA +6 -6
  2. algorhino_anemone-0.1.11.dist-info/RECORD +82 -0
  3. anemone/__init__.py +1 -2
  4. anemone/basics.py +1 -18
  5. anemone/factory.py +13 -23
  6. anemone/indices/__init__.py +1 -0
  7. anemone/indices/index_manager/__init__.py +2 -3
  8. anemone/indices/index_manager/factory.py +13 -8
  9. anemone/indices/index_manager/node_exploration_manager.py +60 -55
  10. anemone/indices/node_indices/__init__.py +2 -3
  11. anemone/indices/node_indices/factory.py +16 -14
  12. anemone/indices/node_indices/index_data.py +20 -24
  13. anemone/indices/node_indices/index_types.py +5 -7
  14. anemone/nn/torch_evaluator.py +18 -11
  15. anemone/node_evaluation/__init__.py +1 -0
  16. anemone/node_evaluation/node_direct_evaluation/__init__.py +2 -3
  17. anemone/node_evaluation/node_direct_evaluation/factory.py +1 -1
  18. anemone/node_evaluation/node_direct_evaluation/node_direct_evaluator.py +19 -42
  19. anemone/node_evaluation/node_tree_evaluation/node_minmax_evaluation.py +113 -115
  20. anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation.py +11 -8
  21. anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation_factory.py +5 -5
  22. anemone/node_factory/__init__.py +2 -3
  23. anemone/node_factory/algorithm_node_factory.py +3 -8
  24. anemone/node_factory/base.py +5 -12
  25. anemone/node_selector/__init__.py +5 -6
  26. anemone/node_selector/branch_explorer.py +18 -21
  27. anemone/node_selector/factory.py +16 -16
  28. anemone/node_selector/node_selector.py +6 -12
  29. anemone/node_selector/node_selector_args.py +2 -5
  30. anemone/node_selector/node_selector_types.py +4 -8
  31. anemone/node_selector/notations_and_statics.py +4 -10
  32. anemone/node_selector/opening_instructions.py +37 -57
  33. anemone/node_selector/recurzipf/__init__.py +1 -0
  34. anemone/node_selector/recurzipf/recur_zipf_base.py +14 -42
  35. anemone/node_selector/sequool/__init__.py +2 -3
  36. anemone/node_selector/sequool/factory.py +3 -8
  37. anemone/node_selector/sequool/sequool.py +32 -50
  38. anemone/node_selector/uniform/__init__.py +1 -2
  39. anemone/node_selector/uniform/uniform.py +10 -18
  40. anemone/nodes/__init__.py +2 -3
  41. anemone/nodes/algorithm_node/__init__.py +1 -3
  42. anemone/nodes/algorithm_node/algorithm_node.py +35 -37
  43. anemone/nodes/itree_node.py +25 -31
  44. anemone/nodes/tree_node.py +30 -29
  45. anemone/nodes/tree_traversal.py +10 -11
  46. anemone/nodes/utils.py +14 -13
  47. anemone/progress_monitor/__init__.py +1 -0
  48. anemone/progress_monitor/progress_monitor.py +55 -75
  49. anemone/recommender_rule/__init__.py +1 -2
  50. anemone/recommender_rule/recommender_rule.py +7 -16
  51. anemone/search_factory/__init__.py +2 -3
  52. anemone/search_factory/search_factory.py +25 -28
  53. anemone/tree_and_value_branch_selector.py +25 -18
  54. anemone/tree_exploration.py +30 -41
  55. anemone/tree_manager/__init__.py +3 -4
  56. anemone/tree_manager/algorithm_node_tree_manager.py +15 -29
  57. anemone/tree_manager/factory.py +3 -5
  58. anemone/tree_manager/tree_expander.py +13 -15
  59. anemone/tree_manager/tree_manager.py +14 -25
  60. anemone/trees/__init__.py +3 -5
  61. anemone/trees/descendants.py +80 -115
  62. anemone/trees/factory.py +9 -13
  63. anemone/trees/tree.py +8 -11
  64. anemone/trees/tree_visualization.py +10 -10
  65. anemone/updates/__init__.py +4 -5
  66. anemone/updates/algorithm_node_updater.py +11 -13
  67. anemone/updates/factory.py +2 -4
  68. anemone/updates/index_block.py +13 -14
  69. anemone/updates/index_updater.py +7 -12
  70. anemone/updates/minmax_evaluation_updater.py +7 -12
  71. anemone/updates/updates_file.py +27 -26
  72. anemone/updates/value_block.py +10 -10
  73. anemone/utils/comparable.py +3 -4
  74. anemone/utils/dataclass.py +10 -13
  75. anemone/utils/dict_of_numbered_dict_with_pointer_on_max.py +16 -23
  76. anemone/utils/logger.py +13 -12
  77. anemone/utils/my_value_sorted_dict.py +4 -7
  78. anemone/utils/small_tools.py +16 -18
  79. algorhino_anemone-0.1.10.dist-info/RECORD +0 -82
  80. {algorhino_anemone-0.1.10.dist-info → algorhino_anemone-0.1.11.dist-info}/WHEEL +0 -0
  81. {algorhino_anemone-0.1.10.dist-info → algorhino_anemone-0.1.11.dist-info}/licenses/LICENSE +0 -0
  82. {algorhino_anemone-0.1.10.dist-info → algorhino_anemone-0.1.11.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: algorhino-anemone
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: anemone searches trees
5
5
  Author-email: Victor Gabillon <victorgabillon@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -12,18 +12,18 @@ 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>=0.1.13
16
- Requires-Dist: atomheart>=0.1.6
15
+ Requires-Dist: valanga>=0.1.14
16
+ Requires-Dist: atomheart>=0.1.7
17
17
  Requires-Dist: rich
18
18
  Requires-Dist: sortedcollections>=2.1.0
19
19
  Requires-Dist: graphviz
20
20
  Provides-Extra: test
21
- Requires-Dist: pytest>=8.4.1; extra == "test"
21
+ Requires-Dist: pytest>=9.0.2; extra == "test"
22
22
  Requires-Dist: coverage; extra == "test"
23
23
  Requires-Dist: pytest-cov>=6.0.0; extra == "test"
24
24
  Provides-Extra: lint
25
- Requires-Dist: ruff>=0.14.1; extra == "lint"
26
- Requires-Dist: pylint>=3.3.8; extra == "lint"
25
+ Requires-Dist: ruff>=0.15.0; extra == "lint"
26
+ Requires-Dist: pylint>=4.0.4; extra == "lint"
27
27
  Provides-Extra: typecheck
28
28
  Requires-Dist: mypy>=1.18.2; extra == "typecheck"
29
29
  Requires-Dist: pyright[nodejs]>=1.1.408; extra == "typecheck"
@@ -0,0 +1,82 @@
1
+ algorhino_anemone-0.1.11.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
2
+ anemone/__init__.py,sha256=15XN-GemLe35vDc4CBT9DE0IVap1g1jP2IVI8X_2Tqo,928
3
+ anemone/basics.py,sha256=wKagPFuxXhDQbjTuM1Qjh37HcJt0m39NBMDg2dc2M6M,188
4
+ anemone/factory.py,sha256=IHtTjR2S92sqeRY2KBNagui3oDPCOEj5IDR3yF5DL0I,6075
5
+ anemone/state_transition.py,sha256=fxvHZOYRtWV5ExXRIoehdRg9qV6zhgiE5uiCeOc80Dc,1418
6
+ anemone/tree_and_value_branch_selector.py,sha256=-Jehxi328Q-rUvU7gZorRVWRDijyBlwrRbaFBvaNiOY,3655
7
+ anemone/tree_exploration.py,sha256=a-uOaPp41K2vCjl9yYQHmVKjZH8Lrpmtbsohpl80Ik0,10242
8
+ anemone/indices/__init__.py,sha256=s1_3fzDPi-L7VQcee0GCpuhza2Exljee-LVuxPu3ht0,65
9
+ anemone/indices/index_manager/__init__.py,sha256=JWYMhOT-XX3cZ36OEy-veZvA8Dbjm_TCwBeyUgEFMr8,501
10
+ anemone/indices/index_manager/factory.py,sha256=15t-olh8mGSP739j0ZYm2uqfWCb9zz1wilkfdC1Dtvg,2014
11
+ anemone/indices/index_manager/node_exploration_manager.py,sha256=WG72bKkKsZbCZ2PKMG8RU0BLb4tvIOF0amEelcb_wTA,23273
12
+ anemone/indices/node_indices/__init__.py,sha256=UcrRQDEs8HybHVkFbUZl9beS3N8EcuGYq7YzOLOxKwk,760
13
+ anemone/indices/node_indices/factory.py,sha256=suPUsjjK3o_fBrjLhab9ELXM8eeXQd5_feWgERTNYaM,4345
14
+ anemone/indices/node_indices/index_data.py,sha256=TH30Rs-meexyFjdIOyGBjgCLTPc1nF4WtbDzlDi-RUs,5345
15
+ anemone/indices/node_indices/index_types.py,sha256=9qwZxv7OBgytwcWGZ-1G6RYDBvQD5rOFxMuBd6vfJAg,551
16
+ anemone/nn/torch_evaluator.py,sha256=lALUV8rm4c80wFxiWHI_-00BMenqAaivqz29GbqPXHY,3611
17
+ anemone/node_evaluation/__init__.py,sha256=FIeCBTB3QsNsIJ22inDJNf3vVsIBdFUuqJJ0L8Q8d9Y,58
18
+ anemone/node_evaluation/node_direct_evaluation/__init__.py,sha256=FB_WFfdy0oTsz1sRF2Rd7-sXoI5Iu1Rdyolj0HF0Uis,884
19
+ anemone/node_evaluation/node_direct_evaluation/factory.py,sha256=z-AywVoud87mL_NLXY3DjbfPhTPBMZmuVdLLGlrQTjE,457
20
+ anemone/node_evaluation/node_direct_evaluation/node_direct_evaluator.py,sha256=HjWVFJy4UDA6VB-6tCkS3iWcFEzYTFa_363GIdwdNzA,5367
21
+ anemone/node_evaluation/node_tree_evaluation/node_minmax_evaluation.py,sha256=aLQFTR_3uqpAF3QxLHdl9U4X4993_-BFOSAWVRoWzOY,34615
22
+ anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation.py,sha256=Ej8h5FNnarEHNbNA68wfu2abXWfRW2PLWDqMYaUN5mo,4282
23
+ anemone/node_evaluation/node_tree_evaluation/node_tree_evaluation_factory.py,sha256=3BEXa080hgb4bE4r-130_ANM4LGl4vzwPJbEhsbpzw0,1328
24
+ anemone/node_factory/__init__.py,sha256=4HMQ9MBID2odRrkR-t8BX89vTdmN2xybTL0mW5WnXUY,535
25
+ anemone/node_factory/algorithm_node_factory.py,sha256=XDaWaTY552uJ90ECC2lqyWreSc0cc04DLuvXIhd8dSI,4098
26
+ anemone/node_factory/base.py,sha256=jcj5Tagvgu6ZYllpvxxLhsApUROxEz3iMdaXbuasTfA,2106
27
+ anemone/node_selector/__init__.py,sha256=fi_BlhEuBh29CWhTpBuSPa9PLrfoPyiCVXGXIyEn8uo,1306
28
+ anemone/node_selector/branch_explorer.py,sha256=Oh0cOtys2s--nZsTDataR3IjZIN6SFs-Q0uu5eVrxxU,2556
29
+ anemone/node_selector/factory.py,sha256=WHSTqsaOf-P3LWo-b97fr_uBUxdkdzqzC25eR8Hi5Nw,2111
30
+ anemone/node_selector/node_selector.py,sha256=DJ1w6mRso-LKD8tRLESdlC4yYyf5T1-RcULfo2s4EBk,1096
31
+ anemone/node_selector/node_selector_args.py,sha256=m4fFMswcHaNQyHSiV0OaoF2gQUWe4_7V5dmO4_nTqQE,531
32
+ anemone/node_selector/node_selector_types.py,sha256=D7CSGcqWFQAyiQfTiunq2i6JxyiIbL_Y3Ru17ujP_CQ,305
33
+ anemone/node_selector/notations_and_statics.py,sha256=XuzHQJmqsuuZnR9pDq8uUO_kyeioqfbJKDyVodhadVY,2592
34
+ anemone/node_selector/opening_instructions.py,sha256=gtu1wO0s5FNu0vH9ZF7ItlZQujQLHy6ArJ1CyHGwTIg,7553
35
+ anemone/node_selector/recurzipf/__init__.py,sha256=nGrweb6xLrknVOO3DqQzSiGxSLso9uPcOR12PLEJRPk,56
36
+ anemone/node_selector/recurzipf/recur_zipf_base.py,sha256=8GNfiFdNZZrxNP7k2HlSyO_T2m1PhX953hVXoD9hiso,3795
37
+ anemone/node_selector/sequool/__init__.py,sha256=3A-yFgnQookFcDHPaSBaJsF97Ia0jsT_g9yY8OEm1Xw,471
38
+ anemone/node_selector/sequool/factory.py,sha256=wmNOf3uYJ0eerjFvx1jdyORtneCtzDuGW9oRHjD-KRo,3056
39
+ anemone/node_selector/sequool/sequool.py,sha256=z3FsoJYs1URpRMOFoZGDCaGRg9inHcj32ZcmFEjbL_E,11350
40
+ anemone/node_selector/uniform/__init__.py,sha256=Y28PZn5mvO7nm9aY9LRxPB-_UUmRnW-Yc8Yc97lBY7o,352
41
+ anemone/node_selector/uniform/uniform.py,sha256=Rdvt0tmWfK8FTxE4ql7xLT2vgIWPnq5iu_QPlzWa_XY,3630
42
+ anemone/nodes/__init__.py,sha256=QiMFfcRefUaP8OtRweuTqjSZ-43TPjIx-P790_v13RU,379
43
+ anemone/nodes/itree_node.py,sha256=akniqYyUdBk63h0zIBrrGHBJ_HDf3jfuA9_18AliQvw,3442
44
+ anemone/nodes/tree_node.py,sha256=O_C9dqWZ_8F-TGmXChtu5jnvmIFl213KyIKWqiGPIQw,7660
45
+ anemone/nodes/tree_traversal.py,sha256=pqtEKdG-NUwrHPu0OnvWTsoBxFDSxKlwBdFTum5jJS8,3926
46
+ anemone/nodes/utils.py,sha256=WHES9GaJuaF5gVP8knzG1iZGnOKEDKtDKwkv2KjItLo,4472
47
+ anemone/nodes/algorithm_node/__init__.py,sha256=AYJ2KAm9xXL42inS6lkypQPHt9sYtWdBPmK9ShgCYYE,115
48
+ anemone/nodes/algorithm_node/algorithm_node.py,sha256=HAqL9iL4Mo7J8N2cxX4ofsjdBRivWW_Ywi4lHB3Kq_A,6533
49
+ anemone/progress_monitor/__init__.py,sha256=zwsFet62FUlbonLTtDOye2VmLFEl8XWAJQJ6NdKu0pY,64
50
+ anemone/progress_monitor/progress_monitor.py,sha256=mFR24b4qtp8bV7ZWbCTb7U-6L4KQOcLKCgvMmfLeRWE,11105
51
+ anemone/recommender_rule/__init__.py,sha256=ia_KPE4CsDgt8qEtKMLHS3vOZcv6aaAqHAbchjBNHEM,333
52
+ anemone/recommender_rule/recommender_rule.py,sha256=pt3HUbH1V_pZC-sKo1Ged6vm_wvmVrea9s2YqipPv44,4374
53
+ anemone/search_factory/__init__.py,sha256=wjaaLMJUlQfn2y6a74AApX01RgmYo50xF63x7z0AWfY,605
54
+ anemone/search_factory/search_factory.py,sha256=jPdjQfhrwwT_EF3asACtAu_FLfCQ0NaX2ODGbuSHMzw,6512
55
+ anemone/tree_manager/__init__.py,sha256=1kRsT7_UQ_YI8NEvpZqV13RETEfgw9mrzjKZcl4w_hY,948
56
+ anemone/tree_manager/algorithm_node_tree_manager.py,sha256=GK6heOTHGNeGrVPq3EYaEOrMbN8FsTjmNay0BkpNJDM,8478
57
+ anemone/tree_manager/factory.py,sha256=76o9DoOpK_rin1caKsHPk7PkmNwvLChWvPYlHdJvb6o,2666
58
+ anemone/tree_manager/tree_expander.py,sha256=AzpwI4hVLNRpphirWX5fruSIiWL6bV-9yv-XPAzzdoY,4033
59
+ anemone/tree_manager/tree_manager.py,sha256=16zlg4OjiLMua0wGIPoFCD4RqVQkAthNE7GtxGnYkGg,7926
60
+ anemone/trees/__init__.py,sha256=3ujCsvrveUCBUWHtklD_jcUzVhYycBphZCaIcDJcXbE,268
61
+ anemone/trees/descendants.py,sha256=CNRjwuPW3UA-B9fDG3XRQigzgYgwUIrhzYxPtO4kGeQ,25889
62
+ anemone/trees/factory.py,sha256=ZXe22pLF0mq41eThFSVhOX6nOeBI2Cq9Y7bwPY9vAJM,2290
63
+ anemone/trees/tree.py,sha256=HqoPjB9HcIrWYV0iv8eoBn6d2OGIlJ6GfcjdxjgEhSQ,1964
64
+ anemone/trees/tree_visualization.py,sha256=IOBnwuykk4rKW0HyeyiohOs27mas7-P60_gnEGl9OBY,4634
65
+ anemone/updates/__init__.py,sha256=0PzroMHow_viONeaUeEH_Oc0KS-bwHp9PYvm4ekdido,1099
66
+ anemone/updates/algorithm_node_updater.py,sha256=96VcRxvMHRmuvZw8mdMz2QTcI4jnqGQmje_3I_mbSjE,5786
67
+ anemone/updates/factory.py,sha256=MoAtf2o9BuljpHr-HcE6Up5NdEfSed5IQO1hyMF7ssc,1187
68
+ anemone/updates/index_block.py,sha256=YvLQXsEHxe_sU2Am8LwxQSXbgjC598o7gCZ3MiId7KA,3003
69
+ anemone/updates/index_updater.py,sha256=KmE3RazrfWOH_rSQ1VbSbYDgUzwFaeTRSI6AfAkYdw4,3531
70
+ anemone/updates/minmax_evaluation_updater.py,sha256=dFqPhsXErk_R39Z2V6oGzE8oLiBsI2flq1dxU3XEIeI,3958
71
+ anemone/updates/updates_file.py,sha256=NGDf1l3At4ufeoQ_wpURIPEvx9oS1dndEqvWwydlAak,10011
72
+ anemone/updates/value_block.py,sha256=Z5J4BZzkUCMaqAfcA061bxO00iwGKMqH5UOYDNVG5zI,4598
73
+ anemone/utils/comparable.py,sha256=-A7uqdIHHfokivT-rWVOGueKBMGxetscUR2QkLzuop0,898
74
+ anemone/utils/dataclass.py,sha256=KtOViWQF33DfJkhIq0WX_TFNTfDjsMQZdEyX4pZrKw4,1758
75
+ anemone/utils/dict_of_numbered_dict_with_pointer_on_max.py,sha256=f-VcVP_UpzW8TayJydnXWHpw30UC04MLbjeEvEO-z9Y,3877
76
+ anemone/utils/logger.py,sha256=DqV0C8l9PxA6a72RG4HX0G_YaSjSlidwdnJLdyIvxGI,3009
77
+ anemone/utils/my_value_sorted_dict.py,sha256=DiL0Ds_TkE88jZB_NJ8fE98Ksaskf3qIyocc5TyoD3M,586
78
+ anemone/utils/small_tools.py,sha256=KtFzO9GYZch-pLdO83IFFXA-s3HpjU38lA832u3JTQU,2800
79
+ algorhino_anemone-0.1.11.dist-info/METADATA,sha256=DmG7BfcmgreqQ-5E5os6DztCaR_C5whOZIbFiLXG2F0,5693
80
+ algorhino_anemone-0.1.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
81
+ algorhino_anemone-0.1.11.dist-info/top_level.txt,sha256=G1vbB-vAevQVde3UZ5X1_Ysy1_6sJDEueHRi2qcDgrY,8
82
+ algorhino_anemone-0.1.11.dist-info/RECORD,,
anemone/__init__.py CHANGED
@@ -1,5 +1,4 @@
1
- """
2
- This module provides functionality for creating tree and value builders for the TreeAndValuePlayer.
1
+ """Provide functionality for creating tree and value builders for the TreeAndValuePlayer.
3
2
 
4
3
  The TreeAndValuePlayerArgs class represents the arguments for configuring the TreeAndValuePlayer.
5
4
  The create_tree_and_value_builders function is used to create the tree and value builders.
anemone/basics.py CHANGED
@@ -1,23 +1,6 @@
1
1
  """Basic types and protocols for Anemone."""
2
2
 
3
- from typing import Annotated, Protocol
4
-
5
- from valanga import Color, HasTurn, State
3
+ from typing import Annotated
6
4
 
7
5
  type Seed = Annotated[int, "seed"]
8
6
  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
- ...
anemone/factory.py CHANGED
@@ -1,11 +1,8 @@
1
- """
2
- Module for creating Tree and Value Branch Selector objects.
3
- """
1
+ """Module for creating Tree and Value Branch Selector objects."""
4
2
 
5
3
  from dataclasses import dataclass
6
- from queue import Queue
7
4
  from random import Random
8
- from typing import Literal, Type
5
+ from typing import Literal
9
6
 
10
7
  from valanga import RepresentationFactory, StateModifications, TurnState
11
8
  from valanga.evaluator_types import EvaluatorInput
@@ -26,7 +23,6 @@ from anemone.nodes.algorithm_node.algorithm_node import AlgorithmNode
26
23
  from anemone.progress_monitor.progress_monitor import (
27
24
  AllStoppingCriterionArgs,
28
25
  )
29
- from anemone.utils.dataclass import IsDataclass
30
26
 
31
27
  from . import node_selector as node_selector_m
32
28
  from . import recommender_rule
@@ -40,9 +36,7 @@ TREE_AND_VALUE_LITERAL_STRING: Literal["TreeAndValue"] = "TreeAndValue"
40
36
 
41
37
  @dataclass
42
38
  class TreeAndValuePlayerArgs:
43
- """
44
- Dataclass for Tree and Value Player Arguments.
45
- """
39
+ """Dataclass for Tree and Value Player Arguments."""
46
40
 
47
41
  node_selector: node_selector_m.AllNodeSelectorArgs
48
42
  opening_type: node_selector_m.OpeningType
@@ -53,7 +47,7 @@ class TreeAndValuePlayerArgs:
53
47
 
54
48
 
55
49
  def create_tree_and_value_branch_selector[StateT: TurnState](
56
- state_type: Type[StateT],
50
+ state_type: type[StateT],
57
51
  args: TreeAndValuePlayerArgs,
58
52
  random_generator: Random,
59
53
  master_state_evaluator: MasterStateEvaluator,
@@ -61,15 +55,13 @@ def create_tree_and_value_branch_selector[StateT: TurnState](
61
55
  StateT, EvaluatorInput, StateModifications
62
56
  ]
63
57
  | None,
64
- queue_progress_player: Queue[IsDataclass] | None,
65
58
  ) -> TreeAndValueBranchSelector[StateT]:
66
- """Convenience constructor using the default minmax tree evaluation.
59
+ """Create a branch selector using the default minmax tree evaluation.
67
60
 
68
61
  This keeps the existing API stable, while allowing advanced users to inject a
69
62
  different tree-evaluation strategy via
70
63
  `create_tree_and_value_branch_selector_with_tree_eval_factory`.
71
64
  """
72
-
73
65
  node_tree_evaluation_factory: NodeTreeEvaluationFactory[StateT]
74
66
  node_tree_evaluation_factory = NodeTreeMinmaxEvaluationFactory[StateT]()
75
67
 
@@ -80,12 +72,11 @@ def create_tree_and_value_branch_selector[StateT: TurnState](
80
72
  master_state_evaluator=master_state_evaluator,
81
73
  state_representation_factory=state_representation_factory,
82
74
  node_tree_evaluation_factory=node_tree_evaluation_factory,
83
- queue_progress_player=queue_progress_player,
84
75
  )
85
76
 
86
77
 
87
78
  def create_tree_and_value_branch_selector_with_tree_eval_factory[StateT: TurnState](
88
- state_type: Type[StateT],
79
+ state_type: type[StateT],
89
80
  args: TreeAndValuePlayerArgs,
90
81
  random_generator: Random,
91
82
  master_state_evaluator: MasterStateEvaluator,
@@ -94,21 +85,21 @@ def create_tree_and_value_branch_selector_with_tree_eval_factory[StateT: TurnSta
94
85
  ]
95
86
  | None,
96
87
  node_tree_evaluation_factory: NodeTreeEvaluationFactory[StateT],
97
- queue_progress_player: Queue[IsDataclass] | None,
98
88
  ) -> TreeAndValueBranchSelector[StateT]:
99
- """
100
- Create a TreeAndValueBranchSelector object with the given arguments.
89
+ """Create a TreeAndValueBranchSelector object with the given arguments.
101
90
 
102
91
  Args:
103
- args (TreeAndValuePlayerArgs): The arguments for creating the TreeAndValueBranchSelector.
104
- syzygy (SyzygyTable | None): The SyzygyTable object for tablebase endgame evaluation.
105
- random_generator (random.Random): The random number generator.
92
+ state_type (type[StateT]): The state type for the search.
93
+ args (TreeAndValuePlayerArgs): Arguments for creating the selector.
94
+ random_generator (Random): The random number generator.
95
+ master_state_evaluator (MasterStateEvaluator): Evaluator for state values.
96
+ state_representation_factory (RepresentationFactory | None): Optional state representation factory.
97
+ node_tree_evaluation_factory (NodeTreeEvaluationFactory[StateT]): Factory for node tree evaluations.
106
98
 
107
99
  Returns:
108
100
  TreeAndValueBranchSelector: The created TreeAndValueBranchSelector object.
109
101
 
110
102
  """
111
-
112
103
  _ = state_type # not used here
113
104
 
114
105
  node_evaluator: NodeDirectEvaluator[StateT] = create_node_evaluator(
@@ -155,7 +146,6 @@ def create_tree_and_value_branch_selector_with_tree_eval_factory[StateT: TurnSta
155
146
  node_selector_create=search_factory.create_node_selector_factory(),
156
147
  stopping_criterion_args=args.stopping_criterion,
157
148
  recommend_branch_after_exploration=args.recommender_rule,
158
- queue_progress_player=queue_progress_player,
159
149
  )
160
150
  )
161
151
  return tree_branch_selector
@@ -0,0 +1 @@
1
+ """Index utilities for node exploration and index management."""
@@ -1,5 +1,4 @@
1
- """
2
- This module provides functionality for managing exploration index managers.
1
+ """Provide functionality for managing exploration index managers.
3
2
 
4
3
  The module includes the following functions and classes:
5
4
  - create_exploration_index_manager: A function to create an exploration index manager.
@@ -9,4 +8,4 @@ The module includes the following functions and classes:
9
8
  from .factory import create_exploration_index_manager
10
9
  from .node_exploration_manager import NodeExplorationIndexManager
11
10
 
12
- __all__ = ["create_exploration_index_manager", "NodeExplorationIndexManager"]
11
+ __all__ = ["NodeExplorationIndexManager", "create_exploration_index_manager"]
@@ -1,6 +1,4 @@
1
- """
2
- This module contains the factory function to create a node exploration index manager based on the given index computation
3
- """
1
+ """Provide a factory for node exploration index managers."""
4
2
 
5
3
  from anemone.indices.index_manager.node_exploration_manager import (
6
4
  NodeExplorationIndexManager,
@@ -14,11 +12,20 @@ from anemone.indices.node_indices.index_types import (
14
12
  )
15
13
 
16
14
 
15
+ class UnknownIndexComputationError(ValueError):
16
+ """Raised when an index computation type is not recognized."""
17
+
18
+ def __init__(self, index_computation: IndexComputationType) -> None:
19
+ """Initialize the error with the unsupported computation type."""
20
+ super().__init__(
21
+ f"player creator: can not find {index_computation} in {__name__}"
22
+ )
23
+
24
+
17
25
  def create_exploration_index_manager(
18
26
  index_computation: IndexComputationType | None = None,
19
27
  ) -> NodeExplorationIndexManager:
20
- """
21
- Creates a node exploration index manager based on the given index computation type.
28
+ """Create a node exploration index manager for the given index computation type.
22
29
 
23
30
  Args:
24
31
  index_computation (IndexComputationType | None): The type of index computation to be used.
@@ -43,8 +50,6 @@ def create_exploration_index_manager(
43
50
  case IndexComputationType.MIN_LOCAL_CHANGE:
44
51
  node_exploration_manager = UpdateIndexLocalMinChange()
45
52
  case _:
46
- raise ValueError(
47
- f"player creator: can not find {index_computation} in {__name__}"
48
- )
53
+ raise UnknownIndexComputationError(index_computation)
49
54
 
50
55
  return node_exploration_manager
@@ -31,13 +31,13 @@ class _StateWithTurn(State, Protocol):
31
31
 
32
32
 
33
33
  class NodeExplorationIndexManager(Protocol):
34
- """
35
- A protocol for managing the exploration indices of nodes in a tree.
34
+ """A protocol for managing the exploration indices of nodes in a tree.
36
35
 
37
36
  This protocol defines methods for updating the exploration indices of nodes in a tree.
38
37
 
39
38
  Args:
40
39
  Protocol (type): The base protocol type.
40
+
41
41
  """
42
42
 
43
43
  needs_parent_state: bool
@@ -47,11 +47,12 @@ class NodeExplorationIndexManager(Protocol):
47
47
  root_node: NodeT,
48
48
  root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
49
49
  ) -> None:
50
- """
51
- Updates the exploration index of the root node in the tree.
50
+ """Update the exploration index of the root node in the tree.
52
51
 
53
52
  Args:
54
53
  root_node (AlgorithmNode): The root node of the tree.
54
+ root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
55
+
55
56
  """
56
57
  ...
57
58
 
@@ -65,21 +66,23 @@ class NodeExplorationIndexManager(Protocol):
65
66
  tree: Tree[NodeT],
66
67
  child_rank: int,
67
68
  ) -> None:
68
- """
69
- Updates the exploration index of a child node in the tree.
69
+ """Update the exploration index of a child node in the tree.
70
70
 
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
+ parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
75
+ child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
76
+ parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
74
77
  tree (Tree): The tree containing the nodes.
75
78
  child_rank (int): The rank of the child node among its siblings.
79
+
76
80
  """
77
81
  ...
78
82
 
79
83
 
80
84
  class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
81
- """
82
- A class representing a null node exploration index manager.
85
+ """A class representing a null node exploration index manager.
83
86
 
84
87
  This class is used when there is no need to update the exploration index of nodes in a tree.
85
88
  It inherits from the NodeExplorationIndexManager class.
@@ -92,13 +95,13 @@ class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
92
95
  root_node: NodeT,
93
96
  root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
94
97
  ) -> None:
95
- """
96
- Updates the exploration index of the root node in the tree.
98
+ """Update the exploration index of the root node in the tree.
97
99
 
98
100
  Args:
99
101
  root_node (AlgorithmNode): The root node of the tree.
102
+ root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
103
+
100
104
  """
101
- ...
102
105
 
103
106
  def update_node_indices[NodeT: AlgorithmNode[Any]](
104
107
  self,
@@ -110,22 +113,23 @@ class NullNodeExplorationIndexManager(NodeExplorationIndexManager):
110
113
  tree: Tree[NodeT],
111
114
  child_rank: int,
112
115
  ) -> None:
113
- """
114
- Updates the exploration index of a child node in the tree.
116
+ """Update the exploration index of a child node in the tree.
115
117
 
116
118
  Args:
117
119
  child_node (AlgorithmNode): The child node to update.
118
120
  parent_node (AlgorithmNode): The parent node of the child node.
121
+ parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
122
+ child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
123
+ parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
119
124
  tree (Tree): The tree containing the nodes.
120
125
  child_rank (int): The rank of the child node among its siblings.
126
+
121
127
  """
122
128
  raise NotImplementedError("should not be raised")
123
129
 
124
130
 
125
131
  class UpdateIndexGlobalMinChange:
126
- """
127
- A class that updates the exploration index of nodes in a tree using the global minimum change strategy.
128
- """
132
+ """A class that updates the exploration index of nodes in a tree using the global minimum change strategy."""
129
133
 
130
134
  needs_parent_state = False
131
135
 
@@ -134,11 +138,12 @@ class UpdateIndexGlobalMinChange:
134
138
  root_node: NodeT,
135
139
  root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
136
140
  ) -> None:
137
- """
138
- Updates the exploration index of the root node in the tree using the global minimum change strategy.
141
+ """Update the exploration index of the root node using the global minimum change strategy.
139
142
 
140
143
  Args:
141
144
  root_node (AlgorithmNode): The root node of the tree.
145
+ root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
146
+
142
147
  """
143
148
  root_value: float = root_node.tree_evaluation.get_value_white()
144
149
 
@@ -158,16 +163,18 @@ class UpdateIndexGlobalMinChange:
158
163
  tree: Tree[NodeT],
159
164
  child_rank: int,
160
165
  ) -> None:
161
- """
162
- Updates the exploration index of a child node in the tree using the global minimum change strategy.
166
+ """Update the exploration index of a child node using the global minimum change strategy.
163
167
 
164
168
  Args:
165
169
  child_node (AlgorithmNode): The child node to update.
166
170
  parent_node (AlgorithmNode): The parent node of the child node.
171
+ parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
172
+ child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
173
+ parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
167
174
  tree (Tree): The tree containing the nodes.
168
175
  child_rank (int): The rank of the child node among its siblings.
169
- """
170
176
 
177
+ """
171
178
  _ = child_rank
172
179
  _ = parent_node
173
180
  _ = tree
@@ -193,10 +200,6 @@ class UpdateIndexGlobalMinChange:
193
200
  abs(child_node_max_path_value - child_node_min_path_value) / 2
194
201
  )
195
202
 
196
- # the amount of change for the child to become better than any of its ancestor
197
- # and become the overall best bode, the max is computed with the parent index
198
- # child_index: float = max(local_child_index, parent_index)
199
-
200
203
  # the index of the child node is updated now
201
204
  # as a child node can have multiple parents we take the min if an index was previously computed
202
205
  if child_node_exploration_index_data.index is None:
@@ -220,9 +223,7 @@ class UpdateIndexGlobalMinChange:
220
223
 
221
224
 
222
225
  class UpdateIndexZipfFactoredProba:
223
- """
224
- A class that updates the exploration index of nodes in a tree using the Zipf factored probability strategy.
225
- """
226
+ """A class that updates the exploration index of nodes in a tree using the Zipf factored probability strategy."""
226
227
 
227
228
  needs_parent_state = False
228
229
 
@@ -231,13 +232,13 @@ class UpdateIndexZipfFactoredProba:
231
232
  root_node: NodeT,
232
233
  root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
233
234
  ) -> None:
234
- """
235
- Updates the exploration index of the root node in the tree using the Zipf factored probability strategy.
235
+ """Update the exploration index of the root node using the Zipf factored probability strategy.
236
236
 
237
237
  Args:
238
238
  root_node (AlgorithmNode): The root node of the tree.
239
- """
239
+ root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
240
240
 
241
+ """
241
242
  _ = root_node
242
243
  assert isinstance(
243
244
  root_node_exploration_index_data, RecurZipfQuoolExplorationData
@@ -255,14 +256,17 @@ class UpdateIndexZipfFactoredProba:
255
256
  tree: Tree[NodeT],
256
257
  child_rank: int,
257
258
  ) -> None:
258
- """
259
- Updates the exploration index of a child node in the tree using the Zipf factored probability strategy.
259
+ """Update the exploration index of a child node using the Zipf factored probability strategy.
260
260
 
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
+ parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
265
+ child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
266
+ parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
264
267
  tree (Tree): The tree containing the nodes.
265
268
  child_rank (int): The rank of the child node among its siblings.
269
+
266
270
  """
267
271
  _ = parent_node
268
272
 
@@ -306,9 +310,7 @@ class UpdateIndexZipfFactoredProba:
306
310
 
307
311
 
308
312
  class UpdateIndexLocalMinChange:
309
- """
310
- A class that updates the exploration index of nodes in a tree using the local minimum change strategy.
311
- """
313
+ """A class that updates the exploration index of nodes in a tree using the local minimum change strategy."""
312
314
 
313
315
  needs_parent_state = True
314
316
 
@@ -317,11 +319,12 @@ class UpdateIndexLocalMinChange:
317
319
  root_node: NodeT,
318
320
  root_node_exploration_index_data: NodeExplorationData[NodeT, Any] | None,
319
321
  ) -> None:
320
- """
321
- Updates the exploration index of the root node in the tree using the local minimum change strategy.
322
+ """Update the exploration index of the root node using the local minimum change strategy.
322
323
 
323
324
  Args:
324
325
  root_node (AlgorithmNode): The root node of the tree.
326
+ root_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the root node.
327
+
325
328
  """
326
329
  _ = root_node
327
330
  assert isinstance(root_node_exploration_index_data, IntervalExplo)
@@ -341,16 +344,18 @@ class UpdateIndexLocalMinChange:
341
344
  tree: Tree[NodeT],
342
345
  child_rank: int,
343
346
  ) -> None:
344
- """
345
- Updates the exploration index of a child node in the tree using the local minimum change strategy.
347
+ """Update the exploration index of a child node using the local minimum change strategy.
346
348
 
347
349
  Args:
348
350
  child_node (AlgorithmNode): The child node to update.
349
351
  parent_node (AlgorithmNode): The parent node of the child node.
352
+ parent_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the parent.
353
+ child_node_exploration_index_data (NodeExplorationData | None): Exploration index data for the child.
354
+ parent_node_state (_StateWithTurn | None): Parent node state with turn information, if needed.
350
355
  tree (Tree): The tree containing the nodes.
351
356
  child_rank (int): The rank of the child node among its siblings.
352
- """
353
357
 
358
+ """
354
359
  _ = tree
355
360
  _ = child_rank
356
361
 
@@ -405,7 +410,6 @@ class UpdateIndexLocalMinChange:
405
410
  value=child_white_value, interval=inter_level_interval
406
411
  )
407
412
  else:
408
- ...
409
413
  local_index = None
410
414
  if parent_node_state.turn == Color.BLACK:
411
415
  best_branch_black: BranchKey | None = (
@@ -459,22 +463,23 @@ class UpdateIndexLocalMinChange:
459
463
  )
460
464
 
461
465
 
462
- # TODO their might be ways to optimize the computation such as not recomptuing for the whole tree
466
+ # TODO: their might be ways to optimize the computation such as not recomptuing for the whole tree
463
467
  def update_all_indices[NodeT: AlgorithmNode[Any]](
464
468
  tree: Tree[NodeT], index_manager: NodeExplorationIndexManager
465
469
  ) -> None:
466
- """
467
- The idea is to compute an index $ind(n)$ for a node $n$ that measures the minimum amount of change
468
- in the value of all the nodes such that this node $n$ becomes the best.
470
+ """Compute exploration indices for nodes in the tree.
469
471
 
470
- This can be computed recursively as :
471
- ind(n) = max( ind(parent(n),.5*abs(value(n)-value(parent(n))))
472
+ This computes an index $ind(n)$ for a node $n$ that measures the minimum amount
473
+ of change in the value of all the nodes such that this node $n$ becomes the best.
474
+ It can be computed recursively as:
475
+ ind(n) = max(ind(parent(n), 0.5 * abs(value(n) - value(parent(n)))))
472
476
 
473
477
  Args:
474
- index_manager:
475
- tree: a tree
478
+ tree: The tree to update.
479
+ index_manager: The index manager that defines the update logic.
476
480
 
477
481
  Returns:
482
+ None
478
483
 
479
484
  """
480
485
  if isinstance(index_manager, NullNodeExplorationIndexManager):
@@ -489,7 +494,7 @@ def update_all_indices[NodeT: AlgorithmNode[Any]](
489
494
 
490
495
  tree_depth: TreeDepth
491
496
  for tree_depth in tree_nodes:
492
- # todo how are we sure that the hm comes in order?
497
+ # TODO: how are we sure that the hm comes in order?
493
498
  parent_node: NodeT
494
499
  for parent_node in tree_nodes[tree_depth].values():
495
500
  branch_rank: int
@@ -518,26 +523,26 @@ def update_all_indices[NodeT: AlgorithmNode[Any]](
518
523
  )
519
524
 
520
525
 
521
- # TODO their might be ways to optimize the computation such as not recomptuing for the whole tree
526
+ # TODO: their might be ways to optimize the computation such as not recomptuing for the whole tree
522
527
 
523
528
 
524
529
  def print_all_indices[NodeT: AlgorithmNode[Any]](
525
530
  tree: Tree[NodeT],
526
531
  ) -> None:
527
- """
528
- Prints the exploration indices of all nodes in the given tree.
532
+ """Print the exploration indices of all nodes in the given tree.
529
533
 
530
534
  Args:
531
535
  tree (Tree): The tree containing the nodes.
532
536
 
533
537
  Returns:
534
538
  None
539
+
535
540
  """
536
541
  tree_nodes: RangedDescendants[NodeT] = tree.descendants
537
542
 
538
543
  tree_depth: TreeDepth
539
544
  for tree_depth in tree_nodes:
540
- # todo how are we sure that the hm comes in order?
545
+ # TODO: how are we sure that the hm comes in order?
541
546
  for parent_node in tree_nodes[tree_depth].values():
542
547
  assert isinstance(parent_node, AlgorithmNode)
543
548
  if parent_node.exploration_index_data is not None:
@@ -1,5 +1,4 @@
1
- """
2
- This module provides functionality for managing node indices in the tree value package.
1
+ """Provide functionality for managing node indices in the tree value package.
3
2
 
4
3
  The following classes and functions are available:
5
4
 
@@ -15,8 +14,8 @@ from .index_data import NodeExplorationData
15
14
  from .index_types import IndexComputationType
16
15
 
17
16
  __all__ = [
18
- "NodeExplorationData",
19
17
  "ExplorationIndexDataFactory",
20
18
  "IndexComputationType",
19
+ "NodeExplorationData",
21
20
  "create_exploration_index_data",
22
21
  ]