graph-games-proto 0.3.1700__py3-none-any.whl → 0.3.1702__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_idx = field(type=int)
1517
+ path_uuid = field(type=str)
1518
1518
  def __todict__(self):
1519
1519
  return {
1520
- "path_idx": self.path_idx
1520
+ "path_uuid": self.path_uuid,
1521
1521
  }
1522
1522
  @staticmethod
1523
1523
  def __fromdict__(d):
1524
1524
  return PublicLegalActionMovePiecesToPath(
1525
- path_idx=d["path_idx"]
1525
+ path_uuid=d["path_uuid"]
1526
1526
  )
1527
1527
 
1528
1528
 
1529
1529
  class LegalActionMovePiecesToPath(PClass):
1530
- path_idx = field(type=int)
1530
+ path_uuid = field(type=str)
1531
1531
  default = field(type=ActionMovePiecesToPathOptional) # Optional[MovePiecesToPathAction]
1532
1532
  def get_public(self, state):
1533
1533
  return PublicLegalActionMovePiecesToPath(
1534
- path_idx=self.path_idx,
1534
+ path_uuid=self.path_uuid,
1535
1535
  )
1536
1536
  def __todict__(self):
1537
1537
  return {
1538
- "path_idx": self.path_idx,
1538
+ "path_uuid": self.path_uuid,
1539
1539
  "default": self.default.__todict__(),
1540
1540
  }
1541
1541
  @staticmethod
1542
1542
  def __fromdict__(d):
1543
1543
  return LegalActionMovePiecesToPath(
1544
- path_idx=d["path_idx"],
1544
+ path_uuid=d["path_uuid"],
1545
1545
  default=ActionMovePiecesToPathOptional.__fromdict__(d["default"])
1546
1546
  )
1547
1547
  @staticmethod
@@ -2826,17 +2826,6 @@ def getinitialstate(game_config):
2826
2826
  deck_1_rng = getrng(8738758)
2827
2827
  nodes = get_nodes(board_config)
2828
2828
 
2829
- uuid2edge = {}
2830
- uuid2path = {}
2831
- uuid2segment = {}
2832
-
2833
- for edge in edges:
2834
- uuid2edge[edge.uuid] = edge
2835
- for path in edge.paths:
2836
- uuid2path[path.uuid] = path
2837
- for segment in path.segments:
2838
- uuid2segment[segment.uuid] = segment
2839
-
2840
2829
  pieceuuid2piece = {}
2841
2830
  piles = []
2842
2831
  for piece_template in board_config.piece_templates:
@@ -2880,6 +2869,18 @@ def getinitialstate(game_config):
2880
2869
  edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
2881
2870
  edgetuple2uuid[edge_tuple] = edge.uuid
2882
2871
 
2872
+
2873
+ uuid2edge = {}
2874
+ uuid2path = {}
2875
+ uuid2segment = {}
2876
+
2877
+ for edge in edges:
2878
+ uuid2edge[edge.uuid] = edge
2879
+ for path in edge.paths:
2880
+ uuid2path[path.uuid] = path
2881
+ for segment in path.segments:
2882
+ uuid2segment[segment.uuid] = segment
2883
+
2883
2884
  bonuses = game_config.fig.board_config.bonuses
2884
2885
  bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
2885
2886
  bonus_statuses = [
@@ -3500,8 +3501,8 @@ def handle_move_pieces_to_path_action(game, action):
3500
3501
  if not player or not player.pieces:
3501
3502
  return game
3502
3503
 
3503
- path_idx = move_pieces_to_path.path_idx
3504
- path = get_path_by_idx(game, path_idx)
3504
+ path_uuid = move_pieces_to_path.path_uuid
3505
+ path = game.uuid2path[path_uuid]
3505
3506
 
3506
3507
  if path is None or not path.segments:
3507
3508
  return game
@@ -3524,8 +3525,8 @@ def handle_move_pieces_to_path_action(game, action):
3524
3525
  game.decks[game.carduuid2card[card_uuid].deck_idx].discard.append(card_uuid)
3525
3526
 
3526
3527
  game = game.set(players=game.players)
3527
- game = game.set(edges=game.edges)
3528
- game = game.set(player_graphs=calc_player_graphs(game)) #
3528
+ game = game.set(uuid2path=game.uuid2path)
3529
+ game = game.set(player_graphs=calc_player_graphs(game)) #
3529
3530
 
3530
3531
  return game
3531
3532
 
@@ -3790,11 +3791,11 @@ def is_move_pieces_to_path_action_legal(game, action):
3790
3791
  # print("******************************1234 is_move_pieces_to_path_action_legal 1")
3791
3792
  player_idx = action.legal_action.player_idx
3792
3793
  proposed_cards_uuids = action.move_pieces_to_path.card_uuids
3793
- path_idx = action.legal_action.move_pieces_to_path.path_idx
3794
- path = game.game_config.fig.board_config.board_paths[path_idx]
3794
+ path_uuid = action.legal_action.move_pieces_to_path.path_uuid
3795
+ path = game.uuid2path[path_uuid]
3795
3796
  proposed_cards = [card_uuid for card_uuid in game.players[player_idx].cards if card_uuid in proposed_cards_uuids]
3796
3797
  proposed_pieces = [piece_uuid for piece_uuid in game.players[player_idx].pieces if piece_uuid in action.move_pieces_to_path.piece_uuids]
3797
- remaining_segments = path.path.segments
3798
+ remaining_segments = path.segments
3798
3799
 
3799
3800
  # print("******************************1234 is_move_pieces_to_path_action_legal 1b: ", proposed_cards)
3800
3801
  # print("******************************1234 is_move_pieces_to_path_action_legal 1c: ", proposed_pieces)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1700
3
+ Version: 0.3.1702
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=QDewUyasIGcpavrEdAcnEDwZtJq0YRBzoTjPIDQUC14,264542
3
+ graph_games_proto/fns.py,sha256=16684x3Fre-z3qXrXCF4RCDhkESjGJ_-Tim-AmVFvgk,264526
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.1700.dist-info/METADATA,sha256=MZ4Kcxgx7QiPgfsPk4urx0lxB-2tMQYu-sX5q6tS-6s,188
7
- graph_games_proto-0.3.1700.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1700.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1700.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1702.dist-info/METADATA,sha256=miFHpsrtSUCKDs5w82i3b1f8XeoHGWtIwWgSc5Muc40,188
7
+ graph_games_proto-0.3.1702.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1702.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1702.dist-info/RECORD,,