graph-games-proto 0.3.1914__py3-none-any.whl → 0.3.1915__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
@@ -1103,7 +1103,6 @@ class PrivateState(PClass):
1103
1103
  my_history = field(type=list) # List[Action2]
1104
1104
  player_score = field(type=PrivatePlayerScore)
1105
1105
  player = field(type=Player)
1106
- legal_actions_2 = field(type=list) # List[LegalAction]
1107
1106
  legal_actions_3 = field(type=list) # List[LegalAction]
1108
1107
  goal_completions = field(type=list, initial=[]) # List[GoalCompletion]
1109
1108
  def __todict__(self):
@@ -1111,7 +1110,6 @@ class PrivateState(PClass):
1111
1110
  "my_history": [x.__todict__() for x in self.my_history],
1112
1111
  "player_score": self.player_score.__todict__(),
1113
1112
  "player": self.player.__todict__(),
1114
- "legal_actions_2": [x.__todict__() for x in self.legal_actions_2],
1115
1113
  "legal_actions_3": [x.__todict__() for x in self.legal_actions_3],
1116
1114
  "goal_completions": [x.__todict__() for x in self.goal_completions],
1117
1115
  }
@@ -1121,7 +1119,6 @@ class PrivateState(PClass):
1121
1119
  my_history=[Action2.__fromdict__(x) for x in d["my_history"]],
1122
1120
  player_score=PrivatePlayerScore.__fromdict__(d["player_score"]),
1123
1121
  player=Player.__fromdict__(d["player"]),
1124
- legal_actions_2=[LegalAction.__fromdict__(x) for x in d["legal_actions_2"]],
1125
1122
  legal_actions_3=[LegalAction.__fromdict__(x) for x in d["legal_actions_3"]],
1126
1123
  goal_completions=[GoalCompletion.__fromdict__(x) for x in d["goal_completions"]],
1127
1124
  )
@@ -1956,7 +1953,6 @@ class State(PClass):
1956
1953
  edgeuuid2idx = field(type=dict) # Dict[str, int]
1957
1954
  edgetuple2uuid = field(type=dict) # Dict[Tuple[int, int], str]
1958
1955
  regions = field(type=list) # List[Region]
1959
- legal_actions_2 = field(type=list) # List[LegalAction]
1960
1956
  legal_actions_3 = field(type=list) # List[LegalAction]
1961
1957
  piles = field(type=list) # List[Pile]
1962
1958
  players = field(type=list) # List[Player]
@@ -1988,7 +1984,6 @@ class State(PClass):
1988
1984
  "edgeuuid2idx": self.edgeuuid2idx,
1989
1985
  "edgetuple2uuid": [{"k": list(k), "v": v} for k, v in self.edgetuple2uuid.items()],
1990
1986
  "regions": [region.__todict__() for region in self.regions],
1991
- "legal_actions_2": [x.__todict__() for x in self.legal_actions_2],
1992
1987
  "legal_actions_3": [x.__todict__() for x in self.legal_actions_3],
1993
1988
  "piles": [pile.__todict__() for pile in self.piles],
1994
1989
  "players": [player.__todict__() for player in self.players],
@@ -2022,7 +2017,6 @@ class State(PClass):
2022
2017
  edgeuuid2idx=d["edgeuuid2idx"],
2023
2018
  edgetuple2uuid={tuple(item["k"]): item["v"] for item in d["edgetuple2uuid"]},
2024
2019
  regions=[Region.__fromdict__(r) for r in d["regions"]],
2025
- legal_actions_2=[LegalAction.__fromdict__(x) for x in d["legal_actions_2"]],
2026
2020
  legal_actions_3=[LegalAction.__fromdict__(x) for x in d["legal_actions_3"]],
2027
2021
  piles=[Pile.__fromdict__(p) for p in d["piles"]],
2028
2022
  players=[Player.__fromdict__(p) for p in d["players"]],
@@ -2599,7 +2593,6 @@ def getinitialstate(game_config):
2599
2593
  edgeuuid2idx = edgeuuid2idx,
2600
2594
  edgetuple2uuid = edgetuple2uuid,
2601
2595
  regions = get_regions(board_config),
2602
- legal_actions_2=[],
2603
2596
  legal_actions_3=[],
2604
2597
  piles=piles,
2605
2598
  players=[Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(game_config.num_players)],
@@ -2724,7 +2717,7 @@ def handle_last_to_play(game):
2724
2717
  if len(player.pieces) < 3:
2725
2718
  return game.set(last_to_play=player.idx)
2726
2719
  elif game.last_to_play == game.history[-1].legal_action.player_idx:
2727
- if not game.legal_actions_2:
2720
+ if not game.legal_actions_3:
2728
2721
  return game.set(terminal=True)
