graph-games-proto 0.3.1709__py3-none-any.whl → 0.3.1710__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
@@ -1514,34 +1514,34 @@ class ActionMovePiecesToPathOptional(PClass):
1514
1514
 
1515
1515
 
1516
1516
  class PublicLegalActionMovePiecesToPath(PClass):
1517
- path_uuid = field(type=str)
1517
+ path_idx = field(type=str)
1518
1518
  def __todict__(self):
1519
1519
  return {
1520
- "path_uuid": self.path_uuid,
1520
+ "path_idx": self.path_idx,
1521
1521
  }
1522
1522
  @staticmethod
1523
1523
  def __fromdict__(d):
1524
1524
  return PublicLegalActionMovePiecesToPath(
1525
- path_uuid=d["path_uuid"]
1525
+ path_idx=d["path_idx"]
1526
1526
  )
1527
1527
 
1528
1528
 
1529
1529
  class LegalActionMovePiecesToPath(PClass):
1530
- path_uuid = field(type=str)
1530
+ path_idx = field(type=str)
1531
1531
  default = field(type=ActionMovePiecesToPathOptional) # Optional[MovePiecesToPathAction]
1532
1532
  def get_public(self, state):
1533
1533
  return PublicLegalActionMovePiecesToPath(
1534
- path_uuid=self.path_uuid,
1534
+ path_idx=self.path_idx,
1535
1535
  )
1536
1536
  def __todict__(self):
1537
1537
  return {
1538
- "path_uuid": self.path_uuid,
1538
+ "path_idx": self.path_idx,
1539
1539
  "default": self.default.__todict__(),
1540
1540
  }
1541
1541
  @staticmethod
1542
1542
  def __fromdict__(d):
1543
1543
  return LegalActionMovePiecesToPath(
1544
- path_uuid=d["path_uuid"],
1544
+ path_idx=d["path_idx"],
1545
1545
  default=ActionMovePiecesToPathOptional.__fromdict__(d["default"])
1546
1546
  )
1547
1547
  @staticmethod
@@ -2155,7 +2155,7 @@ class BonusStatus(PClass):
2155
2155
 
2156
2156
  class State(PClass):
2157
2157
  uuid2edge = field(type=dict) # Dict[str, BiEdge]
2158
- uuid2path = field(type=dict) # Dict[str, Path2]
2158
+ idx2path = field(type=dict) # Dict[str, Path2]
2159
2159
  uuid2segment = field(type=dict) # Dict[str, Segment]
2160
2160
  pieceuuid2piece = field(type=dict) # Dict[str, Piece]
2161
2161
  carduuid2card = field(type=dict) # Dict[str, Card]
@@ -2199,7 +2199,7 @@ class State(PClass):
2199
2199
  def __todict__(self):
