graph-games-proto 0.3.2078__py3-none-any.whl → 0.3.2083__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 +97 -148
- {graph_games_proto-0.3.2078.dist-info → graph_games_proto-0.3.2083.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.2078.dist-info → graph_games_proto-0.3.2083.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.2078.dist-info → graph_games_proto-0.3.2083.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.2078.dist-info → graph_games_proto-0.3.2083.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -2053,7 +2053,9 @@ class BonusStatus(PClass):
|
|
2053
2053
|
|
2054
2054
|
class StateKernel(PClass):
|
2055
2055
|
rng = field(type=random.Random)
|
2056
|
-
|
2056
|
+
fig = field(type=Fig)
|
2057
|
+
num_players = field(type=int)
|
2058
|
+
started_at = field(type=str)
|
2057
2059
|
|
2058
2060
|
uuid2edgerecord = field(type=dict) # Dict[str, BiEdgeRecord]
|
2059
2061
|
uuid2segmentrecord = field(type=dict) # Dict[str, SegmentRecord]
|
@@ -2082,7 +2084,9 @@ class StateKernel(PClass):
|
|
2082
2084
|
def __todict__(self):
|
2083
2085
|
return {
|
2084
2086
|
"rng": rng2json(self.rng),
|
2085
|
-
"
|
2087
|
+
"fig": self.fig.__todict__(),
|
2088
|
+
"num_players": self.num_players,
|
2089
|
+
"started_at": self.started_at,
|
2086
2090
|
"edges": [edge.__todict__() for edge in self.edges],
|
2087
2091
|
"nodes": [node.__todict__() for node in self.nodes],
|
2088
2092
|
"regions": [region.__todict__() for region in self.regions],
|
@@ -2111,7 +2115,9 @@ class StateKernel(PClass):
|
|
2111
2115
|
def __fromdict__(d):
|
2112
2116
|
return StateKernel(
|
2113
2117
|
rng=json2rng(d["rng"]),
|
2114
|
-
|
2118
|
+
fig=Fig.__fromdict__(d["fig"]),
|
2119
|
+
num_players=d["num_players"],
|
2120
|
+
started_at=d["started_at"],
|
2115
2121
|
edges=[BiEdge.__fromdict__(edge) for edge in d["edges"]],
|
2116
2122
|
nodes=[Node.__fromdict__(n) for n in d["nodes"]],
|
2117
2123
|
regions=[Region.__fromdict__(r) for r in d["regions"]],
|
@@ -2138,13 +2144,16 @@ class StateKernel(PClass):
|
|
2138
2144
|
)
|
2139
2145
|
|
2140
2146
|
|
2141
|
-
def init_state_kernel(**kwargs):
|
2142
|
-
rng = kwargs.get('rng')
|
2143
|
-
game_config = kwargs.get('game_config')
|
2144
|
-
fig = game_config.fig
|
2147
|
+
def init_state_kernel(fig, num_players, started_at, **kwargs):
|
2145
2148
|
board_config = fig.board_config
|
2146
|
-
|
2147
|
-
|
2149
|
+
rng = kwargs.get('rng')
|
2150
|
+
nodes = kwargs.get('nodes', get_nodes(board_config))
|
2151
|
+
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(nodes)}
|
2152
|
+
edges = get_edges(rng, board_config, nodeuuid2idx)
|
2153
|
+
segments = kwargs.get('segments', get_segments(board_config))
|
2154
|
+
goals = board_config.goals
|
2155
|
+
regions = kwargs.get('regions', [])
|
2156
|
+
|
2148
2157
|
idx2pathrecord = []
|
2149
2158
|
edgeuuid2idx = {edge.uuid: idx for idx, edge in enumerate(edges)}
|
2150
2159
|
for edge in edges:
|
@@ -2153,7 +2162,7 @@ def init_state_kernel(**kwargs):
|
|
2153
2162
|
pieceuuid2piece = {}
|
2154
2163
|
for piece_template in board_config.piece_templates:
|
2155
2164
|
if piece_template.has_player:
|
2156
|
-
for player_idx in range(
|
2165
|
+
for player_idx in range(num_players):
|
2157
2166
|
pieces = generate_pieces(piece_template, player_idx)
|
2158
2167
|
for piece in pieces:
|
2159
2168
|
pieceuuid2piece[piece.uuid] = piece
|
@@ -2166,6 +2175,18 @@ def init_state_kernel(**kwargs):
|
|
2166
2175
|
carduuid2card[card.uuid] = card
|
2167
2176
|
carduuid2deckidx[card.uuid] = dek.idx
|
2168
2177
|
|
2178
|
+
starting_piles = []
|
2179
|
+
for piece_template in board_config.piece_templates:
|
2180
|
+
if piece_template.has_player:
|
2181
|
+
for player_idx in range(num_players):
|
2182
|
+
pieces = generate_pieces(piece_template, player_idx)
|
2183
|
+
pile = Pile(
|
2184
|
+
player_idx=player_idx,
|
2185
|
+
num_pieces=piece_template.quantity,
|
2186
|
+
pieces=[piece.uuid for piece in pieces],
|
2187
|
+
)
|
2188
|
+
starting_piles.append(pile)
|
2189
|
+
|
2169
2190
|
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
|
2170
2191
|
edges = get_edges(rng, board_config, nodeuuid2idx)
|
2171
2192
|
edgetuple2uuid = {}
|
@@ -2175,27 +2196,45 @@ def init_state_kernel(**kwargs):
|
|
2175
2196
|
edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
|
2176
2197
|
edgetuple2uuid[edge_tuple] = edge.uuid
|
2177
2198
|
|
2178
|
-
bonuses =
|
2199
|
+
bonuses = board_config.bonuses
|
2179
2200
|
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2180
2201
|
|
2181
|
-
player_graphs_3 = calc_player_graphs3(nodes, edges, pieceuuid2piece,
|
2202
|
+
player_graphs_3 = calc_player_graphs3(nodes, edges, pieceuuid2piece, num_players)
|
2182
2203
|
|
2183
|
-
segments = kwargs.get('segments', [])
|
2184
2204
|
|
2185
2205
|
uuid2segmentrecord = {segment.uuid: init_segment_record(segment) for segment in segments}
|
2186
2206
|
uuid2edgerecord = {edge.uuid: init_biedge_record(edge) for edge in edges}
|
2187
2207
|
|
2208
|
+
starting_decks = []
|
2209
|
+
for dek in board_config.deks:
|
2210
|
+
cards = generate_cards(dek)
|
2211
|
+
deck_obj = Deck(
|
2212
|
+
uuid=dek.uuid,
|
2213
|
+
idx=dek.idx,
|
2214
|
+
units=[],
|
2215
|
+
faceup_spots=[],
|
2216
|
+
discard=[],
|
2217
|
+
facedown_stack=[card.uuid for card in cards],
|
2218
|
+
)
|
2219
|
+
starting_decks.append(deck_obj)
|
2220
|
+
|
2221
|
+
default_players = [
|
2222
|
+
Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(num_players)
|
2223
|
+
]
|
2224
|
+
|
2188
2225
|
return StateKernel(
|
2226
|
+
decks=kwargs.get('decks', starting_decks),
|
2227
|
+
piles=kwargs.get('piles', starting_piles),
|
2228
|
+
players=kwargs.get('players', default_players),
|
2229
|
+
player_idxs=kwargs.get('player_idxs', list(range(num_players))),
|
2230
|
+
history=kwargs.get('history', []),
|
2231
|
+
fig=fig,
|
2232
|
+
num_players=num_players,
|
2233
|
+
started_at=started_at,
|
2189
2234
|
rng=rng,
|
2190
|
-
game_config=game_config,
|
2191
2235
|
edges=edges,
|
2192
|
-
nodes=
|
2193
|
-
regions=
|
2194
|
-
decks=kwargs.get('decks', []),
|
2195
|
-
piles=kwargs.get('piles', []),
|
2196
|
-
players=kwargs.get('players'),
|
2197
|
-
player_idxs=kwargs.get('player_idxs'),
|
2198
|
-
history=kwargs.get('history', []),
|
2236
|
+
nodes=nodes,
|
2237
|
+
regions=regions,
|
2199
2238
|
uuid2edgerecord=uuid2edgerecord,
|
2200
2239
|
uuid2segmentrecord=uuid2segmentrecord,
|
2201
2240
|
idx2pathrecord=idx2pathrecord,
|
@@ -2206,9 +2245,9 @@ def init_state_kernel(**kwargs):
|
|
2206
2245
|
nodeuuid2idx=nodeuuid2idx,
|
2207
2246
|
carduuid2deckidx=carduuid2deckidx,
|
2208
2247
|
bonusuuid2bonusidx=bonusuuid2bonusidx,
|
2209
|
-
starting_decks=
|
2210
|
-
starting_piles=
|
2211
|
-
goals=
|
2248
|
+
starting_decks=starting_decks,
|
2249
|
+
starting_piles=starting_piles,
|
2250
|
+
goals=goals,
|
2212
2251
|
player_graphs_3=player_graphs_3,
|
2213
2252
|
)
|
2214
2253
|
|
@@ -2702,102 +2741,18 @@ def getsettingvalue(f, setting_name):
|
|
2702
2741
|
|
2703
2742
|
@dispatch(State, str)
|
2704
2743
|
def getsettingvalue(s, setting_name):
|
2705
|
-
return getsettingvalue(s.kernel.
|
2744
|
+
return getsettingvalue(s.kernel.fig, setting_name)
|
2706
2745
|
|
2707
2746
|
|
2708
2747
|
@dispatch(GameConfig)
|
2709
2748
|
def getinitialstate(game_config):
|
2710
|
-
rng = getrng(game_config.seed)
|
2711
|
-
board_config = game_config.fig.board_config
|
2712
|
-
nodes = get_nodes(board_config)
|
2713
|
-
|
2714
|
-
piles = []
|
2715
|
-
for piece_template in board_config.piece_templates:
|
2716
|
-
if piece_template.has_player:
|
2717
|
-
for player_idx in range(game_config.num_players):
|
2718
|
-
pieces = generate_pieces(piece_template, player_idx)
|
2719
|
-
pile = Pile(
|
2720
|
-
player_idx=player_idx,
|
2721
|
-
num_pieces=piece_template.quantity,
|
2722
|
-
pieces=[piece.uuid for piece in pieces],
|
2723
|
-
)
|
2724
|
-
piles.append(pile)
|
2725
|
-
|
2726
|
-
decks = []
|
2727
|
-
for dek in board_config.deks:
|
2728
|
-
cards = generate_cards(dek)
|
2729
|
-
deck_obj = Deck(
|
2730
|
-
uuid=dek.uuid,
|
2731
|
-
idx=dek.idx,
|
2732
|
-
units=[],
|
2733
|
-
faceup_spots=[],
|
2734
|
-
discard=[],
|
2735
|
-
facedown_stack=[card.uuid for card in cards],
|
2736
|
-
)
|
2737
|
-
decks.append(deck_obj)
|
2738
|
-
|
2739
|
-
# bonuses = game_config.fig.board_config.bonuses
|
2740
|
-
# bonus_statuses = [
|
2741
|
-
# BonusStatus(
|
2742
|
-
# bonus_uuid=bonus.uuid,
|
2743
|
-
# winners=[],
|
2744
|
-
# player_statuses=[
|
2745
|
-
# BonusPlayerStatus(
|
2746
|
-
# player_idx=player_idx,
|
2747
|
-
# score=0,
|
2748
|
-
# longest_trail=None,
|
2749
|
-
# )
|
2750
|
-
# for player_idx in range(game_config.num_players)
|
2751
|
-
# ]
|
2752
|
-
# )
|
2753
|
-
# for bonus in bonuses
|
2754
|
-
# ]
|
2755
|
-
|
2756
|
-
# state = State(
|
2757
|
-
# bonus_statuses=bonus_statuses,
|
2758
|
-
# history=[],
|
2759
|
-
# player_scores=[PlayerScore2(public_items=[], private_items=[]) for _ in range(game_config.num_players)],
|
2760
|
-
# player_graphs=[
|
2761
|
-
# PlayerGraph(
|
2762
|
-
# player_idx=player_idx,
|
2763
|
-
# neighbors=[[] for _ in range(len(nodes))]
|
2764
|
-
# ) for player_idx in range(game_config.num_players)
|
2765
|
-
# ],
|
2766
|
-
# nodes = nodes,
|
2767
|
-
# edges = edges,
|
2768
|
-
# regions = get_regions(board_config),
|
2769
|
-
# legal_actions_3=[],
|
2770
|
-
# piles=piles,
|
2771
|
-
# players=[Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(game_config.num_players)],
|
2772
|
-
# player_idxs=list(range(game_config.num_players)),
|
2773
|
-
# decks=decks,
|
2774
|
-
# rng=rng,
|
2775
|
-
# last_to_play=None,
|
2776
|
-
# winners=[],
|
2777
|
-
# )
|
2778
|
-
|
2779
|
-
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
|
2780
|
-
edges = get_edges(rng, board_config, nodeuuid2idx)
|
2781
|
-
|
2782
2749
|
kernel = init_state_kernel(
|
2783
|
-
|
2784
|
-
game_config
|
2785
|
-
|
2786
|
-
|
2787
|
-
nodes=nodes,
|
2788
|
-
decks=decks,
|
2789
|
-
piles=piles,
|
2790
|
-
players=[Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(game_config.num_players)],
|
2791
|
-
player_idxs=list(range(game_config.num_players)),
|
2792
|
-
history=[],
|
2793
|
-
player_scores=[PlayerScore2(public_items=[], private_items=[]) for _ in range(game_config.num_players)],
|
2794
|
-
starting_decks=[Deck.__fromdict__(x.__todict__()) for x in decks],
|
2795
|
-
starting_piles=[Pile.__fromdict__(x.__todict__()) for x in piles],
|
2796
|
-
goals=board_config.goals,
|
2750
|
+
game_config.fig,
|
2751
|
+
game_config.num_players,
|
2752
|
+
game_config.started_at,
|
2753
|
+
rng=getrng(game_config.seed),
|
2797
2754
|
)
|
2798
|
-
|
2799
2755
|
kernel = run_kernel_hooks(kernel, INITIALIZATION_HOOKS, True)
|
2800
|
-
|
2801
2756
|
return init_memoized_state(kernel)
|
2802
2757
|
|
2803
2758
|
|
@@ -2822,7 +2777,7 @@ def memoize_state(state):
|
|
2822
2777
|
def calc_bonus_statuses3(kernel):
|
2823
2778
|
bonus_statuses = [
|
2824
2779
|
calc_bonus_status3(kernel, bonus)
|
2825
|
-
for bonus in kernel.
|
2780
|
+
for bonus in kernel.fig.board_config.bonuses
|
2826
2781
|
]
|
2827
2782
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
2828
2783
|
return bonus_statuses
|
@@ -2898,7 +2853,7 @@ def score_public_items3(state, player_idx):
|
|
2898
2853
|
)
|
2899
2854
|
for bonus_status in state.bonus_statuses_3:
|
2900
2855
|
bonus_idx = state.kernel.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2901
|
-
bonus = state.kernel.
|
2856
|
+
bonus = state.kernel.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2902
2857
|
if bonus:
|
2903
2858
|
if player_idx in bonus_status.winners:
|
2904
2859
|
items.append(
|
@@ -2934,7 +2889,7 @@ def score_public_items(state, player_idx):
|
|
2934
2889
|
)
|
2935
2890
|
for bonus_status in state.bonus_statuses:
|
2936
2891
|
bonus_idx = state.kernel.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2937
|
-
bonus = state.kernel.
|
2892
|
+
bonus = state.kernel.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2938
2893
|
if bonus:
|
2939
2894
|
if player_idx in bonus_status.winners:
|
2940
2895
|
items.append(
|
@@ -3097,7 +3052,7 @@ def get_bonus_status_longest_trail3(kernel, bonus):
|
|
3097
3052
|
winners = []
|
3098
3053
|
player_longest_trail_lens = []
|
3099
3054
|
|
3100
|
-
for player_idx in range(kernel.
|
3055
|
+
for player_idx in range(kernel.num_players):
|
3101
3056
|
trail_length = get_longest_path_length3(kernel, player_idx)
|
3102
3057
|
player_longest_trail_lens.append(trail_length)
|
3103
3058
|
if trail_length > longest_trail:
|
@@ -3129,7 +3084,7 @@ def get_bonus_status_longest_trail(state, bonus):
|
|
3129
3084
|
winners = []
|
3130
3085
|
player_longest_trail_lens = []
|
3131
3086
|
|
3132
|
-
for player_idx in range(state.kernel.
|
3087
|
+
for player_idx in range(state.kernel.num_players):
|
3133
3088
|
trail_length = get_longest_path_length(state, player_idx)
|
3134
3089
|
player_longest_trail_lens.append(trail_length)
|
3135
3090
|
if trail_length > longest_trail:
|
@@ -3159,7 +3114,7 @@ def get_bonus_status_longest_trail(state, bonus):
|
|
3159
3114
|
def handle_bonus_statuses(state):
|
3160
3115
|
bonus_statuses = [
|
3161
3116
|
calc_bonus_status(state, bonus)
|
3162
|
-
for bonus in state.kernel.
|
3117
|
+
for bonus in state.kernel.fig.board_config.bonuses
|
3163
3118
|
]
|
3164
3119
|
# Remove all None bonus statuses
|
3165
3120
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
@@ -3522,7 +3477,7 @@ def find_player_with_longest_path(kernel):
|
|
3522
3477
|
longest_path_player_idx = None
|
3523
3478
|
longest_path_length = 0
|
3524
3479
|
|
3525
|
-
for player_idx in range(kernel.
|
3480
|
+
for player_idx in range(kernel.num_players):
|
3526
3481
|
path_length = get_longest_path_length(kernel, player_idx)
|
3527
3482
|
if path_length > longest_path_length:
|
3528
3483
|
longest_path_length = path_length
|
@@ -3749,18 +3704,17 @@ def calc_player_graph3(nodes, edges, pieceuuid2piece, player_idx):
|
|
3749
3704
|
|
3750
3705
|
|
3751
3706
|
def calc_player_graphs(state):
|
3752
|
-
game_config = state.kernel.game_config
|
3753
3707
|
return [
|
3754
3708
|
calc_player_graph(state, player_idx)
|
3755
|
-
for player_idx in range(
|
3709
|
+
for player_idx in range(state.kernel.num_players)
|
3756
3710
|
]
|
3757
3711
|
|
3758
3712
|
|
3759
|
-
@dispatch(list, list, dict,
|
3760
|
-
def calc_player_graphs3(nodes, edges, pieceuuid2piece,
|
3713
|
+
@dispatch(list, list, dict, int)
|
3714
|
+
def calc_player_graphs3(nodes, edges, pieceuuid2piece, num_players):
|
3761
3715
|
return [
|
3762
3716
|
calc_player_graph3(nodes, edges, pieceuuid2piece, player_idx)
|
3763
|
-
for player_idx in range(
|
3717
|
+
for player_idx in range(num_players)
|
3764
3718
|
]
|
3765
3719
|
|
3766
3720
|
|
@@ -4096,7 +4050,7 @@ def is_path_open_to_player(state_kernel, path_idx, player_idx):
|
|
4096
4050
|
player_idxs_on_edge = get_player_idxs_on_edge(state_kernel, edge_record)
|
4097
4051
|
|
4098
4052
|
# Check if edge is too crowded for the number of players
|
4099
|
-
if state_kernel.
|
4053
|
+
if state_kernel.num_players <= 3:
|
4100
4054
|
if len(player_idxs_on_edge) > 0:
|
4101
4055
|
return False
|
4102
4056
|
|
@@ -4569,7 +4523,7 @@ def getpublictoplay(s):
|
|
4569
4523
|
def get_max_allotted_times(s):
|
4570
4524
|
return [
|
4571
4525
|
get_player_max_allotted_time(s, player_idx)
|
4572
|
-
for player_idx in range(s.kernel.
|
4526
|
+
for player_idx in range(s.kernel.num_players)
|
4573
4527
|
]
|
4574
4528
|
|
4575
4529
|
|
@@ -4595,7 +4549,7 @@ def get_deadline(s, max_allotted_time):
|
|
4595
4549
|
since_action_idx = max_allotted_time.since_action_idx
|
4596
4550
|
if since_action_idx == -1:
|
4597
4551
|
allotted_since = datetime.strptime(
|
4598
|
-
s.kernel.
|
4552
|
+
s.kernel.started_at,
|
4599
4553
|
"%Y-%m-%d %H:%M:%S"
|
4600
4554
|
)
|
4601
4555
|
else:
|
@@ -4614,7 +4568,7 @@ def get_deadline(s, max_allotted_time):
|
|
4614
4568
|
@dispatch(State)
|
4615
4569
|
def get_deadlines(s):
|
4616
4570
|
if isterminal(s):
|
4617
|
-
return [None for _ in range(s.kernel.
|
4571
|
+
return [None for _ in range(s.kernel.num_players)]
|
4618
4572
|
return [
|
4619
4573
|
get_deadline(s, max_allotted_time)
|
4620
4574
|
for max_allotted_time in get_max_allotted_times(s)
|
@@ -4676,21 +4630,16 @@ def imagine_decks(public_state, private_state):
|
|
4676
4630
|
|
4677
4631
|
|
4678
4632
|
def imagine_state(public_state, private_state):
|
4679
|
-
game_config = public_state.game_config
|
4680
4633
|
imagined_kernel = init_state_kernel(
|
4634
|
+
fig=public_state.fig,
|
4681
4635
|
rng=random.Random(),
|
4682
|
-
game_config=game_config,
|
4683
4636
|
edges=public_state.edges,
|
4684
4637
|
nodes=public_state.nodes,
|
4685
4638
|
piles=public_state.piles,
|
4639
|
+
player_idxs=public_state.player_idxs,
|
4686
4640
|
decks=imagine_decks(public_state, private_state),
|
4687
4641
|
players=imagine_players(public_state, private_state),
|
4688
|
-
player_idxs=public_state.player_idxs,
|
4689
4642
|
history=imagine_history(public_state, private_state),
|
4690
|
-
player_scores=imagine_player_scores(public_state, private_state),
|
4691
|
-
starting_decks=[Deck.__fromdict__(x.__todict__()) for x in decks],
|
4692
|
-
starting_piles=[Pile.__fromdict__(x.__todict__()) for x in public_state.piles],
|
4693
|
-
goals=game_config.fig.board_config.goals,
|
4694
4643
|
)
|
4695
4644
|
return init_memoized_state(imagined_kernel)
|
4696
4645
|
|
@@ -4749,7 +4698,7 @@ def getpublicstate(s):
|
|
4749
4698
|
|
4750
4699
|
return PublicState(
|
4751
4700
|
deadlines=get_deadlines(s),
|
4752
|
-
game_started_at=s.kernel.
|
4701
|
+
game_started_at=s.kernel.started_at,
|
4753
4702
|
allotted_times=get_max_allotted_times(s),
|
4754
4703
|
all_pieces=list(s.kernel.pieceuuid2piece.values()),
|
4755
4704
|
to_play_2=getpublictoplay(s),
|
@@ -4787,10 +4736,10 @@ def getpublicdeck(s, d):
|
|
4787
4736
|
|
4788
4737
|
@dispatch(State, Player)
|
4789
4738
|
def getpublicplayer(s, p):
|
4790
|
-
deck_counts = [0 for _ in s.kernel.
|
4739
|
+
deck_counts = [0 for _ in s.kernel.fig.board_config.deks]
|
4791
4740
|
for card in p.cards:
|
4792
4741
|
deck_counts[s.kernel.carduuid2card[card].deck_idx] += 1
|
4793
|
-
piece_template_counts = [0 for _ in s.kernel.
|
4742
|
+
piece_template_counts = [0 for _ in s.kernel.fig.board_config.piece_templates]
|
4794
4743
|
for piece_uuid in p.pieces:
|
4795
4744
|
piece_template_counts[s.kernel.pieceuuid2piece[piece_uuid].piece_template_idx] += 1
|
4796
4745
|
return PublicPlayer(
|
@@ -4834,10 +4783,10 @@ def getpublicscore(s, player_idx):
|
|
4834
4783
|
path_lens = getplayerpathlens(s, player_idx)
|
4835
4784
|
if not path_lens:
|
4836
4785
|
return 0
|
4837
|
-
addends.append(sum(s.kernel.
|
4786
|
+
addends.append(sum(s.kernel.fig.path_scores[len] for len in path_lens))
|
4838
4787
|
|
4839
4788
|
if getsettingvalue(s, 'cluster_scoring'):
|
4840
|
-
clusters = s.kernel.
|
4789
|
+
clusters = s.kernel.fig.board_config.clusters
|
4841
4790
|
uuid2cluster = {x.uuid: x for x in clusters}
|
4842
4791
|
completed_clusters = s.player_hands[player_idx].completed_clusters
|
4843
4792
|
cluster_scores = [uuid2cluster[cluster_uuid].score for cluster_uuid in completed_clusters]
|
@@ -4860,7 +4809,7 @@ def getplayerpathlens(s, player_idx):
|
|
4860
4809
|
# Implementing the following Julia function:
|
4861
4810
|
# getpathlens(s::State) = length.(getfield.(getfield.(s.fig.board_config.board_paths, :path), :segments))
|
4862
4811
|
def getpathlens(s):
|
4863
|
-
return [len(p.path.segments) for p in s.kernel.
|
4812
|
+
return [len(p.path.segments) for p in s.kernel.fig.board_config.board_paths]
|
4864
4813
|
|
4865
4814
|
# Implementing the following Julia function:
|
4866
4815
|
# function getplayerpathidxs(s::State, player_idx::Int)
|
@@ -4900,7 +4849,7 @@ def getactiontype(action_name):
|
|
4900
4849
|
|
4901
4850
|
|
4902
4851
|
# Function implements the following Julia function:
|
4903
|
-
# getlastplayeridxplus1(s) = mod1(getlastaction(s).player_idx + 1, s.kernel.
|
4852
|
+
# getlastplayeridxplus1(s) = mod1(getlastaction(s).player_idx + 1, s.kernel.num_players)
|
4904
4853
|
def getlastplayeridxplus1(s):
|
4905
4854
|
pass
|
4906
4855
|
|
@@ -5073,7 +5022,7 @@ def combinations(a, n=None):
|
|
5073
5022
|
def getpotentialpathidxs(s, player_num):
|
5074
5023
|
num_pieces = s.player_hands[player_num-1].num_pieces
|
5075
5024
|
return list(
|
5076
|
-
set(getpathidxs(s.kernel.
|
5025
|
+
set(getpathidxs(s.kernel.fig, num_pieces)) - set(getunavailablepathidxs(s, player_num))
|
5077
5026
|
)
|
5078
5027
|
# return list(set(getpathidxs(s.fig, num_pieces)) - set(getunavailablepaths(s, player_num)))
|
5079
5028
|
|
@@ -5137,16 +5086,16 @@ def getunavailablepathidxs(s, player_idx):
|
|
5137
5086
|
link2paths = {}
|
5138
5087
|
path2link = {}
|
5139
5088
|
|
5140
|
-
for board_path in s.kernel.
|
5089
|
+
for board_path in s.kernel.fig.board_config.board_paths:
|
5141
5090
|
link_idx = board_path.link_num - 1
|
5142
5091
|
if link_idx not in link2paths:
|
5143
5092
|
link2paths[link_idx] = []
|
5144
5093
|
link2paths[link_idx].append(board_path.num-1)
|
5145
5094
|
path2link[board_path.num-1] = link_idx
|
5146
5095
|
|
5147
|
-
multipath_links = [(board_link.num-1) for board_link in getmultipathlinks(s.kernel.
|
5096
|
+
multipath_links = [(board_link.num-1) for board_link in getmultipathlinks(s.kernel.fig)]
|
5148
5097
|
|
5149
|
-
if s.kernel.
|
5098
|
+
if s.kernel.num_players < 4:
|
5150
5099
|
blocking_hands = s.player_hands
|
5151
5100
|
else:
|
5152
5101
|
blocking_hands = [s.player_hands[player_idx]]
|
@@ -5652,7 +5601,7 @@ def getqproxy0(ps, a, td):
|
|
5652
5601
|
return rewards
|
5653
5602
|
v_proxies = [
|
5654
5603
|
getvproxy0(getprivatestate(next_s, i))
|
5655
|
-
for i in range(next_s.kernel.
|
5604
|
+
for i in range(next_s.kernel.num_players)
|
5656
5605
|
]
|
5657
5606
|
q_proxies = [
|
5658
5607
|
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=slh5o58-rqAxEznKOvrkh4L0F6VLlHEnuValIVOXGlA,198791
|
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.2083.dist-info/METADATA,sha256=EMIRl_Ci0n9s0m0pVHz4TiJcp4ODBQjCsi3otnaoPms,188
|
7
|
+
graph_games_proto-0.3.2083.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.2083.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.2083.dist-info/RECORD,,
|
File without changes
|
File without changes
|