graph-games-proto 0.3.1701__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 +34 -34
- {graph_games_proto-0.3.1701.dist-info → graph_games_proto-0.3.1708.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1701.dist-info → graph_games_proto-0.3.1708.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1701.dist-info → graph_games_proto-0.3.1708.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1701.dist-info → graph_games_proto-0.3.1708.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -1514,34 +1514,34 @@ class ActionMovePiecesToPathOptional(PClass):
|
|
1514
1514
|
|
1515
1515
|
|
1516
1516
|
class PublicLegalActionMovePiecesToPath(PClass):
|
1517
|
-
|
1517
|
+
path_uuid = field(type=str)
|
1518
1518
|
def __todict__(self):
|
1519
1519
|
return {
|
1520
|
-
"
|
1520
|
+
"path_uuid": self.path_uuid,
|
1521
1521
|
}
|
1522
1522
|
@staticmethod
|
1523
1523
|
def __fromdict__(d):
|
1524
1524
|
return PublicLegalActionMovePiecesToPath(
|
1525
|
-
|
1525
|
+
path_uuid=d["path_uuid"]
|
1526
1526
|
)
|
1527
1527
|
|
1528
1528
|
|
1529
1529
|
class LegalActionMovePiecesToPath(PClass):
|
1530
|
-
|
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
|
-
|
1534
|
+
path_uuid=self.path_uuid,
|
1535
1535
|
)
|
1536
1536
|
def __todict__(self):
|
1537
1537
|
return {
|
1538
|
-
"
|
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
|
-
|
1544
|
+
path_uuid=d["path_uuid"],
|
1545
1545
|
default=ActionMovePiecesToPathOptional.__fromdict__(d["default"])
|
1546
1546
|
)
|
1547
1547
|
@staticmethod
|
@@ -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)
|
@@ -3501,8 +3504,8 @@ def handle_move_pieces_to_path_action(game, action):
|
|
3501
3504
|
if not player or not player.pieces:
|
3502
3505
|
return game
|
3503
3506
|
|
3504
|
-
|
3505
|
-
path =
|
3507
|
+
path_uuid = move_pieces_to_path.path_uuid
|
3508
|
+
path = game.uuid2path[path_uuid]
|
3506
3509
|
|
3507
3510
|
if path is None or not path.segments:
|
3508
3511
|
return game
|
@@ -3525,8 +3528,8 @@ def handle_move_pieces_to_path_action(game, action):
|
|
3525
3528
|
game.decks[game.carduuid2card[card_uuid].deck_idx].discard.append(card_uuid)
|
3526
3529
|
|
3527
3530
|
game = game.set(players=game.players)
|
3528
|
-
game = game.set(
|
3529
|
-
game = game.set(player_graphs=calc_player_graphs(game)) #
|
3531
|
+
game = game.set(uuid2path=game.uuid2path)
|
3532
|
+
game = game.set(player_graphs=calc_player_graphs(game)) #
|
3530
3533
|
|
3531
3534
|
return game
|
3532
3535
|
|
@@ -3791,11 +3794,11 @@ def is_move_pieces_to_path_action_legal(game, action):
|
|
3791
3794
|
# print("******************************1234 is_move_pieces_to_path_action_legal 1")
|
3792
3795
|
player_idx = action.legal_action.player_idx
|
3793
3796
|
proposed_cards_uuids = action.move_pieces_to_path.card_uuids
|
3794
|
-
|
3795
|
-
path = game.
|
3797
|
+
path_uuid = action.legal_action.move_pieces_to_path.path_uuid
|
3798
|
+
path = game.uuid2path[path_uuid]
|
3796
3799
|
proposed_cards = [card_uuid for card_uuid in game.players[player_idx].cards if card_uuid in proposed_cards_uuids]
|
3797
3800
|
proposed_pieces = [piece_uuid for piece_uuid in game.players[player_idx].pieces if piece_uuid in action.move_pieces_to_path.piece_uuids]
|
3798
|
-
remaining_segments = path.
|
3801
|
+
remaining_segments = path.segments
|
3799
3802
|
|
3800
3803
|
# print("******************************1234 is_move_pieces_to_path_action_legal 1b: ", proposed_cards)
|
3801
3804
|
# print("******************************1234 is_move_pieces_to_path_action_legal 1c: ", proposed_pieces)
|
@@ -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,
|
3898
|
-
if
|
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,
|
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,
|
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
|
-
|
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
|
3930
|
-
|
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,
|
3942
|
+
def is_path_open_to_player(game, path_uuid, player_idx):
|
3941
3943
|
|
3942
|
-
if not game or
|
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 =
|
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,
|
4120
|
-
card_fulfillment, piece_fulfillment = get_sample_path_fulfillment(game, player_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,
|
4131
|
-
|
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.
|
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,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=
|
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.
|
7
|
-
graph_games_proto-0.3.
|
8
|
-
graph_games_proto-0.3.
|
9
|
-
graph_games_proto-0.3.
|
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,,
|
File without changes
|
File without changes
|