graph-games-proto 0.3.2083__py3-none-any.whl → 0.3.2096__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 +87 -70
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2096.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2096.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2096.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2096.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -982,6 +982,38 @@ class GameConfig(PClass):
|
|
982
982
|
fig=Fig.__fromdict__(d["fig"]),
|
983
983
|
seed=d["seed"]
|
984
984
|
)
|
985
|
+
|
986
|
+
|
987
|
+
class PublicGameConfig(PClass):
|
988
|
+
uuid = field(type=str)
|
989
|
+
started_at = field(type=str)
|
990
|
+
num_players = field(type=int)
|
991
|
+
fig = field(type=Fig)
|
992
|
+
def __todict__(self):
|
993
|
+
return {
|
994
|
+
"uuid": self.uuid,
|
995
|
+
"started_at": self.started_at,
|
996
|
+
"num_players": self.num_players,
|
997
|
+
"fig": self.fig.__todict__(),
|
998
|
+
}
|
999
|
+
@staticmethod
|
1000
|
+
def __fromdict__(d):
|
1001
|
+
return PublicGameConfig(
|
1002
|
+
uuid=d["uuid"],
|
1003
|
+
started_at=d["started_at"],
|
1004
|
+
num_players=d["num_players"],
|
1005
|
+
fig=Fig.__fromdict__(d["fig"]),
|
1006
|
+
)
|
1007
|
+
|
1008
|
+
|
1009
|
+
@dispatch(GameConfig)
|
1010
|
+
def getpublicgameconfig(game_config):
|
1011
|
+
return PublicGameConfig(
|
1012
|
+
uuid=game_config.uuid,
|
1013
|
+
started_at=game_config.started_at,
|
1014
|
+
num_players=game_config.num_players,
|
1015
|
+
fig=game_config.fig,
|
1016
|
+
)
|
985
1017
|
|
986
1018
|
|
987
1019
|
class ActionDrawUnit:
|
@@ -1195,7 +1227,7 @@ class LegalActionKeep(PClass):
|
|
1195
1227
|
num_cards = len(card_uuids_matching_deck)
|
1196
1228
|
actual_min = 0 if legal_action.keep.min is None else legal_action.keep.min
|
1197
1229
|
actual_max = num_cards if legal_action.keep.max is None else min(legal_action.keep.max, num_cards)
|
1198
|
-
rand_num_chosen = state.rng.randint(actual_min, actual_max)
|
1230
|
+
rand_num_chosen = state.kernel.rng.randint(actual_min, actual_max)
|
1199
1231
|
card_uuids = card_uuids_matching_deck[0:rand_num_chosen]
|
1200
1232
|
return Action2(
|
1201
1233
|
submitted_at=submitted_at,
|
@@ -1236,7 +1268,7 @@ class LegalActionDiscard(PClass):
|
|
1236
1268
|
num_cards = len(card_uuids_matching_deck)
|
1237
1269
|
actual_min = 0 if legal_action.discard.min is None else legal_action.discard.min
|
1238
1270
|
actual_max = num_cards if legal_action.discard.max is None else min(legal_action.discard.max, num_cards)
|
1239
|
-
rand_num_chosen = state.rng.randint(actual_min, actual_max)
|
1271
|
+
rand_num_chosen = state.kernel.rng.randint(actual_min, actual_max)
|
1240
1272
|
card_uuids = card_uuids_matching_deck[0:rand_num_chosen]
|
1241
1273
|
return Action2(
|
1242
1274
|
submitted_at=submitted_at,
|
@@ -1809,13 +1841,11 @@ def init_segment_record(segment: Segment2) -> SegmentRecord:
|
|
1809
1841
|
|
1810
1842
|
|
1811
1843
|
class Path2(PClass):
|
1812
|
-
uuid = field(type=str)
|
1813
1844
|
idx = field(type=int)
|
1814
1845
|
edge_uuid = field(type=str)
|
1815
1846
|
segments = field(type=list) # List[Segment]
|
1816
1847
|
def __todict__(self):
|
1817
1848
|
return {
|
1818
|
-
"uuid": self.uuid,
|
1819
1849
|
"idx": self.idx,
|
1820
1850
|
"edge_uuid": self.edge_uuid,
|
1821
1851
|
"segments": [segment.__todict__() for segment in self.segments],
|
@@ -1823,7 +1853,6 @@ class Path2(PClass):
|
|
1823
1853
|
@staticmethod
|
1824
1854
|
def __fromdict__(d):
|
1825
1855
|
return Path2(
|
1826
|
-
uuid=d["uuid"],
|
1827
1856
|
idx=d["idx"],
|
1828
1857
|
edge_uuid=d["edge_uuid"],
|
1829
1858
|
segments=[Segment2.__fromdict__(segment) for segment in d["segments"]],
|
@@ -1831,13 +1860,11 @@ class Path2(PClass):
|
|
1831
1860
|
|
1832
1861
|
|
1833
1862
|
class PathRecord(PClass):
|
1834
|
-
uuid = field(type=str)
|
1835
1863
|
idx = field(type=int)
|
1836
1864
|
edge_uuid = field(type=str)
|
1837
1865
|
segment_uuids = field(type=list) # List[str]
|
1838
1866
|
def __todict__(self):
|
1839
1867
|
return {
|
1840
|
-
"uuid": self.uuid,
|
1841
1868
|
"idx": self.idx,
|
1842
1869
|
"edge_uuid": self.edge_uuid,
|
1843
1870
|
"segment_uuids": self.segment_uuids,
|
@@ -1845,7 +1872,6 @@ class PathRecord(PClass):
|
|
1845
1872
|
@staticmethod
|
1846
1873
|
def __fromdict__(d):
|
1847
1874
|
return PathRecord(
|
1848
|
-
uuid=d["uuid"],
|
1849
1875
|
idx=d["idx"],
|
1850
1876
|
edge_uuid=d["edge_uuid"],
|
1851
1877
|
segment_uuids=d["segment_uuids"],
|
@@ -1854,7 +1880,6 @@ class PathRecord(PClass):
|
|
1854
1880
|
|
1855
1881
|
def init_path_record(path: Path2) -> PathRecord:
|
1856
1882
|
return PathRecord(
|
1857
|
-
uuid=path.uuid,
|
1858
1883
|
idx=path.idx,
|
1859
1884
|
edge_uuid=path.edge_uuid,
|
1860
1885
|
segment_uuids=[segment.uuid for segment in path.segments],
|
@@ -2052,10 +2077,8 @@ class BonusStatus(PClass):
|
|
2052
2077
|
|
2053
2078
|
|
2054
2079
|
class StateKernel(PClass):
|
2080
|
+
game_config = field(type=GameConfig)
|
2055
2081
|
rng = field(type=random.Random)
|
2056
|
-
fig = field(type=Fig)
|
2057
|
-
num_players = field(type=int)
|
2058
|
-
started_at = field(type=str)
|
2059
2082
|
|
2060
2083
|
uuid2edgerecord = field(type=dict) # Dict[str, BiEdgeRecord]
|
2061
2084
|
uuid2segmentrecord = field(type=dict) # Dict[str, SegmentRecord]
|
@@ -2083,10 +2106,8 @@ class StateKernel(PClass):
|
|
2083
2106
|
player_graphs_3 = field(type=list) # List[PlayerGraph]
|
2084
2107
|
def __todict__(self):
|
2085
2108
|
return {
|
2109
|
+
"game_config": self.game_config.__todict__(),
|
2086
2110
|
"rng": rng2json(self.rng),
|
2087
|
-
"fig": self.fig.__todict__(),
|
2088
|
-
"num_players": self.num_players,
|
2089
|
-
"started_at": self.started_at,
|
2090
2111
|
"edges": [edge.__todict__() for edge in self.edges],
|
2091
2112
|
"nodes": [node.__todict__() for node in self.nodes],
|
2092
2113
|
"regions": [region.__todict__() for region in self.regions],
|
@@ -2114,10 +2135,8 @@ class StateKernel(PClass):
|
|
2114
2135
|
@staticmethod
|
2115
2136
|
def __fromdict__(d):
|
2116
2137
|
return StateKernel(
|
2138
|
+
game_config=GameConfig.__fromdict__(d["game_config"]),
|
2117
2139
|
rng=json2rng(d["rng"]),
|
2118
|
-
fig=Fig.__fromdict__(d["fig"]),
|
2119
|
-
num_players=d["num_players"],
|
2120
|
-
started_at=d["started_at"],
|
2121
2140
|
edges=[BiEdge.__fromdict__(edge) for edge in d["edges"]],
|
2122
2141
|
nodes=[Node.__fromdict__(n) for n in d["nodes"]],
|
2123
2142
|
regions=[Region.__fromdict__(r) for r in d["regions"]],
|
@@ -2144,12 +2163,11 @@ class StateKernel(PClass):
|
|
2144
2163
|
)
|
2145
2164
|
|
2146
2165
|
|
2147
|
-
def init_state_kernel(
|
2148
|
-
board_config = fig.board_config
|
2149
|
-
rng = kwargs.get('rng')
|
2166
|
+
def init_state_kernel(game_config, **kwargs):
|
2167
|
+
board_config = game_config.fig.board_config
|
2150
2168
|
nodes = kwargs.get('nodes', get_nodes(board_config))
|
2151
2169
|
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(nodes)}
|
2152
|
-
edges = get_edges(
|
2170
|
+
edges = get_edges(board_config, nodeuuid2idx)
|
2153
2171
|
segments = kwargs.get('segments', get_segments(board_config))
|
2154
2172
|
goals = board_config.goals
|
2155
2173
|
regions = kwargs.get('regions', [])
|
@@ -2162,7 +2180,7 @@ def init_state_kernel(fig, num_players, started_at, **kwargs):
|
|
2162
2180
|
pieceuuid2piece = {}
|
2163
2181
|
for piece_template in board_config.piece_templates:
|
2164
2182
|
if piece_template.has_player:
|
2165
|
-
for player_idx in range(num_players):
|
2183
|
+
for player_idx in range(game_config.num_players):
|
2166
2184
|
pieces = generate_pieces(piece_template, player_idx)
|
2167
2185
|
for piece in pieces:
|
2168
2186
|
pieceuuid2piece[piece.uuid] = piece
|
@@ -2178,7 +2196,7 @@ def init_state_kernel(fig, num_players, started_at, **kwargs):
|
|
2178
2196
|
starting_piles = []
|
2179
2197
|
for piece_template in board_config.piece_templates:
|
2180
2198
|
if piece_template.has_player:
|
2181
|
-
for player_idx in range(num_players):
|
2199
|
+
for player_idx in range(game_config.num_players):
|
2182
2200
|
pieces = generate_pieces(piece_template, player_idx)
|
2183
2201
|
pile = Pile(
|
2184
2202
|
player_idx=player_idx,
|
@@ -2187,8 +2205,6 @@ def init_state_kernel(fig, num_players, started_at, **kwargs):
|
|
2187
2205
|
)
|
2188
2206
|
starting_piles.append(pile)
|
2189
2207
|
|
2190
|
-
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
|
2191
|
-
edges = get_edges(rng, board_config, nodeuuid2idx)
|
2192
2208
|
edgetuple2uuid = {}
|
2193
2209
|
for edge in edges:
|
2194
2210
|
node_1_idx = nodeuuid2idx[edge.node_1_uuid]
|
@@ -2199,9 +2215,8 @@ def init_state_kernel(fig, num_players, started_at, **kwargs):
|
|
2199
2215
|
bonuses = board_config.bonuses
|
2200
2216
|
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2201
2217
|
|
2202
|
-
player_graphs_3 = calc_player_graphs3(nodes, edges, pieceuuid2piece, num_players)
|
2218
|
+
player_graphs_3 = calc_player_graphs3(nodes, edges, pieceuuid2piece, game_config.num_players)
|
2203
2219
|
|
2204
|
-
|
2205
2220
|
uuid2segmentrecord = {segment.uuid: init_segment_record(segment) for segment in segments}
|
2206
2221
|
uuid2edgerecord = {edge.uuid: init_biedge_record(edge) for edge in edges}
|
2207
2222
|
|
@@ -2219,19 +2234,17 @@ def init_state_kernel(fig, num_players, started_at, **kwargs):
|
|
2219
2234
|
starting_decks.append(deck_obj)
|
2220
2235
|
|
2221
2236
|
default_players = [
|
2222
|
-
Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(num_players)
|
2237
|
+
Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(game_config.num_players)
|
2223
2238
|
]
|
2224
2239
|
|
2225
2240
|
return StateKernel(
|
2241
|
+
game_config=game_config,
|
2242
|
+
rng=getrng(game_config.seed),
|
2226
2243
|
decks=kwargs.get('decks', starting_decks),
|
2227
2244
|
piles=kwargs.get('piles', starting_piles),
|
2228
2245
|
players=kwargs.get('players', default_players),
|
2229
|
-
player_idxs=kwargs.get('player_idxs', list(range(num_players))),
|
2246
|
+
player_idxs=kwargs.get('player_idxs', list(range(game_config.num_players))),
|
2230
2247
|
history=kwargs.get('history', []),
|
2231
|
-
fig=fig,
|
2232
|
-
num_players=num_players,
|
2233
|
-
started_at=started_at,
|
2234
|
-
rng=rng,
|
2235
2248
|
edges=edges,
|
2236
2249
|
nodes=nodes,
|
2237
2250
|
regions=regions,
|
@@ -2513,6 +2526,7 @@ class RemainingAllottedTime(PClass):
|
|
2513
2526
|
|
2514
2527
|
|
2515
2528
|
class PublicState(PClass):
|
2529
|
+
game_config = field(type=PublicGameConfig)
|
2516
2530
|
deadlines = field(type=list) # List[RemainingAllottedTime|None]
|
2517
2531
|
game_started_at = field(type=str)
|
2518
2532
|
allotted_times = field(type=list)
|
@@ -2537,6 +2551,7 @@ class PublicState(PClass):
|
|
2537
2551
|
terminal = field(type=bool)
|
2538
2552
|
def __todict__(self):
|
2539
2553
|
return {
|
2554
|
+
"game_config": self.game_config.__todict__(),
|
2540
2555
|
"deadlines": [deadline.__todict__() if deadline else None for deadline in self.deadlines],
|
2541
2556
|
"game_started_at": self.game_started_at,
|
2542
2557
|
"allotted_times": [allotted_time.__todict__() if allotted_time else None for allotted_time in self.allotted_times], # List[AllottedTime|None]
|
@@ -2563,6 +2578,7 @@ class PublicState(PClass):
|
|
2563
2578
|
@staticmethod
|
2564
2579
|
def __fromdict__(d):
|
2565
2580
|
return PublicState(
|
2581
|
+
game_config=PublicGameConfig.__fromdict__(d["game_config"]),
|
2566
2582
|
deadlines=[RemainingAllottedTime.__fromdict__(x) for x in d["deadlines"]],
|
2567
2583
|
game_started_at=d["game_started_at"],
|
2568
2584
|
allotted_times=[AllottedTime.__fromdict__(x) if x else None for x in d["allotted_times"]], # List[AllottedTime|None]
|
@@ -2653,7 +2669,7 @@ def get_segments(board_config):
|
|
2653
2669
|
return segments
|
2654
2670
|
|
2655
2671
|
|
2656
|
-
def get_edges(
|
2672
|
+
def get_edges(board_config, nodeuuid2idx):
|
2657
2673
|
edges = []
|
2658
2674
|
|
2659
2675
|
|
@@ -2669,7 +2685,6 @@ def get_edges(rng, board_config, nodeuuid2idx):
|
|
2669
2685
|
Segment2(uuid=s.uuid, unit_uuid=s.unit_uuid, pieces=[]) for s in matching_board_path.path.segments
|
2670
2686
|
]
|
2671
2687
|
path = Path2(
|
2672
|
-
uuid=str(generate_uuid_with_rng(rng)),
|
2673
2688
|
idx=path_idx,
|
2674
2689
|
edge_uuid=link.uuid,
|
2675
2690
|
segments=segments,
|
@@ -2741,17 +2756,12 @@ def getsettingvalue(f, setting_name):
|
|
2741
2756
|
|
2742
2757
|
@dispatch(State, str)
|
2743
2758
|
def getsettingvalue(s, setting_name):
|
2744
|
-
return getsettingvalue(s.kernel.fig, setting_name)
|
2759
|
+
return getsettingvalue(s.kernel.game_config.fig, setting_name)
|
2745
2760
|
|
2746
2761
|
|
2747
2762
|
@dispatch(GameConfig)
|
2748
2763
|
def getinitialstate(game_config):
|
2749
|
-
kernel = init_state_kernel(
|
2750
|
-
game_config.fig,
|
2751
|
-
game_config.num_players,
|
2752
|
-
game_config.started_at,
|
2753
|
-
rng=getrng(game_config.seed),
|
2754
|
-
)
|
2764
|
+
kernel = init_state_kernel(game_config)
|
2755
2765
|
kernel = run_kernel_hooks(kernel, INITIALIZATION_HOOKS, True)
|
2756
2766
|
return init_memoized_state(kernel)
|
2757
2767
|
|
@@ -2777,7 +2787,7 @@ def memoize_state(state):
|
|
2777
2787
|
def calc_bonus_statuses3(kernel):
|
2778
2788
|
bonus_statuses = [
|
2779
2789
|
calc_bonus_status3(kernel, bonus)
|
2780
|
-
for bonus in kernel.fig.board_config.bonuses
|
2790
|
+
for bonus in kernel.game_config.fig.board_config.bonuses
|
2781
2791
|
]
|
2782
2792
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
2783
2793
|
return bonus_statuses
|
@@ -2853,7 +2863,7 @@ def score_public_items3(state, player_idx):
|
|
2853
2863
|
)
|
2854
2864
|
for bonus_status in state.bonus_statuses_3:
|
2855
2865
|
bonus_idx = state.kernel.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2856
|
-
bonus = state.kernel.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2866
|
+
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2857
2867
|
if bonus:
|
2858
2868
|
if player_idx in bonus_status.winners:
|
2859
2869
|
items.append(
|
@@ -2889,7 +2899,7 @@ def score_public_items(state, player_idx):
|
|
2889
2899
|
)
|
2890
2900
|
for bonus_status in state.bonus_statuses:
|
2891
2901
|
bonus_idx = state.kernel.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2892
|
-
bonus = state.kernel.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2902
|
+
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2893
2903
|
if bonus:
|
2894
2904
|
if player_idx in bonus_status.winners:
|
2895
2905
|
items.append(
|
@@ -3052,7 +3062,7 @@ def get_bonus_status_longest_trail3(kernel, bonus):
|
|
3052
3062
|
winners = []
|
3053
3063
|
player_longest_trail_lens = []
|
3054
3064
|
|
3055
|
-
for player_idx in range(kernel.num_players):
|
3065
|
+
for player_idx in range(kernel.game_config.num_players):
|
3056
3066
|
trail_length = get_longest_path_length3(kernel, player_idx)
|
3057
3067
|
player_longest_trail_lens.append(trail_length)
|
3058
3068
|
if trail_length > longest_trail:
|
@@ -3084,7 +3094,7 @@ def get_bonus_status_longest_trail(state, bonus):
|
|
3084
3094
|
winners = []
|
3085
3095
|
player_longest_trail_lens = []
|
3086
3096
|
|
3087
|
-
for player_idx in range(state.kernel.num_players):
|
3097
|
+
for player_idx in range(state.kernel.game_config.num_players):
|
3088
3098
|
trail_length = get_longest_path_length(state, player_idx)
|
3089
3099
|
player_longest_trail_lens.append(trail_length)
|
3090
3100
|
if trail_length > longest_trail:
|
@@ -3114,7 +3124,7 @@ def get_bonus_status_longest_trail(state, bonus):
|
|
3114
3124
|
def handle_bonus_statuses(state):
|
3115
3125
|
bonus_statuses = [
|
3116
3126
|
calc_bonus_status(state, bonus)
|
3117
|
-
for bonus in state.kernel.fig.board_config.bonuses
|
3127
|
+
for bonus in state.kernel.game_config.fig.board_config.bonuses
|
3118
3128
|
]
|
3119
3129
|
# Remove all None bonus statuses
|
3120
3130
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
@@ -3477,7 +3487,7 @@ def find_player_with_longest_path(kernel):
|
|
3477
3487
|
longest_path_player_idx = None
|
3478
3488
|
longest_path_length = 0
|
3479
3489
|
|
3480
|
-
for player_idx in range(kernel.num_players):
|
3490
|
+
for player_idx in range(kernel.game_config.num_players):
|
3481
3491
|
path_length = get_longest_path_length(kernel, player_idx)
|
3482
3492
|
if path_length > longest_path_length:
|
3483
3493
|
longest_path_length = path_length
|
@@ -3706,7 +3716,7 @@ def calc_player_graph3(nodes, edges, pieceuuid2piece, player_idx):
|
|
3706
3716
|
def calc_player_graphs(state):
|
3707
3717
|
return [
|
3708
3718
|
calc_player_graph(state, player_idx)
|
3709
|
-
for player_idx in range(state.kernel.num_players)
|
3719
|
+
for player_idx in range(state.kernel.game_config.num_players)
|
3710
3720
|
]
|
3711
3721
|
|
3712
3722
|
|
@@ -4050,7 +4060,7 @@ def is_path_open_to_player(state_kernel, path_idx, player_idx):
|
|
4050
4060
|
player_idxs_on_edge = get_player_idxs_on_edge(state_kernel, edge_record)
|
4051
4061
|
|
4052
4062
|
# Check if edge is too crowded for the number of players
|
4053
|
-
if state_kernel.num_players <= 3:
|
4063
|
+
if state_kernel.game_config.num_players <= 3:
|
4054
4064
|
if len(player_idxs_on_edge) > 0:
|
4055
4065
|
return False
|
4056
4066
|
|
@@ -4523,7 +4533,7 @@ def getpublictoplay(s):
|
|
4523
4533
|
def get_max_allotted_times(s):
|
4524
4534
|
return [
|
4525
4535
|
get_player_max_allotted_time(s, player_idx)
|
4526
|
-
for player_idx in range(s.kernel.num_players)
|
4536
|
+
for player_idx in range(s.kernel.game_config.num_players)
|
4527
4537
|
]
|
4528
4538
|
|
4529
4539
|
|
@@ -4549,7 +4559,7 @@ def get_deadline(s, max_allotted_time):
|
|
4549
4559
|
since_action_idx = max_allotted_time.since_action_idx
|
4550
4560
|
if since_action_idx == -1:
|
4551
4561
|
allotted_since = datetime.strptime(
|
4552
|
-
s.kernel.started_at,
|
4562
|
+
s.kernel.game_config.started_at,
|
4553
4563
|
"%Y-%m-%d %H:%M:%S"
|
4554
4564
|
)
|
4555
4565
|
else:
|
@@ -4568,7 +4578,7 @@ def get_deadline(s, max_allotted_time):
|
|
4568
4578
|
@dispatch(State)
|
4569
4579
|
def get_deadlines(s):
|
4570
4580
|
if isterminal(s):
|
4571
|
-
return [None for _ in range(s.kernel.num_players)]
|
4581
|
+
return [None for _ in range(s.kernel.game_config.num_players)]
|
4572
4582
|
return [
|
4573
4583
|
get_deadline(s, max_allotted_time)
|
4574
4584
|
for max_allotted_time in get_max_allotted_times(s)
|
@@ -4630,9 +4640,16 @@ def imagine_decks(public_state, private_state):
|
|
4630
4640
|
|
4631
4641
|
|
4632
4642
|
def imagine_state(public_state, private_state):
|
4643
|
+
public_game_config = public_state.game_config
|
4644
|
+
|
4633
4645
|
imagined_kernel = init_state_kernel(
|
4634
|
-
|
4635
|
-
|
4646
|
+
GameConfig(
|
4647
|
+
seed=random.randint(0, 2**31 - 1),
|
4648
|
+
uuid=public_game_config.uuid,
|
4649
|
+
num_players=public_game_config.num_players,
|
4650
|
+
fig=public_game_config.fig,
|
4651
|
+
started_at=public_game_config.started_at,
|
4652
|
+
),
|
4636
4653
|
edges=public_state.edges,
|
4637
4654
|
nodes=public_state.nodes,
|
4638
4655
|
piles=public_state.piles,
|
@@ -4672,7 +4689,6 @@ def getpublicstate(s):
|
|
4672
4689
|
)
|
4673
4690
|
paths.append(
|
4674
4691
|
Path2(
|
4675
|
-
uuid=path_record.uuid,
|
4676
4692
|
edge_uuid=path_record.edge_uuid,
|
4677
4693
|
segments=segments,
|
4678
4694
|
idx=path_record.idx
|
@@ -4697,8 +4713,9 @@ def getpublicstate(s):
|
|
4697
4713
|
|
4698
4714
|
|
4699
4715
|
return PublicState(
|
4716
|
+
game_config=getpublicgameconfig(s.kernel.game_config),
|
4700
4717
|
deadlines=get_deadlines(s),
|
4701
|
-
game_started_at=s.kernel.started_at,
|
4718
|
+
game_started_at=s.kernel.game_config.started_at,
|
4702
4719
|
allotted_times=get_max_allotted_times(s),
|
4703
4720
|
all_pieces=list(s.kernel.pieceuuid2piece.values()),
|
4704
4721
|
to_play_2=getpublictoplay(s),
|
@@ -4736,10 +4753,10 @@ def getpublicdeck(s, d):
|
|
4736
4753
|
|
4737
4754
|
@dispatch(State, Player)
|
4738
4755
|
def getpublicplayer(s, p):
|
4739
|
-
deck_counts = [0 for _ in s.kernel.fig.board_config.deks]
|
4756
|
+
deck_counts = [0 for _ in s.kernel.game_config.fig.board_config.deks]
|
4740
4757
|
for card in p.cards:
|
4741
4758
|
deck_counts[s.kernel.carduuid2card[card].deck_idx] += 1
|
4742
|
-
piece_template_counts = [0 for _ in s.kernel.fig.board_config.piece_templates]
|
4759
|
+
piece_template_counts = [0 for _ in s.kernel.game_config.fig.board_config.piece_templates]
|
4743
4760
|
for piece_uuid in p.pieces:
|
4744
4761
|
piece_template_counts[s.kernel.pieceuuid2piece[piece_uuid].piece_template_idx] += 1
|
4745
4762
|
return PublicPlayer(
|
@@ -4783,10 +4800,10 @@ def getpublicscore(s, player_idx):
|
|
4783
4800
|
path_lens = getplayerpathlens(s, player_idx)
|
4784
4801
|
if not path_lens:
|
4785
4802
|
return 0
|
4786
|
-
addends.append(sum(s.kernel.fig.path_scores[len] for len in path_lens))
|
4803
|
+
addends.append(sum(s.kernel.game_config.fig.path_scores[len] for len in path_lens))
|
4787
4804
|
|
4788
4805
|
if getsettingvalue(s, 'cluster_scoring'):
|
4789
|
-
clusters = s.kernel.fig.board_config.clusters
|
4806
|
+
clusters = s.kernel.game_config.fig.board_config.clusters
|
4790
4807
|
uuid2cluster = {x.uuid: x for x in clusters}
|
4791
4808
|
completed_clusters = s.player_hands[player_idx].completed_clusters
|
4792
4809
|
cluster_scores = [uuid2cluster[cluster_uuid].score for cluster_uuid in completed_clusters]
|
@@ -4809,7 +4826,7 @@ def getplayerpathlens(s, player_idx):
|
|
4809
4826
|
# Implementing the following Julia function:
|
4810
4827
|
# getpathlens(s::State) = length.(getfield.(getfield.(s.fig.board_config.board_paths, :path), :segments))
|
4811
4828
|
def getpathlens(s):
|
4812
|
-
return [len(p.path.segments) for p in s.kernel.fig.board_config.board_paths]
|
4829
|
+
return [len(p.path.segments) for p in s.kernel.game_config.fig.board_config.board_paths]
|
4813
4830
|
|
4814
4831
|
# Implementing the following Julia function:
|
4815
4832
|
# function getplayerpathidxs(s::State, player_idx::Int)
|
@@ -4849,7 +4866,7 @@ def getactiontype(action_name):
|
|
4849
4866
|
|
4850
4867
|
|
4851
4868
|
# Function implements the following Julia function:
|
4852
|
-
# getlastplayeridxplus1(s) = mod1(getlastaction(s).player_idx + 1, s.kernel.num_players)
|
4869
|
+
# getlastplayeridxplus1(s) = mod1(getlastaction(s).player_idx + 1, s.kernel.game_config.num_players)
|
4853
4870
|
def getlastplayeridxplus1(s):
|
4854
4871
|
pass
|
4855
4872
|
|
@@ -5022,7 +5039,7 @@ def combinations(a, n=None):
|
|
5022
5039
|
def getpotentialpathidxs(s, player_num):
|
5023
5040
|
num_pieces = s.player_hands[player_num-1].num_pieces
|
5024
5041
|
return list(
|
5025
|
-
set(getpathidxs(s.kernel.fig, num_pieces)) - set(getunavailablepathidxs(s, player_num))
|
5042
|
+
set(getpathidxs(s.kernel.game_config.fig, num_pieces)) - set(getunavailablepathidxs(s, player_num))
|
5026
5043
|
)
|
5027
5044
|
# return list(set(getpathidxs(s.fig, num_pieces)) - set(getunavailablepaths(s, player_num)))
|
5028
5045
|
|
@@ -5086,16 +5103,16 @@ def getunavailablepathidxs(s, player_idx):
|
|
5086
5103
|
link2paths = {}
|
5087
5104
|
path2link = {}
|
5088
5105
|
|
5089
|
-
for board_path in s.kernel.fig.board_config.board_paths:
|
5106
|
+
for board_path in s.kernel.game_config.fig.board_config.board_paths:
|
5090
5107
|
link_idx = board_path.link_num - 1
|
5091
5108
|
if link_idx not in link2paths:
|
5092
5109
|
link2paths[link_idx] = []
|
5093
5110
|
link2paths[link_idx].append(board_path.num-1)
|
5094
5111
|
path2link[board_path.num-1] = link_idx
|
5095
5112
|
|
5096
|
-
multipath_links = [(board_link.num-1) for board_link in getmultipathlinks(s.kernel.fig)]
|
5113
|
+
multipath_links = [(board_link.num-1) for board_link in getmultipathlinks(s.kernel.game_config.fig)]
|
5097
5114
|
|
5098
|
-
if s.kernel.num_players < 4:
|
5115
|
+
if s.kernel.game_config.num_players < 4:
|
5099
5116
|
blocking_hands = s.player_hands
|
5100
5117
|
else:
|
5101
5118
|
blocking_hands = [s.player_hands[player_idx]]
|
@@ -5601,7 +5618,7 @@ def getqproxy0(ps, a, td):
|
|
5601
5618
|
return rewards
|
5602
5619
|
v_proxies = [
|
5603
5620
|
getvproxy0(getprivatestate(next_s, i))
|
5604
|
-
for i in range(next_s.kernel.num_players)
|
5621
|
+
for i in range(next_s.kernel.game_config.num_players)
|
5605
5622
|
]
|
5606
5623
|
q_proxies = [
|
5607
5624
|
r + v_proxies[i]
|
@@ -1,9 +1,9 @@
|
|
1
1
|
graph_games_proto/__init__.py,sha256=_EVQR-51XehfH45XZlba1WPdx3omS3Gm1nTwrgGyn2Q,667
|
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=Ni2ywvhv9562Hi1_pQie5P4aEtqLORss3yxaF-b24L8,199711
|
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.2096.dist-info/METADATA,sha256=RsItWXIDMFkMIN2peGo0mTJo6zq6UpjN64X5kChH3qE,188
|
7
|
+
graph_games_proto-0.3.2096.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.2096.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.2096.dist-info/RECORD,,
|
File without changes
|
File without changes
|