graph-games-proto 0.3.1981__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 CHANGED
@@ -1949,6 +1949,7 @@ 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]
1952
1953
  def __todict__(self):
1953
1954
  return {
1954
1955
  "rng": rng2json(self.rng),
@@ -1967,6 +1968,7 @@ class StateKernel(PClass):
1967
1968
  "edgetuple2uuid": [{"k": list(k), "v": v} for k, v in self.edgetuple2uuid.items()],
1968
1969
  "nodeuuid2idx": self.nodeuuid2idx,
1969
1970
  "carduuid2deckidx": self.carduuid2deckidx,
1971
+ "bonusuuid2bonusidx": self.bonusuuid2bonusidx,
1970
1972
  }
1971
1973
  @staticmethod
1972
1974
  def __fromdict__(d):
@@ -1987,6 +1989,7 @@ class StateKernel(PClass):
1987
1989
  edgetuple2uuid={tuple(item["k"]): item["v"] for item in d["edgetuple2uuid"]},
1988
1990
  nodeuuid2idx=d["nodeuuid2idx"],
1989
1991
  carduuid2deckidx=d["carduuid2deckidx"],
1992
+ bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
1990
1993
  )
1991
1994
 
1992
1995
 
@@ -2025,6 +2028,9 @@ def init_state_kernel(**kwargs):
2025
2028
  node_2_idx = nodeuuid2idx[edge.node_2_uuid]
2026
2029
  edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
2027
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)}
2028
2034
 
2029
2035
  return StateKernel(
2030
2036
  rng=rng,
@@ -2043,6 +2049,7 @@ def init_state_kernel(**kwargs):
2043
2049
  edgetuple2uuid=edgetuple2uuid,
2044
2050
  nodeuuid2idx=nodeuuid2idx,
2045
2051
  carduuid2deckidx=carduuid2deckidx,
2052
+ bonusuuid2bonusidx=bonusuuid2bonusidx
2046
2053
  )
2047
2054
 
2048
2055
 
@@ -2050,7 +2057,6 @@ class State(PClass):
2050
2057
  kernel = field(type=StateKernel)
2051
2058
  idx2path = field(type=list) # List[Path2]
2052
2059
  bonus_statuses = field(type=list) # List[BonusStatus]
2053
- bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
2054
2060
  starting_decks = field(type=list) # List[Deck]
2055
2061
  starting_piles = field(type=list)
2056
2062
  history = field(type=list) # List[Action2]
@@ -2073,7 +2079,6 @@ class State(PClass):
2073
2079
  "kernel": self.kernel.__todict__(),
2074
2080
  "idx2path": [v.__todict__() for v in self.idx2path],
2075
2081
  "bonus_statuses": [status.__todict__() for status in self.bonus_statuses],
2076
- "bonusuuid2bonusidx": self.bonusuuid2bonusidx,
2077
2082
  "starting_decks": [deck.__todict__() for deck in self.starting_decks],
2078
2083
  "starting_piles": [pile.__todict__() for pile in self.starting_piles],
2079
2084
  "history": [x.__todict__() for x in self.history],
@@ -2098,7 +2103,6 @@ class State(PClass):
2098
2103
  kernel=StateKernel.__fromdict__(d["kernel"]),
2099
2104
  idx2path=[Path2.__fromdict__(v) for v in d["idx2path"]],
2100
2105
  bonus_statuses=[BonusStatus.__fromdict__(x) for x in d["bonus_statuses"]],
2101
- bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
2102
2106
  starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
2103
2107
  starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
2104
2108
  history=[Action2.__fromdict__(x) for x in d["history"]],
@@ -2618,7 +2622,6 @@ def getinitialstate(game_config):
2618
2622
  idx2path.append(path)
2619
2623
 
2620
2624
  bonuses = game_config.fig.board_config.bonuses
2621
- bonusuuid2bonusidx = {bonus.uuid: idx for idx, bonus in enumerate(bonuses)}
2622
2625
  bonus_statuses = [
2623
2626
  BonusStatus(
2624
2627
  bonus_uuid=bonus.uuid,
@@ -2638,7 +2641,6 @@ def getinitialstate(game_config):
2638
2641
  state = State(
2639
2642
  idx2path=idx2path,
2640
2643
  bonus_statuses=bonus_statuses,
2641
- bonusuuid2bonusidx=bonusuuid2bonusidx,
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1981
3
+ Version: 0.3.1983
4
4
  Requires-Dist: multipledispatch==1.0.0
5
5
  Requires-Dist: pyrsistent==0.20.0
6
6
  Requires-Dist: numpy==2.2.4
@@ -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=jK1eZUO8OtrzJUpRs2uNOtelhaZZwGphkw59CpbTSUE,182177
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.1981.dist-info/METADATA,sha256=CD2Hb9yHEm9IyX0_vrROdZ9iqn6TSZuBJeaDqo3HZ18,188
7
- graph_games_proto-0.3.1981.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1981.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1981.dist-info/RECORD,,
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,,