graph-games-proto 0.3.1953__py3-none-any.whl → 0.3.1964__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 +22 -26
- {graph_games_proto-0.3.1953.dist-info → graph_games_proto-0.3.1964.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1953.dist-info → graph_games_proto-0.3.1964.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1953.dist-info → graph_games_proto-0.3.1964.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1953.dist-info → graph_games_proto-0.3.1964.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -2060,7 +2060,6 @@ class State(PClass):
|
|
2060
2060
|
players = field(type=list) # List[Player]
|
2061
2061
|
player_idxs = field(type=list) # List[int]
|
2062
2062
|
decks = field(type=list) # List[Deck]
|
2063
|
-
game_config = field(type=GameConfig)
|
2064
2063
|
rng = field(type=random.Random)
|
2065
2064
|
last_to_play = field(type=(int, type(None)), initial=None)
|
2066
2065
|
winners = field(type=list) # List[int]
|
@@ -2086,7 +2085,6 @@ class State(PClass):
|
|
2086
2085
|
"players": [player.__todict__() for player in self.players],
|
2087
2086
|
"player_idxs": self.player_idxs,
|
2088
2087
|
"decks": [deck.__todict__() for deck in self.decks],
|
2089
|
-
"game_config": self.game_config.__todict__(),
|
2090
2088
|
"rng": rng2json(self.rng),
|
2091
2089
|
"last_to_play": self.last_to_play,
|
2092
2090
|
"winners": self.winners,
|
@@ -2114,7 +2112,6 @@ class State(PClass):
|
|
2114
2112
|
players=[Player.__fromdict__(p) for p in d["players"]],
|
2115
2113
|
player_idxs=d["player_idxs"],
|
2116
2114
|
decks=[Deck.__fromdict__(deck) for deck in d["decks"]],
|
2117
|
-
game_config=GameConfig.__fromdict__(d["game_config"]),
|
2118
2115
|
rng=json2rng(d["rng"]),
|
2119
2116
|
last_to_play=d.get("last_to_play"),
|
2120
2117
|
winners=d["winners"],
|
@@ -2669,7 +2666,6 @@ def getinitialstate(game_config):
|
|
2669
2666
|
players=[Player(idx=idx, pieces=[], cards=[], discard_tray=[]) for idx in range(game_config.num_players)],
|
2670
2667
|
player_idxs=list(range(game_config.num_players)),
|
2671
2668
|
decks=decks,
|
2672
|
-
game_config=game_config,
|
2673
2669
|
rng=rng,
|
2674
2670
|
last_to_play=None,
|
2675
2671
|
winners=[],
|
@@ -2679,7 +2675,7 @@ def getinitialstate(game_config):
|
|
2679
2675
|
|
2680
2676
|
kernel = init_state_kernel(
|
2681
2677
|
rng=rng,
|
2682
|
-
game_config=
|
2678
|
+
game_config=game_config,
|
2683
2679
|
edges=state.edges,
|
2684
2680
|
decks=state.decks,
|
2685
2681
|
piles=state.piles,
|
@@ -2722,14 +2718,14 @@ def run_state_action_hooks(state, action, hooks, log=False):
|
|
2722
2718
|
)
|
2723
2719
|
|
2724
2720
|
|
2725
|
-
def score_public_items(
|
2721
|
+
def score_public_items(state, player_idx):
|
2726
2722
|
items = []
|
2727
|
-
for edge in
|
2723
|
+
for edge in state.edges:
|
2728
2724
|
for path in edge.paths:
|
2729
2725
|
if len(path.segments) > 0:
|
2730
2726
|
first_segment = path.segments[0]
|
2731
2727
|
if first_segment.pieces and len(first_segment.pieces) > 0:
|
2732
|
-
first_piece =
|
2728
|
+
first_piece = state.pieceuuid2piece[first_segment.pieces[0]]
|
2733
2729
|
if first_piece.player_idx == player_idx:
|
2734
2730
|
items.append(
|
2735
2731
|
ScoreItem2(
|
@@ -2742,9 +2738,9 @@ def score_public_items(game, player_idx):
|
|
2742
2738
|
description="Player {} owns edge {}".format(player_idx, edge.uuid),
|
2743
2739
|
)
|
2744
2740
|
)
|
2745
|
-
for bonus_status in
|
2746
|
-
bonus_idx =
|
2747
|
-
bonus =
|
2741
|
+
for bonus_status in state.bonus_statuses:
|
2742
|
+
bonus_idx = state.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2743
|
+
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2748
2744
|
if bonus:
|
2749
2745
|
if player_idx in bonus_status.winners:
|
2750
2746
|
items.append(
|
@@ -2836,13 +2832,13 @@ def calc_bonus_status(game, bonus):
|
|
2836
2832
|
return None
|
2837
2833
|
|
2838
2834
|
|
2839
|
-
def get_bonus_status_longest_trail(
|
2835
|
+
def get_bonus_status_longest_trail(state, bonus):
|
2840
2836
|
longest_trail = 0
|
2841
2837
|
winners = []
|
2842
2838
|
player_longest_trail_lens = []
|
2843
2839
|
|
2844
|
-
for player_idx in range(
|
2845
|
-
trail_length = get_longest_path_length(
|
2840
|
+
for player_idx in range(state.kernel.game_config.num_players):
|
2841
|
+
trail_length = get_longest_path_length(state, player_idx)
|
2846
2842
|
player_longest_trail_lens.append(trail_length)
|
2847
2843
|
if trail_length > longest_trail:
|
2848
2844
|
longest_trail = trail_length
|
@@ -2868,14 +2864,14 @@ def get_bonus_status_longest_trail(game, bonus):
|
|
2868
2864
|
)
|
2869
2865
|
|
2870
2866
|
|
2871
|
-
def handle_bonus_statuses(
|
2867
|
+
def handle_bonus_statuses(state):
|
2872
2868
|
bonus_statuses = [
|
2873
|
-
calc_bonus_status(
|
2874
|
-
for bonus in
|
2869
|
+
calc_bonus_status(state, bonus)
|
2870
|
+
for bonus in state.kernel.game_config.fig.board_config.bonuses
|
2875
2871
|
]
|
2876
2872
|
# Remove all None bonus statuses
|
2877
2873
|
bonus_statuses = [bs for bs in bonus_statuses if bs is not None]
|
2878
|
-
return
|
2874
|
+
return state.set(bonus_statuses=bonus_statuses)
|
2879
2875
|
|
2880
2876
|
|
2881
2877
|
def default_handle_scoring(game):
|
@@ -3176,12 +3172,12 @@ def random_player_graph_walk(game, player_idx):
|
|
3176
3172
|
return walk([random_start_node_idx], set([]))
|
3177
3173
|
|
3178
3174
|
|
3179
|
-
def find_player_with_longest_path(
|
3175
|
+
def find_player_with_longest_path(state):
|
3180
3176
|
longest_path_player_idx = None
|
3181
3177
|
longest_path_length = 0
|
3182
3178
|
|
3183
|
-
for player_idx in range(
|
3184
|
-
path_length = get_longest_path_length(
|
3179
|
+
for player_idx in range(state.kernel.game_config.num_players):
|
3180
|
+
path_length = get_longest_path_length(state, player_idx)
|
3185
3181
|
if path_length > longest_path_length:
|
3186
3182
|
longest_path_length = path_length
|
3187
3183
|
longest_path_player_idx = player_idx
|
@@ -3189,7 +3185,7 @@ def find_player_with_longest_path(game):
|
|
3189
3185
|
if longest_path_player_idx is None:
|
3190
3186
|
return None
|
3191
3187
|
|
3192
|
-
return
|
3188
|
+
return state.players[longest_path_player_idx]
|
3193
3189
|
|
3194
3190
|
|
3195
3191
|
@dispatch(State, set)
|
@@ -3340,10 +3336,10 @@ def calc_player_graph(game, player_idx):
|
|
3340
3336
|
)
|
3341
3337
|
|
3342
3338
|
|
3343
|
-
def calc_player_graphs(
|
3344
|
-
game_config =
|
3339
|
+
def calc_player_graphs(state):
|
3340
|
+
game_config = state.kernel.game_config
|
3345
3341
|
return [
|
3346
|
-
calc_player_graph(
|
3342
|
+
calc_player_graph(state, player_idx)
|
3347
3343
|
for player_idx in range(game_config.num_players)
|
3348
3344
|
]
|
3349
3345
|
|
@@ -4094,7 +4090,7 @@ def getnextstate2(s, a, log=False):
|
|
4094
4090
|
|
4095
4091
|
state_kernel = init_state_kernel(
|
4096
4092
|
rng=s.rng,
|
4097
|
-
game_config=s.game_config,
|
4093
|
+
game_config=s.kernel.game_config,
|
4098
4094
|
edges=s.edges,
|
4099
4095
|
decks=s.decks,
|
4100
4096
|
piles=s.piles,
|
@@ -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=NBy2Ugs9XrIkerSWX6c9yshGiWJKg3P6KoehZa1iIOE,181978
|
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.1964.dist-info/METADATA,sha256=B3PirCx5a9Pcc2dG8qv9uT3ErTjWCEE0oIqs7eVk2QI,188
|
7
|
+
graph_games_proto-0.3.1964.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1964.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1964.dist-info/RECORD,,
|
File without changes
|
File without changes
|