graph-games-proto 0.3.1864__py3-none-any.whl → 0.3.1865__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.
graph_games_proto/fns.py CHANGED
@@ -3024,9 +3024,12 @@ def run_state_hooks(state, hooks, log=False):
3024
3024
  def run_accept_action_hooks(state, action, hooks, log=False):
3025
3025
  # Just like "run_state_action_hooks", but returns immediately returns True if any hook returns True, otherwise returns False
3026
3026
  for hook in hooks:
3027
- if run_state_action_hook(state, action, hook, log):
3028
- return True
3029
- return False
3027
+ is_accepted, reason = run_state_action_hook(state, action, hook, log)
3028
+ if is_accepted is not None and is_accepted:
3029
+ return True, reason
3030
+ elif is_accepted is not None and not is_accepted:
3031
+ return False, reason
3032
+ return False, "No hook accepted the action"
3030
3033
 
3031
3034
 
3032
3035
  def run_state_action_hooks(state, action, hooks, log=False):
@@ -3887,19 +3890,19 @@ def append_to_legal_actions(game, legal_action):
3887
3890
 
3888
3891
 
3889
3892
  def default_accept_action(game, action):
3890
- if not game or not action or not action.legal_action:
3891
- return False
3892
3893
 
3893
3894
  # Returns true if action.legal_action is found in game.legal_actions_2
3894
3895
  # The comparision is by value, not by reference
3895
3896
  if action.legal_action not in game.legal_actions_2:
3896
- return False
3897
+ return False, "Action not found in legal actions"
3897
3898
 
3898
3899
  # Check if "action.move_pieces_to_path" is not None
3899
3900
  if action.move_pieces_to_path:
3900
- return is_move_pieces_to_path_action_legal(game, action)
3901
+ is_legal = is_move_pieces_to_path_action_legal(game, action)
3902
+ if not is_legal:
3903
+ return False, "Move pieces to path action is not legal"
3901
3904
 
3902
- return True
3905
+ return True, "Action is legal"
3903
3906
 
3904
3907
 
3905
3908
  def is_move_pieces_to_path_action_legal(game, action):
@@ -4413,8 +4416,9 @@ def isactionlegal2(s, a):
4413
4416
 
4414
4417
 
4415
4418
  def getnextstate2(s, a, log=False):
4416
- if not isactionlegal2(s, a):
4417
- raise ValueError(f"Action is not legal: {a}")
4419
+ is_legal, reason = isactionlegal2(s, a)
4420
+ if not is_legal:
4421
+ raise ValueError(f"Action is not legal: {a}. Reason: {reason}")
4418
4422
  s = run_state_action_hooks(s, a, AFTER_ACCEPT_ACTION_HOOKS, log)
4419
4423
  s = run_state_action_hooks(s, a, HANDLE_ACTION_HOOKS, log)
4420
4424
  s = run_state_hooks(s, HANDLE_SCORING_HOOKS, log)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1864
3
+ Version: 0.3.1865
4
4
  Requires-Dist: multipledispatch==1.0.0
5
5
  Requires-Dist: pyrsistent==0.20.0
6
6
  Requires-Dist: numpy==2.2.4
@@ -1,9 +1,9 @@
1
1
  graph_games_proto/__init__.py,sha256=O5XjRfe3DlxbJn4zezDvvy7cXvL4IzIRPZCL3Y-n7s8,776
2
2
  graph_games_proto/all_types.py,sha256=IpbwftEcHS5Ewz-saFNk0lO9FvcbuHG36odRTayCXUk,54911
3
- graph_games_proto/fns.py,sha256=PosUF9Gr77oZzIaEpfhJteapz6te67HhrbwXWhxgo20,242399
3
+ graph_games_proto/fns.py,sha256=PJUsPdN8ztl9yFVr3c2RC2M0A5gEK9IvdN1RHEauD4A,242723
4
4
  graph_games_proto/main.py,sha256=fj2U7KcwrpZtuUhjOX5yVxY18LZvvsxDFYZ_S5mxe04,145
5
5
  graph_games_proto/state.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- graph_games_proto-0.3.1864.dist-info/METADATA,sha256=2-OMsPvMLX071_QjZDvVDm8yKWj7NlSwB_Agv14gPtY,188
7
- graph_games_proto-0.3.1864.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1864.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1864.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1865.dist-info/METADATA,sha256=WeOSB_09jBe0pkxkIF2IjrMxECzJnvismkPqD8n7obw,188
7
+ graph_games_proto-0.3.1865.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1865.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1865.dist-info/RECORD,,