graph-games-proto 0.3.1981__py3-none-any.whl → 0.3.1986__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 +25 -20
- {graph_games_proto-0.3.1981.dist-info → graph_games_proto-0.3.1986.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1981.dist-info → graph_games_proto-0.3.1986.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1981.dist-info → graph_games_proto-0.3.1986.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1981.dist-info → graph_games_proto-0.3.1986.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -1949,6 +1949,9 @@ class StateKernel(PClass):
|
|
1949
1949
|
edgetuple2uuid = field(type=dict) # Dict[Tuple[int, int], str]
|
1950
1950
|
nodeuuid2idx = field(type=dict) # Dict[str, int]
|
1951
1951
|
carduuid2deckidx = field(type=dict) # Dict[str, int]
|
1952
|
+
bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
|
1953
|
+
starting_decks = field(type=list) # List[Deck]
|
1954
|
+
starting_piles = field(type=list) # List[Pile]
|
1952
1955
|
def __todict__(self):
|
1953
1956
|
return {
|
1954
1957
|
"rng": rng2json(self.rng),
|
@@ -1967,6 +1970,9 @@ class StateKernel(PClass):
|
|
1967
1970
|
"edgetuple2uuid": [{"k": list(k), "v": v} for k, v in self.edgetuple2uuid.items()],
|
1968
1971
|
"nodeuuid2idx": self.nodeuuid2idx,
|
1969
1972
|
"carduuid2deckidx": self.carduuid2deckidx,
|
1973
|
+
"bonusuuid2bonusidx": self.bonusuuid2bonusidx,
|
1974
|
+
"starting_decks": [deck.__todict__() for deck in self.starting_decks],
|
1975
|
+
"starting_piles": [pile.__todict__() for pile in self.starting_piles],
|
1970
1976
|
}
|
1971
1977
|
@staticmethod
|
1972
1978
|
def __fromdict__(d):
|
@@ -1987,6 +1993,9 @@ class StateKernel(PClass):
|
|
1987
1993
|
edgetuple2uuid={tuple(item["k"]): item["v"] for item in d["edgetuple2uuid"]},
|
1988
1994
|
nodeuuid2idx=d["nodeuuid2idx"],
|
1989
1995
|
carduuid2deckidx=d["carduuid2deckidx"],
|
1996
|
+
bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
|
1997
|
+
starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
|
1998
|
+
starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
|
1990
1999
|
)
|
1991
2000
|
|
1992
2001
|
|
@@ -2025,6 +2034,9 @@ def init_state_kernel(**kwargs):
|
|
2025
2034
|
node_2_idx = nodeuuid2idx[edge.node_2_uuid]
|
2026
2035
|
edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
|
2027
2036
|
edgetuple2uuid[edge_tuple] = edge.uuid
|
2037
|
+
|
2038
|
+
bonuses = game_config.fig.board_config.bonuses
|
2039
|
+
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2028
2040
|
|
2029
2041
|
return StateKernel(
|
2030
2042
|
rng=rng,
|
@@ -2043,6 +2055,9 @@ def init_state_kernel(**kwargs):
|
|
2043
2055
|
edgetuple2uuid=edgetuple2uuid,
|
2044
2056
|
nodeuuid2idx=nodeuuid2idx,
|
2045
2057
|
carduuid2deckidx=carduuid2deckidx,
|
2058
|
+
bonusuuid2bonusidx=bonusuuid2bonusidx,
|
2059
|
+
starting_decks=kwargs.get('starting_decks'),
|
2060
|
+
starting_piles=kwargs.get('starting_piles'),
|
2046
2061
|
)
|
2047
2062
|
|
2048
2063
|
|
@@ -2050,9 +2065,6 @@ class State(PClass):
|
|
2050
2065
|
kernel = field(type=StateKernel)
|
2051
2066
|
idx2path = field(type=list) # List[Path2]
|
2052
2067
|
bonus_statuses = field(type=list) # List[BonusStatus]
|
2053
|
-
bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
|
2054
|
-
starting_decks = field(type=list) # List[Deck]
|
2055
|
-
starting_piles = field(type=list)
|
2056
2068
|
history = field(type=list) # List[Action2]
|
2057
2069
|
player_scores = field(type=list) # List[PlayerScore2]
|
2058
2070
|
player_graphs = field(type=list) # List[PlayerGraph]
|
@@ -2073,9 +2085,6 @@ class State(PClass):
|
|
2073
2085
|
"kernel": self.kernel.__todict__(),
|
2074
2086
|
"idx2path": [v.__todict__() for v in self.idx2path],
|
2075
2087
|
"bonus_statuses": [status.__todict__() for status in self.bonus_statuses],
|
2076
|
-
"bonusuuid2bonusidx": self.bonusuuid2bonusidx,
|
2077
|
-
"starting_decks": [deck.__todict__() for deck in self.starting_decks],
|
2078
|
-
"starting_piles": [pile.__todict__() for pile in self.starting_piles],
|
2079
2088
|
"history": [x.__todict__() for x in self.history],
|
2080
2089
|
"player_scores": [x.__todict__() for x in self.player_scores],
|
2081
2090
|
"player_graphs": [x.__todict__() for x in self.player_graphs],
|
@@ -2098,9 +2107,6 @@ class State(PClass):
|
|
2098
2107
|
kernel=StateKernel.__fromdict__(d["kernel"]),
|
2099
2108
|
idx2path=[Path2.__fromdict__(v) for v in d["idx2path"]],
|
2100
2109
|
bonus_statuses=[BonusStatus.__fromdict__(x) for x in d["bonus_statuses"]],
|
2101
|
-
bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
|
2102
|
-
starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
|
2103
|
-
starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
|
2104
2110
|
history=[Action2.__fromdict__(x) for x in d["history"]],
|
2105
2111
|
player_scores=[PlayerScore2.__fromdict__(x) for x in d["player_scores"]],
|
2106
2112
|
player_graphs=[PlayerGraph.__fromdict__(x) for x in d["player_graphs"]],
|
@@ -2618,7 +2624,6 @@ def getinitialstate(game_config):
|
|
2618
2624
|
idx2path.append(path)
|
2619
2625
|
|
2620
2626
|
bonuses = game_config.fig.board_config.bonuses
|
2621
|
-
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2622
2627
|
bonus_statuses = [
|
2623
2628
|
BonusStatus(
|
2624
2629
|
bonus_uuid=bonus.uuid,
|
@@ -2634,17 +2639,13 @@ def getinitialstate(game_config):
|
|
2634
2639
|
)
|
2635
2640
|
for bonus in bonuses
|
2636
2641
|
]
|
2642
|
+
|
2643
|
+
starting_decks=[Deck.__fromdict__(x.__todict__()) for x in decks]
|
2644
|
+
starting_piles=[Pile.__fromdict__(x.__todict__()) for x in piles]
|
2637
2645
|
|
2638
2646
|
state = State(
|
2639
2647
|
idx2path=idx2path,
|
2640
2648
|
bonus_statuses=bonus_statuses,
|
2641
|
-
bonusuuid2bonusidx=bonusuuid2bonusidx,
|
2642
|
-
starting_decks=[
|
2643
|
-
Deck.__fromdict__(x.__todict__()) for x in decks
|
2644
|
-
],
|
2645
|
-
starting_piles=[
|
2646
|
-
Pile.__fromdict__(x.__todict__()) for x in piles
|
2647
|
-
],
|
2648
2649
|
history=[],
|
2649
2650
|
player_scores=[PlayerScore2(public_items=[], private_items=[]) for _ in range(game_config.num_players)],
|
2650
2651
|
player_graphs=[
|
@@ -2679,6 +2680,8 @@ def getinitialstate(game_config):
|
|
2679
2680
|
player_idxs=state.player_idxs,
|
2680
2681
|
history=state.history,
|
2681
2682
|
player_scores=state.player_scores,
|
2683
|
+
starting_decks=starting_decks,
|
2684
|
+
starting_piles=starting_piles,
|
2682
2685
|
)
|
2683
2686
|
|
2684
2687
|
state = state.set(kernel=kernel)
|
@@ -2736,7 +2739,7 @@ def score_public_items(state, player_idx):
|
|
2736
2739
|
)
|
2737
2740
|
)
|
2738
2741
|
for bonus_status in state.bonus_statuses:
|
2739
|
-
bonus_idx = state.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2742
|
+
bonus_idx = state.kernel.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2740
2743
|
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2741
2744
|
if bonus:
|
2742
2745
|
if player_idx in bonus_status.winners:
|
@@ -4099,6 +4102,8 @@ def getnextstate2(s, a, log=False):
|
|
4099
4102
|
player_idxs=s.player_idxs,
|
4100
4103
|
history=s.history,
|
4101
4104
|
player_scores=s.player_scores,
|
4105
|
+
starting_decks=s.kernel.starting_decks,
|
4106
|
+
starting_piles=s.kernel.starting_piles,
|
4102
4107
|
)
|
4103
4108
|
s = s.set(legal_actions_3=calc_legal_actions3(state_kernel))
|
4104
4109
|
|
@@ -4270,8 +4275,8 @@ def getpublicstate(s):
|
|
4270
4275
|
all_pieces=list(s.kernel.pieceuuid2piece.values()),
|
4271
4276
|
to_play_2=getpublictoplay(s),
|
4272
4277
|
bonus_statuses=s.bonus_statuses,
|
4273
|
-
starting_decks=s.starting_decks,
|
4274
|
-
starting_piles=s.starting_piles,
|
4278
|
+
starting_decks=s.kernel.starting_decks,
|
4279
|
+
starting_piles=s.kernel.starting_piles,
|
4275
4280
|
history=get_public_history(s),
|
4276
4281
|
player_scores=get_public_player_scores(s),
|
4277
4282
|
player_graphs=s.player_graphs,
|
@@ -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=CfVDjz6q53feWv71XmCFGOGFI40s8Op0jiq6BzEuVLI,182494
|
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.1986.dist-info/METADATA,sha256=idZgHPywS8D8vXzhRPJefE30f5kr5NrL1MeSjcbDtgI,188
|
7
|
+
graph_games_proto-0.3.1986.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1986.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1986.dist-info/RECORD,,
|
File without changes
|
File without changes
|