graph-games-proto 0.3.2083__py3-none-any.whl → 0.3.2095__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 +83 -68
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2095.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2095.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2095.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.2083.dist-info → graph_games_proto-0.3.2095.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)
|
@@ -2653,7 +2667,7 @@ def get_segments(board_config):
|
|
2653
2667
|
return segments
|
2654
2668
|
|
2655
2669
|
|
2656
|
-
def get_edges(
|
2670
|
+
def get_edges(board_config, nodeuuid2idx):
|
2657
2671
|
edges = []
|
2658
2672
|
|
2659
2673
|
|
@@ -2669,7 +2683,6 @@ def get_edges(rng, board_config, nodeuuid2idx):
|
|
2669
2683
|
Segment2(uuid=s.uuid, unit_uuid=s.unit_uuid, pieces=[]) for s in matching_board_path.path.segments
|
2670
2684
|
]
|
2671
2685
|
path = Path2(
|
2672
|
-
uuid=str(generate_uuid_with_rng(rng)),
|
2673
2686
|
idx=path_idx,
|
2674
2687
|
edge_uuid=link.uuid,
|
2675
2688
|
segments=segments,
|
@@ -2741,17 +2754,12 @@ def getsettingvalue(f, setting_name):
|
|
2741
2754
|
|
2742
2755
|
@dispatch(State, str)
|
2743
2756
|
def getsettingvalue(s, setting_name):
|
2744
|
-
return getsettingvalue(s.kernel.fig, setting_name)
|
2757
|
+
return getsettingvalue(s.kernel.game_config.fig, setting_name)
|
2745
2758
|
|
2746
2759
|
|
2747
2760
|
@dispatch(GameConfig)
|
2748
2761
|
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
|
-
)
|
2762
|
+
kernel = init_state_kernel(game_config)
|
2755
2763
|
kernel = run_kernel_hooks(kernel, INITIALIZATION_HOOKS, True)
|
2756
2764
|
return init_memoized_state(kernel)
|
2757
2765
|
|
@@ -2777,7 +2785,7 @@ def memoize_state(state):
|
|
2777
2785
|
def calc_bonus_statuses3(kernel):
|
2778
2786
|
bonus_statuses = [
|
2779
2787
|
calc_bonus_status3(kernel, bonus)
|
2780
|
-
for bonus in kernel.fig.board_config.bonuses
|
2788
|
+
for bonus in kernel.game_config.fig.board_config.bonuses
|
2781
2789
|
]
|
2782
2790
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
2783
2791
|
return bonus_statuses
|
@@ -2853,7 +2861,7 @@ def score_public_items3(state, player_idx):
|
|
2853
2861
|
)
|
2854
2862
|
for bonus_status in state.bonus_statuses_3:
|
2855
2863
|
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
|
2864
|
+
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2857
2865
|
if bonus:
|
2858
2866
|
if player_idx in bonus_status.winners:
|
2859
2867
|
items.append(
|
@@ -2889,7 +2897,7 @@ def score_public_items(state, player_idx):
|
|
2889
2897
|
)
|
2890
2898
|
for bonus_status in state.bonus_statuses:
|
2891
2899
|
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
|
2900
|
+
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2893
2901
|
if bonus:
|
2894
2902
|
if player_idx in bonus_status.winners:
|
2895
2903
|
items.append(
|
@@ -3052,7 +3060,7 @@ def get_bonus_status_longest_trail3(kernel, bonus):
|
|
3052
3060
|
winners = []
|
3053
3061
|
player_longest_trail_lens = []
|
3054
3062
|
|
3055
|
-
for player_idx in range(kernel.num_players):
|
3063
|
+
for player_idx in range(kernel.game_config.num_players):
|
3056
3064
|
trail_length = get_longest_path_length3(kernel, player_idx)
|
3057
3065
|
player_longest_trail_lens.append(trail_length)
|
3058
3066
|
if trail_length > longest_trail:
|
@@ -3084,7 +3092,7 @@ def get_bonus_status_longest_trail(state, bonus):
|
|
3084
3092
|
winners = []
|
3085
3093
|
player_longest_trail_lens = []
|
3086
3094
|
|
3087
|
-
for player_idx in range(state.kernel.num_players):
|
3095
|
+
for player_idx in range(state.kernel.game_config.num_players):
|
3088
3096
|
trail_length = get_longest_path_length(state, player_idx)
|
3089
3097
|
player_longest_trail_lens.append(trail_length)
|
3090
3098
|
if trail_length > longest_trail:
|
@@ -3114,7 +3122,7 @@ def get_bonus_status_longest_trail(state, bonus):
|
|
3114
3122
|
def handle_bonus_statuses(state):
|
3115
3123
|
bonus_statuses = [
|
3116
3124
|
calc_bonus_status(state, bonus)
|
3117
|
-
for bonus in state.kernel.fig.board_config.bonuses
|
3125
|
+
for bonus in state.kernel.game_config.fig.board_config.bonuses
|
3118
3126
|
]
|
3119
3127
|
# Remove all None bonus statuses
|
3120
3128
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
@@ -3477,7 +3485,7 @@ def find_player_with_longest_path(kernel):
|
|
3477
3485
|
longest_path_player_idx = None
|
3478
3486
|
longest_path_length = 0
|
3479
3487
|
|
3480
|
-
for player_idx in range(kernel.num_players):
|
3488
|
+
for player_idx in range(kernel.game_config.num_players):
|
3481
3489
|
path_length = get_longest_path_length(kernel, player_idx)
|
3482
3490
|
if path_length > longest_path_length:
|
3483
3491
|
longest_path_length = path_length
|
@@ -3706,7 +3714,7 @@ def calc_player_graph3(nodes, edges, pieceuuid2piece, player_idx):
|
|
3706
3714
|
def calc_player_graphs(state):
|
3707
3715
|
return [
|
3708
3716
|
calc_player_graph(state, player_idx)
|
3709
|
-
for player_idx in range(state.kernel.num_players)
|
3717
|
+
for player_idx in range(state.kernel.game_config.num_players)
|
3710
3718
|
]
|
3711
3719
|
|
3712
3720
|
|
@@ -4050,7 +4058,7 @@ def is_path_open_to_player(state_kernel, path_idx, player_idx):
|
|
4050
4058
|
player_idxs_on_edge = get_player_idxs_on_edge(state_kernel, edge_record)
|
4051
4059
|
|
4052
4060
|
# Check if edge is too crowded for the number of players
|
4053
|
-
if state_kernel.num_players <= 3:
|
4061
|
+
if state_kernel.game_config.num_players <= 3:
|
4054
4062
|
if len(player_idxs_on_edge) > 0:
|
4055
4063
|
return False
|
4056
4064
|
|
@@ -4523,7 +4531,7 @@ def getpublictoplay(s):
|
|
4523
4531
|
def get_max_allotted_times(s):
|
4524
4532
|
return [
|
4525
4533
|
get_player_max_allotted_time(s, player_idx)
|
4526
|
-
for player_idx in range(s.kernel.num_players)
|
4534
|
+
for player_idx in range(s.kernel.game_config.num_players)
|
4527
4535
|
]
|
4528
4536
|
|
4529
4537
|
|
@@ -4568,7 +4576,7 @@ def get_deadline(s, max_allotted_time):
|
|
4568
4576
|
@dispatch(State)
|
4569
4577
|
def get_deadlines(s):
|
4570
4578
|
if isterminal(s):
|
4571
|
-
return [None for _ in range(s.kernel.num_players)]
|
4579
|
+
return [None for _ in range(s.kernel.game_config.num_players)]
|
4572
4580
|
return [
|
4573
4581
|
get_deadline(s, max_allotted_time)
|
4574
4582
|
for max_allotted_time in get_max_allotted_times(s)
|
@@ -4630,9 +4638,16 @@ def imagine_decks(public_state, private_state):
|
|
4630
4638
|
|
4631
4639
|
|
4632
4640
|
def imagine_state(public_state, private_state):
|
4641
|
+
public_game_config = public_state.game_config
|
4642
|
+
|
4633
4643
|
imagined_kernel = init_state_kernel(
|
4634
|
-
|
4635
|
-
|
4644
|
+
GameConfig(
|
4645
|
+
seed=random.randint(0, 2**31 - 1),
|
4646
|
+
uuid=public_game_config.uuid,
|
4647
|
+
num_players=public_game_config.num_players,
|
4648
|
+
fig=public_game_config.fig,
|
4649
|
+
started_at=public_game_config.started_at,
|
4650
|
+
),
|
4636
4651
|
edges=public_state.edges,
|
4637
4652
|
nodes=public_state.nodes,
|
4638
4653
|
piles=public_state.piles,
|
@@ -4672,7 +4687,6 @@ def getpublicstate(s):
|
|
4672
4687
|
)
|
4673
4688
|
paths.append(
|
4674
4689
|
Path2(
|
4675
|
-
uuid=path_record.uuid,
|
4676
4690
|
edge_uuid=path_record.edge_uuid,
|
4677
4691
|
segments=segments,
|
4678
4692
|
idx=path_record.idx
|
@@ -4697,6 +4711,7 @@ def getpublicstate(s):
|
|
4697
4711
|
|
4698
4712
|
|
4699
4713
|
return PublicState(
|
4714
|
+
game_config=getpublicgameconfig(s.kernel.game_config),
|
4700
4715
|
deadlines=get_deadlines(s),
|
4701
4716
|
game_started_at=s.kernel.started_at,
|
4702
4717
|
allotted_times=get_max_allotted_times(s),
|
@@ -4736,10 +4751,10 @@ def getpublicdeck(s, d):
|
|
4736
4751
|
|
4737
4752
|
@dispatch(State, Player)
|
4738
4753
|
def getpublicplayer(s, p):
|
4739
|
-
deck_counts = [0 for _ in s.kernel.fig.board_config.deks]
|
4754
|
+
deck_counts = [0 for _ in s.kernel.game_config.fig.board_config.deks]
|
4740
4755
|
for card in p.cards:
|
4741
4756
|
deck_counts[s.kernel.carduuid2card[card].deck_idx] += 1
|
4742
|
-
piece_template_counts = [0 for _ in s.kernel.fig.board_config.piece_templates]
|
4757
|
+
piece_template_counts = [0 for _ in s.kernel.game_config.fig.board_config.piece_templates]
|
4743
4758
|
for piece_uuid in p.pieces:
|
4744
4759
|
piece_template_counts[s.kernel.pieceuuid2piece[piece_uuid].piece_template_idx] += 1
|
4745
4760
|
return PublicPlayer(
|
@@ -4783,10 +4798,10 @@ def getpublicscore(s, player_idx):
|
|
4783
4798
|
path_lens = getplayerpathlens(s, player_idx)
|
4784
4799
|
if not path_lens:
|
4785
4800
|
return 0
|
4786
|
-
addends.append(sum(s.kernel.fig.path_scores[len] for len in path_lens))
|
4801
|
+
addends.append(sum(s.kernel.game_config.fig.path_scores[len] for len in path_lens))
|
4787
4802
|
|
4788
4803
|
if getsettingvalue(s, 'cluster_scoring'):
|
4789
|
-
clusters = s.kernel.fig.board_config.clusters
|
4804
|
+
clusters = s.kernel.game_config.fig.board_config.clusters
|
4790
4805
|
uuid2cluster = {x.uuid: x for x in clusters}
|
4791
4806
|
completed_clusters = s.player_hands[player_idx].completed_clusters
|
4792
4807
|
cluster_scores = [uuid2cluster[cluster_uuid].score for cluster_uuid in completed_clusters]
|
@@ -4809,7 +4824,7 @@ def getplayerpathlens(s, player_idx):
|
|
4809
4824
|
# Implementing the following Julia function:
|
4810
4825
|
# getpathlens(s::State) = length.(getfield.(getfield.(s.fig.board_config.board_paths, :path), :segments))
|
4811
4826
|
def getpathlens(s):
|
4812
|
-
return [len(p.path.segments) for p in s.kernel.fig.board_config.board_paths]
|
4827
|
+
return [len(p.path.segments) for p in s.kernel.game_config.fig.board_config.board_paths]
|
4813
4828
|
|
4814
4829
|
# Implementing the following Julia function:
|
4815
4830
|
# function getplayerpathidxs(s::State, player_idx::Int)
|
@@ -4849,7 +4864,7 @@ def getactiontype(action_name):
|
|
4849
4864
|
|
4850
4865
|
|
4851
4866
|
# Function implements the following Julia function:
|
4852
|
-
# getlastplayeridxplus1(s) = mod1(getlastaction(s).player_idx + 1, s.kernel.num_players)
|
4867
|
+
# getlastplayeridxplus1(s) = mod1(getlastaction(s).player_idx + 1, s.kernel.game_config.num_players)
|
4853
4868
|
def getlastplayeridxplus1(s):
|
4854
4869
|
pass
|
4855
4870
|
|
@@ -5022,7 +5037,7 @@ def combinations(a, n=None):
|
|
5022
5037
|
def getpotentialpathidxs(s, player_num):
|
5023
5038
|
num_pieces = s.player_hands[player_num-1].num_pieces
|
5024
5039
|
return list(
|
5025
|
-
set(getpathidxs(s.kernel.fig, num_pieces)) - set(getunavailablepathidxs(s, player_num))
|
5040
|
+
set(getpathidxs(s.kernel.game_config.fig, num_pieces)) - set(getunavailablepathidxs(s, player_num))
|
5026
5041
|
)
|
5027
5042
|
# return list(set(getpathidxs(s.fig, num_pieces)) - set(getunavailablepaths(s, player_num)))
|
5028
5043
|
|
@@ -5086,16 +5101,16 @@ def getunavailablepathidxs(s, player_idx):
|
|
5086
5101
|
link2paths = {}
|
5087
5102
|
path2link = {}
|
5088
5103
|
|
5089
|
-
for board_path in s.kernel.fig.board_config.board_paths:
|
5104
|
+
for board_path in s.kernel.game_config.fig.board_config.board_paths:
|
5090
5105
|
link_idx = board_path.link_num - 1
|
5091
5106
|
if link_idx not in link2paths:
|
5092
5107
|
link2paths[link_idx] = []
|
5093
5108
|
link2paths[link_idx].append(board_path.num-1)
|
5094
5109
|
path2link[board_path.num-1] = link_idx
|
5095
5110
|
|
5096
|
-
multipath_links = [(board_link.num-1) for board_link in getmultipathlinks(s.kernel.fig)]
|
5111
|
+
multipath_links = [(board_link.num-1) for board_link in getmultipathlinks(s.kernel.game_config.fig)]
|
5097
5112
|
|
5098
|
-
if s.kernel.num_players < 4:
|
5113
|
+
if s.kernel.game_config.num_players < 4:
|
5099
5114
|
blocking_hands = s.player_hands
|
5100
5115
|
else:
|
5101
5116
|
blocking_hands = [s.player_hands[player_idx]]
|
@@ -5601,7 +5616,7 @@ def getqproxy0(ps, a, td):
|
|
5601
5616
|
return rewards
|
5602
5617
|
v_proxies = [
|
5603
5618
|
getvproxy0(getprivatestate(next_s, i))
|
5604
|
-
for i in range(next_s.kernel.num_players)
|
5619
|
+
for i in range(next_s.kernel.game_config.num_players)
|
5605
5620
|
]
|
5606
5621
|
q_proxies = [
|
5607
5622
|
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=aq2Vxkuz1J4LGAPlO8OZtW1Tns81gL68UICMfsZzeHY,199556
|
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.2095.dist-info/METADATA,sha256=3B4hZJi4LhHbTKGGFf-y7t0nTc0sQ-w_1rPTCZ0-jyA,188
|
7
|
+
graph_games_proto-0.3.2095.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.2095.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.2095.dist-info/RECORD,,
|
File without changes
|
File without changes
|