2729
2722
  return game
2730
2723
 
@@ -2848,11 +2841,11 @@ def default_after_accept_action(game, action):
2848
2841
  if player_idx < 0 or player_idx >= len(game.players):
2849
2842
  return game
2850
2843
  new_legal_actions = [
2851
- la for la in game.legal_actions_2 if la.player_idx != player_idx
2844
+ la for la in game.legal_actions_3 if la.player_idx != player_idx
2852
2845
  ]
2853
2846
  history = game.history + [action]
2854
2847
  return game.set(
2855
- legal_actions_2=new_legal_actions,
2848
+ legal_actions_3=new_legal_actions,
2856
2849
  history=history,
2857
2850
  )
2858
2851
 
@@ -3543,19 +3536,19 @@ def append_all_to_legal_actions(game, legal_actions):
3543
3536
  def append_to_legal_actions(game, legal_action):
3544
3537
  if not game:
3545
3538
  return game
3546
-
3547
- game.legal_actions_2.append(
3539
+
3540
+ game.legal_actions_3.append(
3548
3541
  legal_action
3549
3542
  )
3550
3543
 
3551
- return game.set(legal_actions_2=game.legal_actions_2)
3544
+ return game.set(legal_actions_3=game.legal_actions_3)
3552
3545
 
3553
3546
 
3554
3547
  def default_accept_action(game, action):
3555
3548
 
3556
- # Returns true if action.legal_action is found in game.legal_actions_2
3549
+ # Returns true if action.legal_action is found in game.legal_actions_3
3557
3550
  # The comparision is by value, not by reference
3558
- if action.legal_action not in game.legal_actions_2:
3551
+ if action.legal_action not in game.legal_actions_3:
3559
3552
  return False, "Action not found in legal actions"
3560
3553
 
3561
3554
  # Check if "action.move_pieces_to_path" is not None
@@ -4219,8 +4212,6 @@ def getnextstate2(s, a, log=False):
4219
4212
  s = run_state_action_hooks(s, a, HANDLE_ACTION_HOOKS, log)
4220
4213
  s = run_state_hooks(s, HANDLE_SCORING_HOOKS, log)
4221
4214
  s = run_state_hooks(s, HANDLE_TERMINAL_HOOKS, log)
4222
- if not s.legal_actions_2:
4223
- s = run_state_action_hooks(s, a, EMPTY_LEGAL_ACTIONS_HOOKS, log)
4224
4215
 
4225
4216
  state_kernal = init_state_kernal(
4226
4217
  game_config=s.game_config,
@@ -4261,7 +4252,7 @@ def getprivateplayerscore(s, player_score):
4261
4252
 
4262
4253
 
4263
4254
  def getpublictoplay(s):
4264
- player_idxs = [legal_action.player_idx for legal_action in s.legal_actions_2]
4255
+ player_idxs = [legal_action.player_idx for legal_action in s.legal_actions_3]
4265
4256
  # filter out duplicates
4266
4257
  return list(set(player_idxs))
4267
4258
 
@@ -4276,7 +4267,7 @@ def get_max_allotted_times(s):
4276
4267
  def get_player_max_allotted_time(s, player_idx):
4277
4268
  max_allotted_seconds = 0
4278
4269
  since_action_idx_of_max = -1
4279
- for legal_action in s.legal_actions_2:
4270
+ for legal_action in s.legal_actions_3:
4280
4271
  if legal_action.player_idx == player_idx:
4281
4272
  if legal_action.allotted_seconds > max_allotted_seconds:
4282
4273
  max_allotted_seconds = legal_action.allotted_seconds
@@ -4350,7 +4341,6 @@ def get_public_player_scores(s):
4350
4341
 
4351
4342
  # player_score = field(type=PrivatePlayerScore)
4352
4343
  # player = field(type=Player)
4353
- # legal_actions_2 = field(type=list) # List[LegalAction]
4354
4344
  # goal_completions = field(type=list, initial=[]) # List[GoalCompletion]
4355
4345
 
4356
4346
 
@@ -4402,7 +4392,6 @@ def imagine_state(public_state, private_state):
4402
4392
  piles = public_state.piles,
4403
4393
  player_idxs = public_state.player_idxs,
4404
4394
  game_config = public_state.game_config,
4405
- legal_actions_2 = imagine_legal_actions(public_state, private_state),
4406
4395
  players = imagine_players(public_state, private_state),
4407
4396
  decks = imagine_decks(public_state, private_state),
4408
4397
  rng = imagine_rng(public_state, private_state),
@@ -4412,7 +4401,7 @@ def imagine_state(public_state, private_state):
4412
4401
 
4413
4402
 
4414
4403
  def isterminal(s):
4415
- return len(s.legal_actions_2) == 0
4404
+ return len(s.legal_actions_3) == 0
4416
4405
 
4417
4406
 
4418
4407
  @dispatch(State)
@@ -4603,7 +4592,7 @@ def get_legal_actions3(s, player_idx):
4603
4592
 
4604
4593
  @dispatch(State, int)
4605
4594
  def get_legal_actions(s, player_idx):
4606
- return [a for a in s.legal_actions_2 if a.player_idx == player_idx]
4595
+ return [a for a in s.legal_actions_3 if a.player_idx == player_idx]
4607
4596
 
4608
4597
 
4609
4598
  def get_goal_completions(s, player_idx):
@@ -5094,7 +5083,6 @@ def getprivatestate(s, player_idx):
5094
5083
  my_history=[a for a in s.history if a.legal_action.player_idx == player_idx],
5095
5084
  player_score=getprivateplayerscore(s, s.player_scores[player_idx]),
5096
5085
  player=s.players[player_idx],
5097
- legal_actions_2 = get_legal_actions(s, player_idx),
5098
5086
  legal_actions_3 = get_legal_actions3(s, player_idx),
5099
5087
  goal_completions=get_goal_completions(s, player_idx),
5100
5088
  )
@@ -5246,15 +5234,15 @@ def diff(A, dims=None):
5246
5234
 
5247
5235
 
5248
5236
  def get_default_toplay(s):
5249
- if s.legal_actions_2:
5250
- return s.legal_actions_2[0].player_idx
5237
+ if s.legal_actions_3:
5238
+ return s.legal_actions_3[0].player_idx
5251
5239
  return None
5252
5240
 
5253
5241
 
5254
5242
  def get_intuited_best_actions(ps):
5255
- if not ps.legal_actions_2:
5243
+ if not ps.legal_actions_3:
5256
5244
  return None
5257
- return ps.legal_actions_2[:8]
5245
+ return ps.legal_actions_3[:8]
5258
5246
 
5259
5247
 
5260
5248
  def get_spread(q_values, p_idx):
@@ -5282,7 +5270,7 @@ def dynamics(s, a):
5282
5270
 
5283
5271
  def alpha0(ps):
5284
5272
  td = 3
5285
- legal_actions = ps.legal_actions_2
5273
+ legal_actions = ps.legal_actions_3
5286
5274
  if not legal_actions:
5287
5275
  return None
5288
5276
  intuited = get_intuited_best_actions(ps)
@@ -5533,24 +5521,6 @@ ACCEPT_ACTION_HOOKS = [
5533
5521
  )
5534
5522
  ]
