graph-games-proto 0.3.1934__py3-none-any.whl → 0.3.1937__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
@@ -16,7 +16,7 @@ from itertools import combinations as itertools_combinations, chain
16
16
  from collections import deque
17
17
 
18
18
  DEFAULT_ALLOTTED_SECONDS = 12
19
- INITIAL_ALLOTTED_SECONDS = 120
19
+ INITIAL_ALLOTTED_SECONDS = 22
20
20
 
21
21
  class NoAction(PClass):
22
22
  pass
@@ -1946,6 +1946,7 @@ class StateKernal(PClass):
1946
1946
  pieceuuid2piece = field(type=dict) # Dict[str, Piece]
1947
1947
  edgeuuid2idx = field(type=dict) # Dict[str, int]
1948
1948
  carduuid2card = field(type=dict) # Dict[str, Card]
1949
+ edgetuple2uuid = field(type=dict) # Dict[Tuple[int, int], str]
1949
1950
  def __todict__(self):
1950
1951
  return {
1951
1952
  "rng": rng2json(self.rng),
@@ -1961,6 +1962,7 @@ class StateKernal(PClass):
1961
1962
  "pieceuuid2piece": {k: v.__todict__() for k, v in self.pieceuuid2piece.items()},
1962
1963
  "edgeuuid2idx": self.edgeuuid2idx,
1963
1964
  "carduuid2card": {k: v.__todict__() for k, v in self.carduuid2card.items()},
1965
+ "edgetuple2uuid": [{"k": list(k), "v": v} for k, v in self.edgetuple2uuid.items()],
1964
1966
  }
1965
1967
  @staticmethod
1966
1968
  def __fromdict__(d):
@@ -1978,10 +1980,12 @@ class StateKernal(PClass):
1978
1980
  pieceuuid2piece={k: Piece.__fromdict(v) for k, v in d["pieceuuid2piece"].items()},
1979
1981
  edgeuuid2idx=d["edgeuuid2idx"],
1980
1982
  carduuid2card={k: Card.__fromdict(v) for k, v in d["carduuid2card"].items()},
1983
+ edgetuple2uuid={tuple(item["k"]): item["v"] for item in d["edgetuple2uuid"]},
1981
1984
  )
1982
1985
 
1983
1986
 
1984
1987
  def init_state_kernel(**kwargs):
1988
+ rng = kwargs.get('rng')
1985
1989
  game_config = kwargs.get('game_config')
1986
1990
  fig = game_config.fig
1987
1991
  board_config = fig.board_config
@@ -2003,9 +2007,18 @@ def init_state_kernel(**kwargs):
2003
2007
  cards = generate_cards(dek)
2004
2008
  for card in cards:
2005
2009
  carduuid2card[card.uuid] = card
2010
+
2011
+ nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
2012
+ edges = get_edges(rng, board_config, nodeuuid2idx)
2013
+ edgetuple2uuid = {}
2014
+ for edge in edges:
2015
+ node_1_idx = nodeuuid2idx[edge.node_1_uuid]
2016
+ node_2_idx = nodeuuid2idx[edge.node_2_uuid]
2017
+ edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
2018
+ edgetuple2uuid[edge_tuple] = edge.uuid
2006
2019
 
2007
2020
  return StateKernal(
2008
- rng=kwargs.get('rng'),
2021
+ rng=rng,
2009
2022
  game_config=game_config,
2010
2023
  edges=edges,
2011
2024
  decks=kwargs.get('decks'),
@@ -2018,6 +2031,7 @@ def init_state_kernel(**kwargs):
2018
2031
  edgeuuid2idx=edgeuuid2idx,
2019
2032
  carduuid2card=carduuid2card,
2020
2033
  pieceuuid2piece=pieceuuid2piece,
2034
+ edgetuple2uuid=edgetuple2uuid,
2021
2035
  )
2022
2036
 
2023
2037
 
@@ -2037,7 +2051,6 @@ class State(PClass):
2037
2051
  nodes = field(type=list) # List[Node]
2038
2052
  nodeuuid2idx = field(type=dict) # Dict[str, int]
2039
2053
  edges = field(type=list) # List[BiEdge]
2040
- edgetuple2uuid = field(type=dict) # Dict[Tuple[int, int], str]
2041
2054
  regions = field(type=list) # List[Region]
