graph-games-proto 0.3.1702__py3-none-any.whl → 0.3.1708__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
@@ -1988,16 +1988,19 @@ class Pile(PClass):
1988
1988
 
1989
1989
  class Segment2(PClass):
1990
1990
  uuid = field(type=str)
1991
+ unit_uuid = field(type=(str, type(None)), initial=None) # Optional[str]
1991
1992
  pieces = field(type=list) # List[Piece]
1992
1993
  def __todict__(self):
1993
1994
  return {
1994
1995
  "uuid": self.uuid,
1996
+ "unit_uuid": self.unit_uuid,
1995
1997
  "pieces": self.pieces,
1996
1998
  }
1997
1999
  @staticmethod
1998
2000
  def __fromdict__(d):
1999
2001
  return Segment2(
2000
2002
  uuid=d["uuid"],
2003
+ unit_uuid=d["unit_uuid"],
2001
2004
  pieces=d["pieces"],
2002
2005
  )
2003
2006
 
@@ -2713,7 +2716,7 @@ def get_edges(rng, board_config, nodeuuid2idx):
2713
2716
  for matching_board_path in matching_board_paths:
2714
2717
  path_idx = matching_board_path.num - 1
2715
2718
  segments = [
2716
- Segment2(uuid=s.uuid, pieces=[]) for s in matching_board_path.path.segments
2719
+ Segment2(uuid=s.uuid, unit_uuid=s.unit_uuid, pieces=[]) for s in matching_board_path.path.segments
2717
2720
  ]
2718
2721
  path = Path2(uuid=str(generate_uuid_with_rng(rng)), idx=path_idx, segments=segments)
2719
2722
  paths.append(path)
@@ -3894,15 +3897,15 @@ def get_total_path_count(game):
3894
3897
  return len(game.uuid2path.values())
3895
3898
 
3896
3899
 
3897
- def get_legal_actions_for_path(game, player_idx, path_idx):
3898
- if path_idx < 0 or path_idx >= get_total_path_count(game):
3900
+ def get_legal_actions_for_path(game, player_idx, path_uuid):
3901
+ if path_uuid not in game.uuid2path:
3899
3902
  return []
3900
-
3901
- if not is_path_open_to_player(game, path_idx, player_idx):
3903
+
3904
+ if not is_path_open_to_player(game, path_uuid, player_idx):
3902
3905
  return []
3903
3906
 
3904
3907
  legal_actions = []
3905
- default = get_sample_actionclaimpath(game, player_idx, path_idx)
3908
+ default = get_sample_actionclaimpath(game, player_idx, path_uuid)
3906
3909
  if default:
3907
3910
  legal_actions.append(
3908
3911
  LegalAction(
@@ -3914,7 +3917,7 @@ def get_legal_actions_for_path(game, player_idx, path_idx):
3914
3917
  allotted_since_action_idx=(len(game.history) - 1),
3915
3918
  btn_text="Claim path",
3916
3919
  move_pieces_to_path=LegalActionMovePiecesToPath(
3917
- path_idx=path_idx,
3920
+ path_uuid=path_uuid,
3918
3921
  default=default
3919
3922
  )
3920
3923
  )
@@ -3926,9 +3929,8 @@ def get_legal_actions_for_path(game, player_idx, path_idx):
3926
3929
  def get_legal_actions_for_paths(game, player_idx):
3927
3930
  legal_actions = []
3928
3931
 
3929
- for path in game.game_config.fig.board_config.board_paths:
3930
- path_idx = path.num - 1
3931
- legal_actions_for_path = get_legal_actions_for_path(game, player_idx, path_idx)
3932
+ for path_uuid in game.uuid2path.keys():
3933
+ legal_actions_for_path = get_legal_actions_for_path(game, player_idx, path_uuid)
3932
3934
  if legal_actions_for_path:
3933
3935
  legal_actions.extend(legal_actions_for_path)
3934
3936
  # else:
@@ -3937,16 +3939,16 @@ def get_legal_actions_for_paths(game, player_idx):
3937
3939
  return legal_actions
3938
3940
 
3939
3941
 
3940
- def is_path_open_to_player(game, path_idx, player_idx):
3942
+ def is_path_open_to_player(game, path_uuid, player_idx):
3941
3943
 
3942
- if not game or path_idx < 0 or path_idx >= get_total_path_count(game):
3944
+ if not game or path_uuid not in game.uuid2path:
3943
3945
  return False
3944
3946
 
3945
3947
  # Check if edge is too crowded for the number of players
3946
3948
 
3947
3949
 
3948
3950
  # Check if any segment of the path has pieces from any player
3949
- path = get_path_by_idx(game, path_idx)
3951
+ path = game.uuid2path[path_uuid]
3950
3952
  if path.segments[0].pieces:
3951
3953
  return False
3952
3954
 
@@ -4116,8 +4118,8 @@ def does_fulfill_path(game, player_idx, path_idx, fulfillment):
4116
4118
  return False
4117
4119
 
4118
4120
 
4119
- def get_sample_actionclaimpath(game, player_idx, path_idx):
4120
- card_fulfillment, piece_fulfillment = get_sample_path_fulfillment(game, player_idx, path_idx)
4121
+ def get_sample_actionclaimpath(game, player_idx, path_uuid):
4122
+ card_fulfillment, piece_fulfillment = get_sample_path_fulfillment(game, player_idx, path_uuid)
4121
4123
  if not card_fulfillment or not piece_fulfillment:
4122
4124
  return None
4123
4125
 
@@ -4127,22 +4129,20 @@ def get_sample_actionclaimpath(game, player_idx, path_idx):
4127
4129
  )
4128
4130
 
4129
4131
 
4130
- def get_sample_path_fulfillment(game, player_idx, path_idx):
4131
- log = path_idx == 3 and player_idx == 1
4132
- path = game.game_config.fig.board_config.board_paths[path_idx]
4132
+ def get_sample_path_fulfillment(game, player_idx, path_uuid):
4133
+ path = game.uuid2path[path_uuid]
4133
4134
  remaining_card_uuids = [card_uuid for card_uuid in game.players[player_idx].cards if game.carduuid2card[card_uuid].deck_idx == 0]
4134
4135
  remaining_pieces = [
4135
4136
  piece_uuid
4136
4137
  for piece_uuid in game.players[player_idx].pieces
4137
4138
  if game.pieceuuid2piece[piece_uuid].piece_template_idx == 0
4138
4139
  ]
4139
- remaining_segments = path.path.segments
4140
+ remaining_segments = path.segments
4140
4141
  return get_path_fulfillment_from_resources(
4141
4142
  game,
4142
4143
  remaining_card_uuids,
4143
4144
  remaining_pieces,
4144
4145
  remaining_segments,
4145
- log,
4146
4146
  )
4147
4147
 
4148
4148
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1702
3
+ Version: 0.3.1708
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=16684x3Fre-z3qXrXCF4RCDhkESjGJ_-Tim-AmVFvgk,264526
3
+ graph_games_proto/fns.py,sha256=C8KNhuDQLg2u_ws2HgQd0a8WdhiHIQRQ0wHL1hDxY48,264516
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.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,,
6
+ graph_games_proto-0.3.1708.dist-info/METADATA,sha256=zZOXaYZxDQlvgx1a7NOa__WGhiNBeKn0w9ZQmgtrL8c,188
7
+ graph_games_proto-0.3.1708.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1708.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1708.dist-info/RECORD,,