5535
5523
 
5536
- EMPTY_LEGAL_ACTIONS_HOOK_1 = """
5537
- def handler(game, action):
5538
- if action.legal_action.name == "INITIAL-GOAL-KEEP":
5539
- return append_default_legal_actions_for_initial_player(game, action)
5540
- else:
5541
- return append_default_legal_actions_for_next_player(game, action)
5542
- return game
5543
- """
5544
-
5545
- EMPTY_LEGAL_ACTIONS_HOOKS = [
5546
- Hook(
5547
- name="EmptyLegalActionsHook",
5548
- uuid="f45dabf6-8f46-4af2-9b88-327db8b985eb",
5549
- when="EMPTY_LEGAL_ACTIONS",
5550
- code=EMPTY_LEGAL_ACTIONS_HOOK_1,
5551
- )
5552
- ]
5553
-
5554
5524
  HANDLE_SCORING_HOOK_1 = """
5555
5525
  def handler(game):
5556
5526
  return default_handle_scoring(game)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1914
3
+ Version: 0.3.1915
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=_EVQR-51XehfH45XZlba1WPdx3omS3Gm1nTwrgGyn2Q,667
2
2
  graph_games_proto/all_types.py,sha256=IpbwftEcHS5Ewz-saFNk0lO9FvcbuHG36odRTayCXUk,54911
3
- graph_games_proto/fns.py,sha256=Nm-ZCX43EEQ6f8hil0E-7ssB6nqMLIMqhau13QStvdo,192330
3
+ graph_games_proto/fns.py,sha256=Rj9ALtDUBPp5C0sn7ExUcuXrzOabAw7A1Xsf-LKL7Sg,191027
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.1914.dist-info/METADATA,sha256=GJyzgKEyzKBPUc8lVJcSmt5KVoC6BsfpbqwXw7tKSY0,188
7
- graph_games_proto-0.3.1914.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1914.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1914.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1915.dist-info/METADATA,sha256=8DzNZJm4Rg3_o3wwY0t6DEQIjF8wFibw9dK6jrRntd4,188
7
+ graph_games_proto-0.3.1915.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1915.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1915.dist-info/RECORD,,