graph-games-proto 0.3.1752__py3-none-any.whl → 0.3.1755__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 +36 -5
- {graph_games_proto-0.3.1752.dist-info → graph_games_proto-0.3.1755.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1752.dist-info → graph_games_proto-0.3.1755.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1752.dist-info → graph_games_proto-0.3.1755.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1752.dist-info → graph_games_proto-0.3.1755.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -2005,11 +2005,13 @@ class Segment2(PClass):
|
|
2005
2005
|
class Path2(PClass):
|
2006
2006
|
uuid = field(type=str)
|
2007
2007
|
idx = field(type=int)
|
2008
|
+
edge_uuid = field(type=str)
|
2008
2009
|
segments = field(type=list) # List[Segment]
|
2009
2010
|
def __todict__(self):
|
2010
2011
|
return {
|
2011
2012
|
"uuid": self.uuid,
|
2012
2013
|
"idx": self.idx,
|
2014
|
+
"edge_uuid": self.edge_uuid,
|
2013
2015
|
"segments": [segment.__todict__() for segment in self.segments],
|
2014
2016
|
}
|
2015
2017
|
@staticmethod
|
@@ -2017,6 +2019,7 @@ class Path2(PClass):
|
|
2017
2019
|
return Path2(
|
2018
2020
|
uuid=d["uuid"],
|
2019
2021
|
idx=d["idx"],
|
2022
|
+
edge_uuid=d["edge_uuid"],
|
2020
2023
|
segments=[Segment2.__fromdict__(segment) for segment in d["segments"]],
|
2021
2024
|
)
|
2022
2025
|
|
@@ -2532,7 +2535,6 @@ class PublicState(PClass):
|
|
2532
2535
|
decks = field(type=list) # List[PublicDeck]
|
2533
2536
|
piles = field(type=list) # List[Pile]
|
2534
2537
|
player_idxs = field(type=list) # List[int]
|
2535
|
-
game_idx = field(type=int)
|
2536
2538
|
initial_to_play = field(type=list) # List[int]
|
2537
2539
|
to_play = field(type=list) # List[int]
|
2538
2540
|
unit_discards = field(type=list) # List[int]
|
@@ -2605,7 +2607,6 @@ class PublicState(PClass):
|
|
2605
2607
|
decks=[PublicDeck.__fromdict__(deck) for deck in d["decks"]],
|
2606
2608
|
piles=[Pile.__fromdict__(x) for x in d["piles"]],
|
2607
2609
|
player_idxs=d["player_idxs"],
|
2608
|
-
game_idx=d["game_idx"],
|
2609
2610
|
initial_to_play=d["initial_to_play"],
|
2610
2611
|
to_play=d["to_play"],
|
2611
2612
|
unit_discards=d["unit_discards"],
|
@@ -2694,7 +2695,12 @@ def get_edges(rng, board_config, nodeuuid2idx):
|
|
2694
2695
|
segments = [
|
2695
2696
|
Segment2(uuid=s.uuid, unit_uuid=s.unit_uuid, pieces=[]) for s in matching_board_path.path.segments
|
2696
2697
|
]
|
2697
|
-
path = Path2(
|
2698
|
+
path = Path2(
|
2699
|
+
uuid=str(generate_uuid_with_rng(rng)),
|
2700
|
+
idx=path_idx,
|
2701
|
+
edge_uuid=link.uuid,
|
2702
|
+
segments=segments,
|
2703
|
+
)
|
2698
2704
|
paths.append(path)
|
2699
2705
|
|
2700
2706
|
if len(paths) == 0:
|
@@ -3911,16 +3917,41 @@ def get_legal_actions_for_paths(game, player_idx):
|
|
3911
3917
|
return legal_actions
|
3912
3918
|
|
3913
3919
|
|
3920
|
+
def get_player_idxs_on_edge(game, edge):
|
3921
|
+
player_idxs = set()
|
3922
|
+
if not edge or not edge.paths:
|
3923
|
+
return list(player_idxs)
|
3924
|
+
|
3925
|
+
for path in edge.paths:
|
3926
|
+
for segment in path.segments:
|
3927
|
+
if segment.pieces and segment.pieces[0]:
|
3928
|
+
piece = game.pieceuuid2piece.get(segment.pieces[0])
|
3929
|
+
if piece:
|
3930
|
+
player_idxs.add(piece.player_idx)
|
3931
|
+
|
3932
|
+
return list(player_idxs)
|
3933
|
+
|
3934
|
+
|
3914
3935
|
def is_path_open_to_player(game, path_idx, player_idx):
|
3915
3936
|
|
3916
3937
|
if not game or path_idx < 0 or get_total_path_count(game) <= path_idx:
|
3917
3938
|
return False
|
3918
3939
|
|
3940
|
+
path = game.idx2path[path_idx]
|
3941
|
+
edge_idx = game.edgeuuid2idx[path.edge_uuid]
|
3942
|
+
edge = game.edges[edge_idx]
|
3943
|
+
|
3944
|
+
player_idxs_on_edge = get_player_idxs_on_edge(game, edge)
|
3945
|
+
|
3919
3946
|
# Check if edge is too crowded for the number of players
|
3920
|
-
|
3947
|
+
if game.game_config.num_players <= 3:
|
3948
|
+
if len(player_idxs_on_edge) > 0:
|
3949
|
+
return False
|
3950
|
+
|
3951
|
+
if player_idx in player_idxs_on_edge:
|
3952
|
+
return False
|
3921
3953
|
|
3922
3954
|
# Check if any segment of the path has pieces from any player
|
3923
|
-
path = game.idx2path[path_idx]
|
3924
3955
|
if path.segments[0].pieces:
|
3925
3956
|
return False
|
3926
3957
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
graph_games_proto/__init__.py,sha256=O5XjRfe3DlxbJn4zezDvvy7cXvL4IzIRPZCL3Y-n7s8,776
|
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=tXNB_opKY3SYSh0NHlIH77l_xKaTVaVzIDSQrP6G_hg,236864
|
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.1755.dist-info/METADATA,sha256=GbwVTuU6vysYcnS_l9_wdaFLS3M0XcfYSx-A97huRiA,188
|
7
|
+
graph_games_proto-0.3.1755.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1755.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1755.dist-info/RECORD,,
|
File without changes
|
File without changes
|