2200
2200
  return {
2201
2201
  "uuid2edge": {k: v.__todict__() for k, v in self.uuid2edge.items()},
2202
- "uuid2path": {k: v.__todict__() for k, v in self.uuid2path.items()},
2202
+ "idx2path": {k: v.__todict__() for k, v in self.idx2path.items()},
2203
2203
  "uuid2segment": {k: v.__todict__() for k, v in self.uuid2segment.items()},
2204
2204
  "pieceuuid2piece": {k: v.__todict__() for k, v in self.pieceuuid2piece.items()},
2205
2205
  "carduuid2card": {k: v.__todict__() for k, v in self.carduuid2card.items()},
@@ -2244,7 +2244,7 @@ class State(PClass):
2244
2244
  def __fromdict__(d):
2245
2245
  return State(
2246
2246
  uuid2edge={k: BiEdge.__fromdict__(v) for k, v in d["uuid2edge"].items()},
2247
- uuid2path={k: Path2.__fromdict__(v) for k, v in d["uuid2path"].items()},
2247
+ idx2path={k: Path2.__fromdict__(v) for k, v in d["idx2path"].items()},
2248
2248
  uuid2segment={k: Segment2.__fromdict__(v) for k, v in d["uuid2segment"].items()},
2249
2249
  pieceuuid2piece={k: Piece.__fromdict__(v) for k, v in d["pieceuuid2piece"].items()},
2250
2250
  carduuid2card={k: Card.__fromdict__(v) for k, v in d["carduuid2card"].items()},
@@ -2874,13 +2874,13 @@ def getinitialstate(game_config):
2874
2874
 
2875
2875
 
2876
2876
  uuid2edge = {}
2877
- uuid2path = {}
2877
+ idx2path = {}
2878
2878
  uuid2segment = {}
2879
2879
 
2880
2880
  for edge in edges:
2881
2881
  uuid2edge[edge.uuid] = edge
2882
2882
  for path in edge.paths:
2883
- uuid2path[path.uuid] = path
2883
+ idx2path[path.uuid] = path
2884
2884
  for segment in path.segments:
2885
2885
  uuid2segment[segment.uuid] = segment
2886
2886
 
@@ -2904,7 +2904,7 @@ def getinitialstate(game_config):
2904
2904
 
2905
2905
  state = State(
2906
2906
  uuid2edge=uuid2edge,
2907
- uuid2path=uuid2path,
2907
+ idx2path=idx2path,
2908
2908
  uuid2segment=uuid2segment,
2909
2909
  pieceuuid2piece=pieceuuid2piece,
2910
2910
  carduuid2card=carduuid2card,
@@ -3161,20 +3161,6 @@ def default_after_accept_action(game, action):
3161
3161
  )
3162
3162
 
3163
3163
 
3164
- def get_path_by_idx(game, path_idx):
3165
- if not game or path_idx < 0 or path_idx >= len(game.game_config.fig.board_config.board_paths):
3166
- return None
3167
-
3168
- for edge in game.edges:
3169
- if len(edge.paths) == 0:
3170
- raise ValueError(f"Edge {edge.uuid} has no paths")
3171
- for path in edge.paths:
3172
- if path.idx == path_idx:
3173
- return path
3174
-
3175
- return None
3176
-
3177
-
3178
3164
  def handle_draw_action(game, action):
3179
3165
  if not game or not action or not action.legal_action or not action.legal_action.draw:
3180
3166
  return game
@@ -3504,8 +3490,8 @@ def handle_move_pieces_to_path_action(game, action):
3504
3490
  if not player or not player.pieces:
3505
3491
  return game
3506
3492
 
3507
- path_uuid = move_pieces_to_path.path_uuid
3508
- path = game.uuid2path[path_uuid]
3493
+ path_idx = move_pieces_to_path.path_idx
3494
+ path = game.idx2path[path_idx]
3509
3495
 
3510
3496
  if path is None or not path.segments:
3511
3497
  return game
@@ -3528,7 +3514,7 @@ def handle_move_pieces_to_path_action(game, action):
3528
3514
  game.decks[game.carduuid2card[card_uuid].deck_idx].discard.append(card_uuid)
3529
3515
 
3530
3516
  game = game.set(players=game.players)
3531
- game = game.set(uuid2path=game.uuid2path)
3517
+ game = game.set(idx2path=game.idx2path)
3532
3518
  game = game.set(player_graphs=calc_player_graphs(game)) #
3533
3519
 
3534
3520
  return game
@@ -3794,8 +3780,8 @@ def is_move_pieces_to_path_action_legal(game, action):
3794
3780
  # print("******************************1234 is_move_pieces_to_path_action_legal 1")
3795
3781
  player_idx = action.legal_action.player_idx
3796
3782
  proposed_cards_uuids = action.move_pieces_to_path.card_uuids
3797
- path_uuid = action.legal_action.move_pieces_to_path.path_uuid
3798
- path = game.uuid2path[path_uuid]
3783
+ path_idx = action.legal_action.move_pieces_to_path.path_idx
3784
+ path = game.idx2path[path_idx]
3799
3785
  proposed_cards = [card_uuid for card_uuid in game.players[player_idx].cards if card_uuid in proposed_cards_uuids]
3800
3786
  proposed_pieces = [piece_uuid for piece_uuid in game.players[player_idx].pieces if piece_uuid in action.move_pieces_to_path.piece_uuids]
3801
3787
  remaining_segments = path.segments
@@ -3894,18 +3880,18 @@ def append_default_legal_actions_for_next_player(game, action, log=False):
3894
3880
 
3895
3881
 
3896
3882
  def get_total_path_count(game):
3897
- return len(game.uuid2path.values())
3883
+ return len(game.idx2path.values())
3898
3884
 
3899
3885
 
3900
- def get_legal_actions_for_path(game, player_idx, path_uuid):
3901
- if path_uuid not in game.uuid2path:
3886
+ def get_legal_actions_for_path(game, player_idx, path_idx):
3887
+ if path_idx not in game.idx2path:
3902
3888
  return []
3903
3889
 
3904
- if not is_path_open_to_player(game, path_uuid, player_idx):
3890
+ if not is_path_open_to_player(game, path_idx, player_idx):
3905
3891
  return []
3906
3892
 
3907
3893
  legal_actions = []
3908
- default = get_sample_actionclaimpath(game, player_idx, path_uuid)
3894
+ default = get_sample_actionclaimpath(game, player_idx, path_idx)
3909
3895
  if default:
3910
3896
  legal_actions.append(
3911
3897
  LegalAction(
@@ -3917,7 +3903,7 @@ def get_legal_actions_for_path(game, player_idx, path_uuid):
3917
3903
  allotted_since_action_idx=(len(game.history) - 1),
3918
3904
  btn_text="Claim path",
3919
3905
  move_pieces_to_path=LegalActionMovePiecesToPath(
3920
- path_uuid=path_uuid,
3906
+ path_idx=path_idx,
3921
3907
  default=default
3922
3908
  )
3923
3909
  )
@@ -3929,8 +3915,8 @@ def get_legal_actions_for_path(game, player_idx, path_uuid):
3929
3915
  def get_legal_actions_for_paths(game, player_idx):
3930
3916
  legal_actions = []
3931
3917
 
3932
- for path_uuid in game.uuid2path.keys():
3933
- legal_actions_for_path = get_legal_actions_for_path(game, player_idx, path_uuid)
3918
+ for path_idx in game.idx2path.keys():
3919
+ legal_actions_for_path = get_legal_actions_for_path(game, player_idx, path_idx)
3934
3920
  if legal_actions_for_path:
3935
3921
  legal_actions.extend(legal_actions_for_path)
3936
3922
  # else:
@@ -3939,16 +3925,16 @@ def get_legal_actions_for_paths(game, player_idx):
3939
3925
  return legal_actions
3940
3926
 
3941
3927
 
3942
- def is_path_open_to_player(game, path_uuid, player_idx):
3928
+ def is_path_open_to_player(game, path_idx, player_idx):
3943
3929
 
3944
- if not game or path_uuid not in game.uuid2path:
3930
+ if not game or path_idx not in game.idx2path:
3945
3931
  return False
3946
3932
 
3947
3933
  # Check if edge is too crowded for the number of players
3948
3934
 
3949
3935
 
3950
3936
  # Check if any segment of the path has pieces from any player
3951
- path = game.uuid2path[path_uuid]
3937
+ path = game.idx2path[path_idx]
3952
3938
  if path.segments[0].pieces:
3953
3939
  return False
3954
3940
 
@@ -4118,8 +4104,8 @@ def does_fulfill_path(game, player_idx, path_idx, fulfillment):
4118
4104
  return False
4119
4105
 
4120
4106
 
4121
- def get_sample_actionclaimpath(game, player_idx, path_uuid):
4122
- card_fulfillment, piece_fulfillment = get_sample_path_fulfillment(game, player_idx, path_uuid)
4107
+ def get_sample_actionclaimpath(game, player_idx, path_idx):
4108
+ card_fulfillment, piece_fulfillment = get_sample_path_fulfillment(game, player_idx, path_idx)
4123
4109
  if not card_fulfillment or not piece_fulfillment:
4124
4110
  return None
4125
4111
 
@@ -4129,8 +4115,8 @@ def get_sample_actionclaimpath(game, player_idx, path_uuid):
4129
4115
  )
4130
4116
 
4131
4117
 
4132
- def get_sample_path_fulfillment(game, player_idx, path_uuid):
4133
- path = game.uuid2path[path_uuid]
4118
+ def get_sample_path_fulfillment(game, player_idx, path_idx):
4119
+ path = game.idx2path[path_idx]
4134
4120
  remaining_card_uuids = [card_uuid for card_uuid in game.players[player_idx].cards if game.carduuid2card[card_uuid].deck_idx == 0]
4135
4121
  remaining_pieces = [
4136
4122
  piece_uuid
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1709
3
+ Version: 0.3.1710
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=LOpk1mGZxPWMRGrPNoXDENn7JPG6rNfhieehItW8bEA,881
2
2
  graph_games_proto/all_types.py,sha256=IpbwftEcHS5Ewz-saFNk0lO9FvcbuHG36odRTayCXUk,54911
3
- graph_games_proto/fns.py,sha256=C8KNhuDQLg2u_ws2HgQd0a8WdhiHIQRQ0wHL1hDxY48,264516
3
+ graph_games_proto/fns.py,sha256=h1o-uA304yMKqLSgLgFSRrpWSkvmCLY8EbQwi1JO-7g,264059
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.1709.dist-info/METADATA,sha256=ev79QNjtQd3Qtaqdx1nasU_MaiYPGxVtrO6Sp3dk8xA,188
7
- graph_games_proto-0.3.1709.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1709.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1709.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1710.dist-info/METADATA,sha256=AzBXd589rEtm5U23ya7vjrmlWGBU4rbZ8nKCHZEvnx8,188
7
+ graph_games_proto-0.3.1710.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1710.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1710.dist-info/RECORD,,