graph-games-proto 0.3.1733__py3-none-any.whl → 0.3.1738__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
@@ -2155,7 +2155,7 @@ class BonusStatus(PClass):
2155
2155
 
2156
2156
  class State(PClass):
2157
2157
  uuid2edge = field(type=dict) # Dict[str, BiEdge]
2158
- idx2path = field(type=dict) # Dict[str, Path2]
2158
+ idx2path = field(type=list) # List[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
- "idx2path": {k: v.__todict__() for k, v in self.idx2path.items()},
2202
+ "idx2path": [v.__todict__() for v in self.idx2path],
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
- idx2path={k: Path2.__fromdict__(v) for k, v in d["idx2path"].items()},
2247
+ idx2path=[Path2.__fromdict__(v) for v in d["idx2path"]],
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
- idx2path = {}
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
- idx2path[path.idx] = path
2883
+ idx2path.append(path)
2884
2884
  for segment in path.segments:
2885
2885
  uuid2segment[segment.uuid] = segment
2886
2886
 
@@ -3880,14 +3880,12 @@ def append_default_legal_actions_for_next_player(game, action, log=False):
3880
3880
 
3881
3881
 
3882
3882
  def get_total_path_count(game):
3883
- return len(game.idx2path.values())
3883
+ return len(game.idx2path)
3884
3884
 
3885
3885
 
3886
3886
  def get_legal_actions_for_path(game, player_idx, path_idx):
3887
- # print("****************************** get_legal_actions_for_path 1", path_idx)
3888
- if path_idx not in game.idx2path.keys():
3887
+ if path_idx < 0 or get_total_path_count(game) <= path_idx:
3889
3888
  return []
3890
- print("****************************** get_legal_actions_for_path 2", path_idx)
3891
3889
 
3892
3890
  if not is_path_open_to_player(game, path_idx, player_idx):
3893
3891
  return []
@@ -3917,7 +3915,7 @@ def get_legal_actions_for_path(game, player_idx, path_idx):
3917
3915
  def get_legal_actions_for_paths(game, player_idx):
3918
3916
  legal_actions = []
3919
3917
 
3920
- for path_idx in game.idx2path.keys():
3918
+ for path_idx in range(get_total_path_count(game)):
3921
3919
  legal_actions_for_path = get_legal_actions_for_path(game, player_idx, path_idx)
3922
3920
  if legal_actions_for_path:
3923
3921
  legal_actions.extend(legal_actions_for_path)
@@ -3929,7 +3927,7 @@ def get_legal_actions_for_paths(game, player_idx):
3929
3927
 
3930
3928
  def is_path_open_to_player(game, path_idx, player_idx):
3931
3929
 
3932
- if not game or path_idx not in game.idx2path:
3930
+ if not game or path_idx < 0 or get_total_path_count(game) <= path_idx:
3933
3931
  return False
3934
3932
 
3935
3933
  # Check if edge is too crowded for the number of players
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1733
3
+ Version: 0.3.1738
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=sI31dBPkrs_UHYsuc1Q2sdYkJfpVPKpB--FuqghA208,864
2
2
  graph_games_proto/all_types.py,sha256=IpbwftEcHS5Ewz-saFNk0lO9FvcbuHG36odRTayCXUk,54911
3
- graph_games_proto/fns.py,sha256=CAy0WlFfnEFZsMexx7RS1NNyLo0P5gFp3aS4svpjwyA,264238
3
+ graph_games_proto/fns.py,sha256=6g0ZmnvRPm24KVE8G8X6ZHiy4MCw2lTdLckxIcxKX9w,264080
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.1733.dist-info/METADATA,sha256=66eoFVkcdbKwCrg7nvpVvXcVvw2w-yQHuwDhmfMVAQs,188
7
- graph_games_proto-0.3.1733.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1733.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1733.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1738.dist-info/METADATA,sha256=CygOMgbby4Df4__1cThcu05pNH31usj0mCWDVTTBN8A,188
7
+ graph_games_proto-0.3.1738.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1738.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1738.dist-info/RECORD,,