graph-games-proto 0.3.1983__py3-none-any.whl → 0.3.1989__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 +44 -30
- {graph_games_proto-0.3.1983.dist-info → graph_games_proto-0.3.1989.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1983.dist-info → graph_games_proto-0.3.1989.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1983.dist-info → graph_games_proto-0.3.1989.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1983.dist-info → graph_games_proto-0.3.1989.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -1950,6 +1950,9 @@ class StateKernel(PClass):
|
|
1950
1950
|
nodeuuid2idx = field(type=dict) # Dict[str, int]
|
1951
1951
|
carduuid2deckidx = field(type=dict) # Dict[str, int]
|
1952
1952
|
bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
|
1953
|
+
starting_decks = field(type=list) # List[Deck]
|
1954
|
+
starting_piles = field(type=list) # List[Pile]
|
1955
|
+
goals = field(type=list) # List[FrozenGoal]
|
1953
1956
|
def __todict__(self):
|
1954
1957
|
return {
|
1955
1958
|
"rng": rng2json(self.rng),
|
@@ -1969,6 +1972,9 @@ class StateKernel(PClass):
|
|
1969
1972
|
"nodeuuid2idx": self.nodeuuid2idx,
|
1970
1973
|
"carduuid2deckidx": self.carduuid2deckidx,
|
1971
1974
|
"bonusuuid2bonusidx": self.bonusuuid2bonusidx,
|
1975
|
+
"starting_decks": [deck.__todict__() for deck in self.starting_decks],
|
1976
|
+
"starting_piles": [pile.__todict__() for pile in self.starting_piles],
|
1977
|
+
"goals": [goal.__todict__() for goal in self.goals],
|
1972
1978
|
}
|
1973
1979
|
@staticmethod
|
1974
1980
|
def __fromdict__(d):
|
@@ -1990,6 +1996,9 @@ class StateKernel(PClass):
|
|
1990
1996
|
nodeuuid2idx=d["nodeuuid2idx"],
|
1991
1997
|
carduuid2deckidx=d["carduuid2deckidx"],
|
1992
1998
|
bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
|
1999
|
+
starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
|
2000
|
+
starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
|
2001
|
+
goals=[FrozenGoal.__fromdict__(goal) for goal in d["goals"]],
|
1993
2002
|
)
|
1994
2003
|
|
1995
2004
|
|
@@ -2049,42 +2058,46 @@ def init_state_kernel(**kwargs):
|
|
2049
2058
|
edgetuple2uuid=edgetuple2uuid,
|
2050
2059
|
nodeuuid2idx=nodeuuid2idx,
|
2051
2060
|
carduuid2deckidx=carduuid2deckidx,
|
2052
|
-
bonusuuid2bonusidx=bonusuuid2bonusidx
|
2061
|
+
bonusuuid2bonusidx=bonusuuid2bonusidx,
|
2062
|
+
starting_decks=kwargs.get('starting_decks'),
|
2063
|
+
starting_piles=kwargs.get('starting_piles'),
|
2064
|
+
goals=kwargs.get('goals'),
|
2053
2065
|
)
|
2054
2066
|
|
2055
2067
|
|
2056
2068
|
class State(PClass):
|
2069
|
+
# Identity
|
2057
2070
|
kernel = field(type=StateKernel)
|
2058
|
-
idx2path = field(type=list) # List[Path2]
|
2059
|
-
bonus_statuses = field(type=list) # List[BonusStatus]
|
2060
|
-
starting_decks = field(type=list) # List[Deck]
|
2061
|
-
starting_piles = field(type=list)
|
2062
2071
|
history = field(type=list) # List[Action2]
|
2063
|
-
|
2064
|
-
player_graphs = field(type=list) # List[PlayerGraph]
|
2065
|
-
goals = field(type=list) # List[Goal]
|
2072
|
+
players = field(type=list) # List[Player]
|
2066
2073
|
nodes = field(type=list) # List[Node]
|
2067
2074
|
edges = field(type=list) # List[BiEdge]
|
2068
2075
|
regions = field(type=list) # List[Region]
|
2069
|
-
legal_actions_3 = field(type=list) # List[LegalAction]
|
2070
2076
|
piles = field(type=list) # List[Pile]
|
2071
|
-
|
2077
|
+
last_to_play = field(type=(int, type(None)), initial=None)
|
2078
|
+
|
2079
|
+
idx2path = field(type=list) # List[Path2]
|
2080
|
+
|
2081
|
+
# Scoring
|
2072
2082
|
player_idxs = field(type=list) # List[int]
|
2073
2083
|
decks = field(type=list) # List[Deck]
|
2074
2084
|
rng = field(type=random.Random)
|
2075
|
-
|
2085
|
+
|
2086
|
+
# Memoized
|
2087
|
+
player_graphs = field(type=list) # List[PlayerGraph]
|
2088
|
+
legal_actions_3 = field(type=list) # List[LegalAction]
|
2089
|
+
player_scores = field(type=list) # List[PlayerScore2]
|
2090
|
+
bonus_statuses = field(type=list) # List[BonusStatus]
|
2076
2091
|
winners = field(type=list) # List[int]
|
2092
|
+
|
2077
2093
|
def __todict__(self):
|
2078
2094
|
return {
|
2079
2095
|
"kernel": self.kernel.__todict__(),
|
2080
2096
|
"idx2path": [v.__todict__() for v in self.idx2path],
|
2081
2097
|
"bonus_statuses": [status.__todict__() for status in self.bonus_statuses],
|
2082
|
-
"starting_decks": [deck.__todict__() for deck in self.starting_decks],
|
2083
|
-
"starting_piles": [pile.__todict__() for pile in self.starting_piles],
|
2084
2098
|
"history": [x.__todict__() for x in self.history],
|
2085
2099
|
"player_scores": [x.__todict__() for x in self.player_scores],
|
2086
2100
|
"player_graphs": [x.__todict__() for x in self.player_graphs],
|
2087
|
-
"goals": [goal.__todict__() for goal in self.goals],
|
2088
2101
|
"nodes": [node.__todict__() for node in self.nodes],
|
2089
2102
|
"edges": [edge.__todict__() for edge in self.edges],
|
2090
2103
|
"regions": [region.__todict__() for region in self.regions],
|
@@ -2103,12 +2116,9 @@ class State(PClass):
|
|
2103
2116
|
kernel=StateKernel.__fromdict__(d["kernel"]),
|
2104
2117
|
idx2path=[Path2.__fromdict__(v) for v in d["idx2path"]],
|
2105
2118
|
bonus_statuses=[BonusStatus.__fromdict__(x) for x in d["bonus_statuses"]],
|
2106
|
-
starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
|
2107
|
-
starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
|
2108
2119
|
history=[Action2.__fromdict__(x) for x in d["history"]],
|
2109
2120
|
player_scores=[PlayerScore2.__fromdict__(x) for x in d["player_scores"]],
|
2110
2121
|
player_graphs=[PlayerGraph.__fromdict__(x) for x in d["player_graphs"]],
|
2111
|
-
goals=[FrozenGoal.__fromdict__(goal) for goal in d["goals"]],
|
2112
2122
|
nodes=[Node.__fromdict__(n) for n in d["nodes"]],
|
2113
2123
|
edges=[BiEdge.__fromdict__(e) for e in d["edges"]],
|
2114
2124
|
regions=[Region.__fromdict__(r) for r in d["regions"]],
|
@@ -2637,16 +2647,13 @@ def getinitialstate(game_config):
|
|
2637
2647
|
)
|
2638
2648
|
for bonus in bonuses
|
2639
2649
|
]
|
2650
|
+
|
2651
|
+
starting_decks=[Deck.__fromdict__(x.__todict__()) for x in decks]
|
2652
|
+
starting_piles=[Pile.__fromdict__(x.__todict__()) for x in piles]
|
2640
2653
|
|
2641
2654
|
state = State(
|
2642
2655
|
idx2path=idx2path,
|
2643
2656
|
bonus_statuses=bonus_statuses,
|
2644
|
-
starting_decks=[
|
2645
|
-
Deck.__fromdict__(x.__todict__()) for x in decks
|
2646
|
-
],
|
2647
|
-
starting_piles=[
|
2648
|
-
Pile.__fromdict__(x.__todict__()) for x in piles
|
2649
|
-
],
|
2650
2657
|
history=[],
|
2651
2658
|
player_scores=[PlayerScore2(public_items=[], private_items=[]) for _ in range(game_config.num_players)],
|
2652
2659
|
player_graphs=[
|
@@ -2655,7 +2662,6 @@ def getinitialstate(game_config):
|
|
2655
2662
|
neighbors=[[] for _ in range(len(nodes))]
|
2656
2663
|
) for player_idx in range(game_config.num_players)
|
2657
2664
|
],
|
2658
|
-
goals = board_config.goals,
|
2659
2665
|
nodes = nodes,
|
2660
2666
|
edges = edges,
|
2661
2667
|
regions = get_regions(board_config),
|
@@ -2681,6 +2687,9 @@ def getinitialstate(game_config):
|
|
2681
2687
|
player_idxs=state.player_idxs,
|
2682
2688
|
history=state.history,
|
2683
2689
|
player_scores=state.player_scores,
|
2690
|
+
starting_decks=starting_decks,
|
2691
|
+
starting_piles=starting_piles,
|
2692
|
+
goals=board_config.goals,
|
2684
2693
|
)
|
2685
2694
|
|
2686
2695
|
state = state.set(kernel=kernel)
|
@@ -2752,10 +2761,11 @@ def score_public_items(state, player_idx):
|
|
2752
2761
|
return items
|
2753
2762
|
|
2754
2763
|
|
2755
|
-
|
2764
|
+
@dispatch(State, int)
|
2765
|
+
def score_private_items(state, player_idx):
|
2756
2766
|
items = []
|
2757
|
-
goaluuid2goal = {goal.uuid: goal for goal in
|
2758
|
-
goal_completions = get_goal_completions(
|
2767
|
+
goaluuid2goal = {goal.uuid: goal for goal in state.kernel.goals}
|
2768
|
+
goal_completions = get_goal_completions(state, player_idx)
|
2759
2769
|
complete_goal_uuids = [gc.goal_uuid for gc in goal_completions if gc.complete]
|
2760
2770
|
incomplete_goal_uuids = [gc.goal_uuid for gc in goal_completions if not gc.complete]
|
2761
2771
|
for complete_goal_uuid in complete_goal_uuids:
|
@@ -4101,6 +4111,9 @@ def getnextstate2(s, a, log=False):
|
|
4101
4111
|
player_idxs=s.player_idxs,
|
4102
4112
|
history=s.history,
|
4103
4113
|
player_scores=s.player_scores,
|
4114
|
+
starting_decks=s.kernel.starting_decks,
|
4115
|
+
starting_piles=s.kernel.starting_piles,
|
4116
|
+
goals=s.kernel.goals,
|
4104
4117
|
)
|
4105
4118
|
s = s.set(legal_actions_3=calc_legal_actions3(state_kernel))
|
4106
4119
|
|
@@ -4272,8 +4285,8 @@ def getpublicstate(s):
|
|
4272
4285
|
all_pieces=list(s.kernel.pieceuuid2piece.values()),
|
4273
4286
|
to_play_2=getpublictoplay(s),
|
4274
4287
|
bonus_statuses=s.bonus_statuses,
|
4275
|
-
starting_decks=s.starting_decks,
|
4276
|
-
starting_piles=s.starting_piles,
|
4288
|
+
starting_decks=s.kernel.starting_decks,
|
4289
|
+
starting_piles=s.kernel.starting_piles,
|
4277
4290
|
history=get_public_history(s),
|
4278
4291
|
player_scores=get_public_player_scores(s),
|
4279
4292
|
player_graphs=s.player_graphs,
|
@@ -4506,9 +4519,10 @@ def get_player_graph(s, player_idx):
|
|
4506
4519
|
return nodes
|
4507
4520
|
|
4508
4521
|
|
4522
|
+
@dispatch(State, int)
|
4509
4523
|
def get_goals(s, player_idx):
|
4510
4524
|
player = s.players[player_idx]
|
4511
|
-
goaluuid2goal = {goal.uuid: goal for goal in s.goals}
|
4525
|
+
goaluuid2goal = {goal.uuid: goal for goal in s.kernel.goals}
|
4512
4526
|
goal_uuids = [s.kernel.carduuid2card[card_uuid].goal_uuid for card_uuid in player.cards if s.kernel.carduuid2card[card_uuid].goal_uuid]
|
4513
4527
|
return [
|
4514
4528
|
goaluuid2goal[goal_uuid] for goal_uuid in goal_uuids if goal_uuid in goaluuid2goal
|
@@ -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=I5TKswJWFPFWBORV9VOArGWBlXgUW3GXb-1GP0HVhxE,182680
|
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.1989.dist-info/METADATA,sha256=Mv0DRZjDx42RK5lO5oFiwkJofNq6YmNqokhkaH2rwVA,188
|
7
|
+
graph_games_proto-0.3.1989.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1989.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1989.dist-info/RECORD,,
|
File without changes
|
File without changes
|