graph-games-proto 0.3.1699__py3-none-any.whl → 0.3.1701__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 -10
- {graph_games_proto-0.3.1699.dist-info → graph_games_proto-0.3.1701.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1699.dist-info → graph_games_proto-0.3.1701.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1699.dist-info → graph_games_proto-0.3.1701.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1699.dist-info → graph_games_proto-0.3.1701.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -2003,16 +2003,19 @@ class Segment2(PClass):
|
|
2003
2003
|
|
2004
2004
|
|
2005
2005
|
class Path2(PClass):
|
2006
|
+
uuid = field(type=str)
|
2006
2007
|
idx = field(type=int)
|
2007
2008
|
segments = field(type=list) # List[Segment]
|
2008
2009
|
def __todict__(self):
|
2009
2010
|
return {
|
2011
|
+
"uuid": self.uuid,
|
2010
2012
|
"idx": self.idx,
|
2011
2013
|
"segments": [segment.__todict__() for segment in self.segments],
|
2012
2014
|
}
|
2013
2015
|
@staticmethod
|
2014
2016
|
def __fromdict__(d):
|
2015
2017
|
return Path2(
|
2018
|
+
uuid=d["uuid"],
|
2016
2019
|
idx=d["idx"],
|
2017
2020
|
segments=[Segment2.__fromdict__(segment) for segment in d["segments"]],
|
2018
2021
|
)
|
@@ -2148,6 +2151,9 @@ class BonusStatus(PClass):
|
|
2148
2151
|
|
2149
2152
|
|
2150
2153
|
class State(PClass):
|
2154
|
+
uuid2edge = field(type=dict) # Dict[str, BiEdge]
|
2155
|
+
uuid2path = field(type=dict) # Dict[str, Path2]
|
2156
|
+
uuid2segment = field(type=dict) # Dict[str, Segment]
|
2151
2157
|
pieceuuid2piece = field(type=dict) # Dict[str, Piece]
|
2152
2158
|
carduuid2card = field(type=dict) # Dict[str, Card]
|
2153
2159
|
final_scores = field(type=(list, type(None)), initial=None) # Optional[List[int]]
|
@@ -2189,6 +2195,9 @@ class State(PClass):
|
|
2189
2195
|
# market_refills::Vector{MarketRefill}
|
2190
2196
|
def __todict__(self):
|
2191
2197
|
return {
|
2198
|
+
"uuid2edge": {k: v.__todict__() for k, v in self.uuid2edge.items()},
|
2199
|
+
"uuid2path": {k: v.__todict__() for k, v in self.uuid2path.items()},
|
2200
|
+
"uuid2segment": {k: v.__todict__() for k, v in self.uuid2segment.items()},
|
2192
2201
|
"pieceuuid2piece": {k: v.__todict__() for k, v in self.pieceuuid2piece.items()},
|
2193
2202
|
"carduuid2card": {k: v.__todict__() for k, v in self.carduuid2card.items()},
|
2194
2203
|
"final_scores": self.final_scores,
|
@@ -2231,6 +2240,9 @@ class State(PClass):
|
|
2231
2240
|
@staticmethod
|
2232
2241
|
def __fromdict__(d):
|
2233
2242
|
return State(
|
2243
|
+
uuid2edge={k: BiEdge.__fromdict__(v) for k, v in d["uuid2edge"].items()},
|
2244
|
+
uuid2path={k: Path2.__fromdict__(v) for k, v in d["uuid2path"].items()},
|
2245
|
+
uuid2segment={k: Segment2.__fromdict__(v) for k, v in d["uuid2segment"].items()},
|
2234
2246
|
pieceuuid2piece={k: Piece.__fromdict__(v) for k, v in d["pieceuuid2piece"].items()},
|
2235
2247
|
carduuid2card={k: Card.__fromdict__(v) for k, v in d["carduuid2card"].items()},
|
2236
2248
|
final_scores=d["final_scores"],
|
@@ -2688,7 +2700,7 @@ def get_nodes(board_config):
|
|
2688
2700
|
return []
|
2689
2701
|
|
2690
2702
|
|
2691
|
-
def get_edges(board_config, nodeuuid2idx):
|
2703
|
+
def get_edges(rng, board_config, nodeuuid2idx):
|
2692
2704
|
edges = []
|
2693
2705
|
|
2694
2706
|
|
@@ -2703,7 +2715,7 @@ def get_edges(board_config, nodeuuid2idx):
|
|
2703
2715
|
segments = [
|
2704
2716
|
Segment2(uuid=s.uuid, pieces=[]) for s in matching_board_path.path.segments
|
2705
2717
|
]
|
2706
|
-
path = Path2(idx=path_idx, segments=segments)
|
2718
|
+
path = Path2(uuid=str(generate_uuid_with_rng(rng)), idx=path_idx, segments=segments)
|
2707
2719
|
paths.append(path)
|
2708
2720
|
|
2709
2721
|
if len(paths) == 0:
|
@@ -2848,7 +2860,7 @@ def getinitialstate(game_config):
|
|
2848
2860
|
decks.append(deck_obj)
|
2849
2861
|
|
2850
2862
|
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
|
2851
|
-
edges = get_edges(board_config, nodeuuid2idx)
|
2863
|
+
edges = get_edges(rng, board_config, nodeuuid2idx)
|
2852
2864
|
edgeuuid2idx = {edge.uuid: idx for idx, edge in enumerate(edges)}
|
2853
2865
|
edgetuple2uuid = {}
|
2854
2866
|
for edge in edges:
|
@@ -2857,6 +2869,18 @@ def getinitialstate(game_config):
|
|
2857
2869
|
edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
|
2858
2870
|
edgetuple2uuid[edge_tuple] = edge.uuid
|
2859
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
|
+
|
2860
2884
|
bonuses = game_config.fig.board_config.bonuses
|
2861
2885
|
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2862
2886
|
bonus_statuses = [
|
@@ -2876,6 +2900,9 @@ def getinitialstate(game_config):
|
|
2876
2900
|
]
|
2877
2901
|
|
2878
2902
|
state = State(
|
2903
|
+
uuid2edge=uuid2edge,
|
2904
|
+
uuid2path=uuid2path,
|
2905
|
+
uuid2segment=uuid2segment,
|
2879
2906
|
pieceuuid2piece=pieceuuid2piece,
|
2880
2907
|
carduuid2card=carduuid2card,
|
2881
2908
|
final_scores=None,
|
@@ -3864,7 +3891,7 @@ def append_default_legal_actions_for_next_player(game, action, log=False):
|
|
3864
3891
|
|
3865
3892
|
|
3866
3893
|
def get_total_path_count(game):
|
3867
|
-
return
|
3894
|
+
return len(game.uuid2path.values())
|
3868
3895
|
|
3869
3896
|
|
3870
3897
|
def get_legal_actions_for_path(game, player_idx, path_idx):
|
@@ -3873,9 +3900,6 @@ def get_legal_actions_for_path(game, player_idx, path_idx):
|
|
3873
3900
|
|
3874
3901
|
if not is_path_open_to_player(game, path_idx, player_idx):
|
3875
3902
|
return []
|
3876
|
-
|
3877
|
-
# TODO check if player has enough pieces to claim the path
|
3878
|
-
player_pieces = game.players[player_idx].pieces
|
3879
3903
|
|
3880
3904
|
legal_actions = []
|
3881
3905
|
default = get_sample_actionclaimpath(game, player_idx, path_idx)
|
@@ -3914,11 +3938,13 @@ def get_legal_actions_for_paths(game, player_idx):
|
|
3914
3938
|
|
3915
3939
|
|
3916
3940
|
def is_path_open_to_player(game, path_idx, player_idx):
|
3917
|
-
# TODO check if player has enough pieces to claim the path
|
3918
3941
|
|
3919
3942
|
if not game or path_idx < 0 or path_idx >= get_total_path_count(game):
|
3920
3943
|
return False
|
3921
3944
|
|
3945
|
+
# Check if edge is too crowded for the number of players
|
3946
|
+
|
3947
|
+
|
3922
3948
|
# Check if any segment of the path has pieces from any player
|
3923
3949
|
path = get_path_by_idx(game, path_idx)
|
3924
3950
|
if path.segments[0].pieces:
|
@@ -7073,7 +7099,7 @@ def get_imagined_state(static_board_config, player_state):
|
|
7073
7099
|
|
7074
7100
|
|
7075
7101
|
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
|
7076
|
-
edges = get_edges(board_config, nodeuuid2idx)
|
7102
|
+
edges = get_edges(rng, board_config, nodeuuid2idx)
|
7077
7103
|
edgeuuid2idx = {edge.uuid: idx for idx, edge in enumerate(edges)}
|
7078
7104
|
edgetuple2uuid = {}
|
7079
7105
|
for edge in edges:
|
@@ -7087,7 +7113,7 @@ def get_imagined_state(static_board_config, player_state):
|
|
7087
7113
|
player_graphs = [],
|
7088
7114
|
nodes = get_nodes(board_config),
|
7089
7115
|
nodeuuid2idx = nodeuuid2idx,
|
7090
|
-
edges =
|
7116
|
+
edges = edges,
|
7091
7117
|
edgeuuid2idx = edgeuuid2idx,
|
7092
7118
|
edgetuple2uuid = edgetuple2uuid,
|
7093
7119
|
regions = get_regions(board_config),
|
@@ -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=VhyabYcA34Oo4QNUHLPVXCnf050jj3PI3pP1IYz6-aU,264543
|
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.1701.dist-info/METADATA,sha256=72HOO9KiT8Eg17THvFR0FNTXLo1WL2JjD_6FN64m_gE,188
|
7
|
+
graph_games_proto-0.3.1701.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1701.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1701.dist-info/RECORD,,
|
File without changes
|
File without changes
|