2042
2055
  legal_actions_3 = field(type=list) # List[LegalAction]
2043
2056
  piles = field(type=list) # List[Pile]
@@ -2065,7 +2078,6 @@ class State(PClass):
2065
2078
  "nodes": [node.__todict__() for node in self.nodes],
2066
2079
  "nodeuuid2idx": self.nodeuuid2idx,
2067
2080
  "edges": [edge.__todict__() for edge in self.edges],
2068
- "edgetuple2uuid": [{"k": list(k), "v": v} for k, v in self.edgetuple2uuid.items()],
2069
2081
  "regions": [region.__todict__() for region in self.regions],
2070
2082
  "legal_actions_3": [x.__todict__() for x in self.legal_actions_3],
2071
2083
  "piles": [pile.__todict__() for pile in self.piles],
@@ -2095,7 +2107,6 @@ class State(PClass):
2095
2107
  nodes=[Node.__fromdict__(n) for n in d["nodes"]],
2096
2108
  nodeuuid2idx=d["nodeuuid2idx"],
2097
2109
  edges=[BiEdge.__fromdict__(e) for e in d["edges"]],
2098
- edgetuple2uuid={tuple(item["k"]): item["v"] for item in d["edgetuple2uuid"]},
2099
2110
  regions=[Region.__fromdict__(r) for r in d["regions"]],
2100
2111
  legal_actions_3=[LegalAction.__fromdict__(x) for x in d["legal_actions_3"]],
2101
2112
  piles=[Pile.__fromdict__(p) for p in d["piles"]],
@@ -2603,12 +2614,6 @@ def getinitialstate(game_config):
2603
2614
 
2604
2615
  nodeuuid2idx = {node.uuid: idx for idx, node in enumerate(board_config.points)}
2605
2616
  edges = get_edges(rng, board_config, nodeuuid2idx)
2606
- edgetuple2uuid = {}
2607
- for edge in edges:
2608
- node_1_idx = nodeuuid2idx[edge.node_1_uuid]
2609
- node_2_idx = nodeuuid2idx[edge.node_2_uuid]
2610
- edge_tuple = (min(node_1_idx, node_2_idx), max(node_1_idx, node_2_idx))
2611
- edgetuple2uuid[edge_tuple] = edge.uuid
2612
2617
 
2613
2618
  idx2path = []
2614
2619
 
@@ -2658,7 +2663,6 @@ def getinitialstate(game_config):
2658
2663
  nodes = nodes,
2659
2664
  nodeuuid2idx = nodeuuid2idx,
2660
2665
  edges = edges,
2661
- edgetuple2uuid = edgetuple2uuid,
2662
2666
  regions = get_regions(board_config),
2663
2667
  legal_actions_3=[],
2664
2668
  piles=piles,
@@ -3193,7 +3197,7 @@ def calc_path_len_from_edges(game, edge_tuples):
3193
3197
  return 0
3194
3198
  edge_lens = []
3195
3199
  for edge_tuple in edge_tuples:
3196
- edge_uuid = game.edgetuple2uuid.get(edge_tuple)
3200
+ edge_uuid = game.kernel.edgetuple2uuid.get(edge_tuple)
3197
3201
  edge_idx = game.edgeuuid2idx.get(edge_uuid)
3198
3202
  if edge_idx is not None:
3199
3203
  edge = game.edges[edge_idx]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1934
3
+ Version: 0.3.1937
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=VGAFpUF4NHnQqnuLNYIc9EfNumKx49IKvg7a-8eQEDo,182032
3
+ graph_games_proto/fns.py,sha256=7Sub-734RnmdNZ2bR9r4b2dYjWdaTNcD8v6MxS6dBhQ,182190
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.1934.dist-info/METADATA,sha256=06szQT5VQPzcO7sGenz5Ozo0sd32urAf2ydz9mBsNhU,188
7
- graph_games_proto-0.3.1934.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1934.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1934.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1937.dist-info/METADATA,sha256=L7F7-8wAqBVh6XrujYeaukSL2Lcn_xTOHKdVhDknwoQ,188
7
+ graph_games_proto-0.3.1937.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1937.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1937.dist-info/RECORD,,