graph-games-proto 0.3.1979__py3-none-any.whl → 0.3.1983__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 +19 -17
- {graph_games_proto-0.3.1979.dist-info → graph_games_proto-0.3.1983.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1979.dist-info → graph_games_proto-0.3.1983.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1979.dist-info → graph_games_proto-0.3.1983.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1979.dist-info → graph_games_proto-0.3.1983.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -1190,7 +1190,7 @@ class LegalActionKeep(PClass):
|
|
1190
1190
|
deck_idx = legal_action.keep.deck_idx
|
1191
1191
|
card_uuids_matching_deck = [
|
1192
1192
|
card_uuid for card_uuid in discard_tray
|
1193
|
-
if state.carduuid2deckidx[card_uuid] == deck_idx
|
1193
|
+
if state.kernel.carduuid2deckidx[card_uuid] == deck_idx
|
1194
1194
|
]
|
1195
1195
|
num_cards = len(card_uuids_matching_deck)
|
1196
1196
|
actual_min = 0 if legal_action.keep.min is None else legal_action.keep.min
|
@@ -1231,7 +1231,7 @@ class LegalActionDiscard(PClass):
|
|
1231
1231
|
deck_idx = legal_action.discard.deck_idx
|
1232
1232
|
card_uuids_matching_deck = [
|
1233
1233
|
card_uuid for card_uuid in discard_tray
|
1234
|
-
if state.carduuid2deckidx[card_uuid] == deck_idx
|
1234
|
+
if state.kernel.carduuid2deckidx[card_uuid] == deck_idx
|
1235
1235
|
]
|
1236
1236
|
num_cards = len(card_uuids_matching_deck)
|
1237
1237
|
actual_min = 0 if legal_action.discard.min is None else legal_action.discard.min
|
@@ -1535,7 +1535,7 @@ class ActionDiscard(PClass):
|
|
1535
1535
|
card_uuids = field(type=list) # List[int]
|
1536
1536
|
def get_public(self, state):
|
1537
1537
|
return PublicActionDiscard(
|
1538
|
-
deck_idxs=[state.carduuid2deckidx[card_uuid] for card_uuid in self.card_uuids]
|
1538
|
+
deck_idxs=[state.kernel.carduuid2deckidx[card_uuid] for card_uuid in self.card_uuids]
|
1539
1539
|
)
|
1540
1540
|
def __todict__(self):
|
1541
1541
|
return {
|
@@ -1565,7 +1565,7 @@ class ActionKeep(PClass):
|
|
1565
1565
|
card_uuids = field(type=list) # List[int])
|
1566
1566
|
def get_public(self, state):
|
1567
1567
|
return PublicActionKeep(
|
1568
|
-
deck_idxs=[state.carduuid2deckidx[card_uuid] for card_uuid in self.card_uuids]
|
1568
|
+
deck_idxs=[state.kernel.carduuid2deckidx[card_uuid] for card_uuid in self.card_uuids]
|
1569
1569
|
)
|
1570
1570
|
def __todict__(self):
|
1571
1571
|
return {
|
@@ -1948,6 +1948,8 @@ class StateKernel(PClass):
|
|
1948
1948
|
carduuid2card = field(type=dict) # Dict[str, Card]
|
1949
1949
|
edgetuple2uuid = field(type=dict) # Dict[Tuple[int, int], str]
|
1950
1950
|
nodeuuid2idx = field(type=dict) # Dict[str, int]
|
1951
|
+
carduuid2deckidx = field(type=dict) # Dict[str, int]
|
1952
|
+
bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
|
1951
1953
|
def __todict__(self):
|
1952
1954
|
return {
|
1953
1955
|
"rng": rng2json(self.rng),
|
@@ -1965,6 +1967,8 @@ class StateKernel(PClass):
|
|
1965
1967
|
"carduuid2card": {k: v.__todict__() for k, v in self.carduuid2card.items()},
|
1966
1968
|
"edgetuple2uuid": [{"k": list(k), "v": v} for k, v in self.edgetuple2uuid.items()],
|
1967
1969
|
"nodeuuid2idx": self.nodeuuid2idx,
|
1970
|
+
"carduuid2deckidx": self.carduuid2deckidx,
|
1971
|
+
"bonusuuid2bonusidx": self.bonusuuid2bonusidx,
|
1968
1972
|
}
|
1969
1973
|
@staticmethod
|
1970
1974
|
def __fromdict__(d):
|
@@ -1984,6 +1988,8 @@ class StateKernel(PClass):
|
|
1984
1988
|
carduuid2card={k: Card.__fromdict(v) for k, v in d["carduuid2card"].items()},
|
1985
1989
|
edgetuple2uuid={tuple(item["k"]): item["v"] for item in d["edgetuple2uuid"]},
|
1986
1990
|
nodeuuid2idx=d["nodeuuid2idx"],
|
1991
|
+
carduuid2deckidx=d["carduuid2deckidx"],
|
1992
|
+
bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
|
1987
1993
|
)
|
1988
1994
|
|
1989
1995
|
|
@@ -2005,11 +2011,14 @@ def init_state_kernel(**kwargs):
|
|
2005
2011
|
pieces = generate_pieces(piece_template, player_idx)
|
2006
2012
|
for piece in pieces:
|
2007
2013
|
pieceuuid2piece[piece.uuid] = piece
|
2014
|
+
|
2015
|
+
carduuid2deckidx = {}
|
2008
2016
|
carduuid2card = {}
|
2009
2017
|
for dek in board_config.deks:
|
2010
2018
|
cards = generate_cards(dek)
|
2011
2019
|
for card in cards:
|
2012
2020
|
carduuid2card[card.uuid] = card
|
2021
|
+
carduuid2deckidx[card.uuid] = dek.idx
|
2013
2022
|
|
2014
2023
|
nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
|
2015
2024
|
edges = get_edges(rng, board_config, nodeuuid2idx)
|
@@ -2019,6 +2028,9 @@ def init_state_kernel(**kwargs):
|
|
2019
2028
|
node_2_idx = nodeuuid2idx[edge.node_2_uuid]
|
2020
2029
|
edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
|
2021
2030
|
edgetuple2uuid[edge_tuple] = edge.uuid
|
2031
|
+
|
2032
|
+
bonuses = game_config.fig.board_config.bonuses
|
2033
|
+
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2022
2034
|
|
2023
2035
|
return StateKernel(
|
2024
2036
|
rng=rng,
|
@@ -2036,6 +2048,8 @@ def init_state_kernel(**kwargs):
|
|
2036
2048
|
pieceuuid2piece=pieceuuid2piece,
|
2037
2049
|
edgetuple2uuid=edgetuple2uuid,
|
2038
2050
|
nodeuuid2idx=nodeuuid2idx,
|
2051
|
+
carduuid2deckidx=carduuid2deckidx,
|
2052
|
+
bonusuuid2bonusidx=bonusuuid2bonusidx
|
2039
2053
|
)
|
2040
2054
|
|
2041
2055
|
|
@@ -2043,8 +2057,6 @@ class State(PClass):
|
|
2043
2057
|
kernel = field(type=StateKernel)
|
2044
2058
|
idx2path = field(type=list) # List[Path2]
|
2045
2059
|
bonus_statuses = field(type=list) # List[BonusStatus]
|
2046
|
-
bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
|
2047
|
-
carduuid2deckidx = field(type=dict) # Dict[str, int]
|
2048
2060
|
starting_decks = field(type=list) # List[Deck]
|
2049
2061
|
starting_piles = field(type=list)
|
2050
2062
|
history = field(type=list) # List[Action2]
|
@@ -2067,8 +2079,6 @@ class State(PClass):
|
|
2067
2079
|
"kernel": self.kernel.__todict__(),
|
2068
2080
|
"idx2path": [v.__todict__() for v in self.idx2path],
|
2069
2081
|
"bonus_statuses": [status.__todict__() for status in self.bonus_statuses],
|
2070
|
-
"bonusuuid2bonusidx": self.bonusuuid2bonusidx,
|
2071
|
-
"carduuid2deckidx": self.carduuid2deckidx,
|
2072
2082
|
"starting_decks": [deck.__todict__() for deck in self.starting_decks],
|
2073
2083
|
"starting_piles": [pile.__todict__() for pile in self.starting_piles],
|
2074
2084
|
"history": [x.__todict__() for x in self.history],
|
@@ -2093,8 +2103,6 @@ class State(PClass):
|
|
2093
2103
|
kernel=StateKernel.__fromdict__(d["kernel"]),
|
2094
2104
|
idx2path=[Path2.__fromdict__(v) for v in d["idx2path"]],
|
2095
2105
|
bonus_statuses=[BonusStatus.__fromdict__(x) for x in d["bonus_statuses"]],
|
2096
|
-
bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
|
2097
|
-
carduuid2deckidx=d["carduuid2deckidx"],
|
2098
2106
|
starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
|
2099
2107
|
starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
|
2100
2108
|
history=[Action2.__fromdict__(x) for x in d["history"]],
|
@@ -2591,12 +2599,9 @@ def getinitialstate(game_config):
|
|
2591
2599
|
)
|
2592
2600
|
piles.append(pile)
|
2593
2601
|
|
2594
|
-
carduuid2deckidx = {}
|
2595
2602
|
decks = []
|
2596
2603
|
for dek in board_config.deks:
|
2597
2604
|
cards = generate_cards(dek)
|
2598
|
-
for card in cards:
|
2599
|
-
carduuid2deckidx[card.uuid] = dek.idx
|
2600
2605
|
deck_obj = Deck(
|
2601
2606
|
uuid=dek.uuid,
|
2602
2607
|
idx=dek.idx,
|
@@ -2617,7 +2622,6 @@ def getinitialstate(game_config):
|
|
2617
2622
|
idx2path.append(path)
|
2618
2623
|
|
2619
2624
|
bonuses = game_config.fig.board_config.bonuses
|
2620
|
-
bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
|
2621
2625
|
bonus_statuses = [
|
2622
2626
|
BonusStatus(
|
2623
2627
|
bonus_uuid=bonus.uuid,
|
@@ -2637,8 +2641,6 @@ def getinitialstate(game_config):
|
|
2637
2641
|
state = State(
|
2638
2642
|
idx2path=idx2path,
|
2639
2643
|
bonus_statuses=bonus_statuses,
|
2640
|
-
bonusuuid2bonusidx=bonusuuid2bonusidx,
|
2641
|
-
carduuid2deckidx=carduuid2deckidx,
|
2642
2644
|
starting_decks=[
|
2643
2645
|
Deck.__fromdict__(x.__todict__()) for x in decks
|
2644
2646
|
],
|
@@ -2736,7 +2738,7 @@ def score_public_items(state, player_idx):
|
|
2736
2738
|
)
|
2737
2739
|
)
|
2738
2740
|
for bonus_status in state.bonus_statuses:
|
2739
|
-
bonus_idx = state.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2741
|
+
bonus_idx = state.kernel.bonusuuid2bonusidx.get(bonus_status.bonus_uuid)
|
2740
2742
|
bonus = state.kernel.game_config.fig.board_config.bonuses[bonus_idx] if bonus_idx is not None else None
|
2741
2743
|
if bonus:
|
2742
2744
|
if player_idx in bonus_status.winners:
|
@@ -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=yB1kxoIYiYt6D_Xx9A6Vp6CVTPe3m30M3GDVULVF7SI,182235
|
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.1983.dist-info/METADATA,sha256=GbtVYo6tdOH0n-whQiol1hXhN0SOA3khUr8SuSk-SAQ,188
|
7
|
+
graph_games_proto-0.3.1983.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1983.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1983.dist-info/RECORD,,
|
File without changes
|
File without changes
|