graph-games-proto 0.3.1986__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 CHANGED
@@ -1952,6 +1952,7 @@ class StateKernel(PClass):
1952
1952
  bonusuuid2bonusidx = field(type=dict) # Dict[str, int]
1953
1953
  starting_decks = field(type=list) # List[Deck]
1954
1954
  starting_piles = field(type=list) # List[Pile]
1955
+ goals = field(type=list) # List[FrozenGoal]
1955
1956
  def __todict__(self):
1956
1957
  return {
1957
1958
  "rng": rng2json(self.rng),
@@ -1973,6 +1974,7 @@ class StateKernel(PClass):
1973
1974
  "bonusuuid2bonusidx": self.bonusuuid2bonusidx,
1974
1975
  "starting_decks": [deck.__todict__() for deck in self.starting_decks],
1975
1976
  "starting_piles": [pile.__todict__() for pile in self.starting_piles],
1977
+ "goals": [goal.__todict__() for goal in self.goals],
1976
1978
  }
1977
1979
  @staticmethod
1978
1980
  def __fromdict__(d):
@@ -1996,6 +1998,7 @@ class StateKernel(PClass):
1996
1998
  bonusuuid2bonusidx=d["bonusuuid2bonusidx"],
1997
1999
  starting_decks=[Deck.__fromdict__(x) for x in d["starting_decks"]],
1998
2000
  starting_piles=[Pile.__fromdict__(x) for x in d["starting_piles"]],
2001
+ goals=[FrozenGoal.__fromdict__(goal) for goal in d["goals"]],
1999
2002
  )
2000
2003
 
2001
2004
 
@@ -2058,28 +2061,35 @@ def init_state_kernel(**kwargs):
2058
2061
  bonusuuid2bonusidx=bonusuuid2bonusidx,
2059
2062
  starting_decks=kwargs.get('starting_decks'),
2060
2063
  starting_piles=kwargs.get('starting_piles'),
2064
+ goals=kwargs.get('goals'),
2061
2065
  )
2062
2066
 
2063
2067
 
2064
2068
  class State(PClass):
2069
+ # Identity
2065
2070
  kernel = field(type=StateKernel)
2066
- idx2path = field(type=list) # List[Path2]
2067
- bonus_statuses = field(type=list) # List[BonusStatus]
2068
2071
  history = field(type=list) # List[Action2]
2069
- player_scores = field(type=list) # List[PlayerScore2]
2070
- player_graphs = field(type=list) # List[PlayerGraph]
2071
- goals = field(type=list) # List[Goal]
2072
+ players = field(type=list) # List[Player]
2072
2073
  nodes = field(type=list) # List[Node]
2073
2074
  edges = field(type=list) # List[BiEdge]
2074
2075
  regions = field(type=list) # List[Region]
2075
- legal_actions_3 = field(type=list) # List[LegalAction]
2076
2076
  piles = field(type=list) # List[Pile]
2077
- players = field(type=list) # List[Player]
2077
+ last_to_play = field(type=(int, type(None)), initial=None)
2078
+
2079
+ idx2path = field(type=list) # List[Path2]
2080
+
2081
+ # Scoring
2078
2082
  player_idxs = field(type=list) # List[int]
2079
2083
  decks = field(type=list) # List[Deck]
2080
2084
  rng = field(type=random.Random)
2081
- last_to_play = field(type=(int, type(None)), initial=None)
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]
2082
2091
  winners = field(type=list) # List[int]
2092
+
2083
2093
  def __todict__(self):
2084
2094
  return {
2085
2095
  "kernel": self.kernel.__todict__(),
@@ -2088,7 +2098,6 @@ class State(PClass):
2088
2098
  "history": [x.__todict__() for x in self.history],
2089
2099
  "player_scores": [x.__todict__() for x in self.player_scores],
2090
2100
  "player_graphs": [x.__todict__() for x in self.player_graphs],
2091
- "goals": [goal.__todict__() for goal in self.goals],
2092
2101
  "nodes": [node.__todict__() for node in self.nodes],
2093
2102
  "edges": [edge.__todict__() for edge in self.edges],
2094
2103
  "regions": [region.__todict__() for region in self.regions],
@@ -2110,7 +2119,6 @@ class State(PClass):
2110
2119
  history=[Action2.__fromdict__(x) for x in d["history"]],
2111
2120
  player_scores=[PlayerScore2.__fromdict__(x) for x in d["player_scores"]],
2112
2121
  player_graphs=[PlayerGraph.__fromdict__(x) for x in d["player_graphs"]],
2113
- goals=[FrozenGoal.__fromdict__(goal) for goal in d["goals"]],
2114
2122
  nodes=[Node.__fromdict__(n) for n in d["nodes"]],
2115
2123
  edges=[BiEdge.__fromdict__(e) for e in d["edges"]],
2116
2124
  regions=[Region.__fromdict__(r) for r in d["regions"]],
@@ -2654,7 +2662,6 @@ def getinitialstate(game_config):
2654
2662
  neighbors=[[] for _ in range(len(nodes))]
2655
2663
  ) for player_idx in range(game_config.num_players)
2656
2664
  ],
2657
- goals = board_config.goals,
2658
2665
  nodes = nodes,
2659
2666
  edges = edges,
2660
2667
  regions = get_regions(board_config),
@@ -2682,6 +2689,7 @@ def getinitialstate(game_config):
2682
2689
  player_scores=state.player_scores,
2683
2690
  starting_decks=starting_decks,
2684
2691
  starting_piles=starting_piles,
2692
+ goals=board_config.goals,
2685
2693
  )
2686
2694
 
2687
2695
  state = state.set(kernel=kernel)
@@ -2753,10 +2761,11 @@ def score_public_items(state, player_idx):
2753
2761
  return items
2754
2762
 
2755
2763
 
2756
- def score_private_items(game, player_idx):
2764
+ @dispatch(State, int)
2765
+ def score_private_items(state, player_idx):
2757
2766
  items = []
2758
- goaluuid2goal = {goal.uuid: goal for goal in game.goals}
2759
- goal_completions = get_goal_completions(game, player_idx)
2767
+ goaluuid2goal = {goal.uuid: goal for goal in state.kernel.goals}
2768
+ goal_completions = get_goal_completions(state, player_idx)
2760
2769
  complete_goal_uuids = [gc.goal_uuid for gc in goal_completions if gc.complete]
2761
2770
  incomplete_goal_uuids = [gc.goal_uuid for gc in goal_completions if not gc.complete]
2762
2771
  for complete_goal_uuid in complete_goal_uuids:
@@ -4104,6 +4113,7 @@ def getnextstate2(s, a, log=False):
4104
4113
  player_scores=s.player_scores,
4105
4114
  starting_decks=s.kernel.starting_decks,
4106
4115
  starting_piles=s.kernel.starting_piles,
4116
+ goals=s.kernel.goals,
4107
4117
  )
4108
4118
  s = s.set(legal_actions_3=calc_legal_actions3(state_kernel))
4109
4119
 
@@ -4509,9 +4519,10 @@ def get_player_graph(s, player_idx):
4509
4519
  return nodes
4510
4520
 
4511
4521
 
4522
+ @dispatch(State, int)
4512
4523
  def get_goals(s, player_idx):
4513
4524
  player = s.players[player_idx]
4514
- goaluuid2goal = {goal.uuid: goal for goal in s.goals}
4525
+ goaluuid2goal = {goal.uuid: goal for goal in s.kernel.goals}
4515
4526
  goal_uuids = [s.kernel.carduuid2card[card_uuid].goal_uuid for card_uuid in player.cards if s.kernel.carduuid2card[card_uuid].goal_uuid]
4516
4527
  return [
4517
4528
  goaluuid2goal[goal_uuid] for goal_uuid in goal_uuids if goal_uuid in goaluuid2goal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1986
3
+ Version: 0.3.1989
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=CfVDjz6q53feWv71XmCFGOGFI40s8Op0jiq6BzEuVLI,182494
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.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,,
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,,