graph-games-proto 0.3.2095__py3-none-any.whl → 0.3.2099__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
@@ -1063,7 +1063,18 @@ class Player(PClass):
1063
1063
  cards=d["cards"],
1064
1064
  discard_tray=d["discard_tray"]
1065
1065
  )
1066
-
1066
+
1067
+
1068
+ @dispatch(PublicPlayer)
1069
+ def imagine_player(public_player) -> Player:
1070
+ return Player(
1071
+ idx=public_player.idx,
1072
+ pieces=public_player.pieces,
1073
+ cards=[],
1074
+ discard_tray=[],
1075
+ )
1076
+
1077
+
1067
1078
  class GoalCompletion(PClass):
1068
1079
  goal_uuid = field(type=str)
1069
1080
  complete = field(type=bool, initial=False)
@@ -2091,7 +2102,7 @@ class StateKernel(PClass):
2091
2102
  piles = field(type=list) # List[Pile]
2092
2103
  players = field(type=list) # List[Player]
2093
2104
  player_idxs = field(type=list) # List[int]
2094
- history = field(type=list) # List[PublicAction]
2105
+ history = field(type=list) # List[Action2]
2095
2106
  pieceuuid2piece = field(type=dict) # Dict[str, Piece]
2096
2107
  edgeuuid2idx = field(type=dict) # Dict[str, int]
2097
2108
  carduuid2card = field(type=dict) # Dict[str, Card]
@@ -2144,7 +2155,7 @@ class StateKernel(PClass):
2144
2155
  piles=[Pile.__fromdict__(pile) for pile in d["piles"]],
2145
2156
  players=[Player.__fromdict__(player) for player in d["players"]],
2146
2157
  player_idxs=d["player_idxs"],
2147
- history=[PublicAction.__fromdict__(action) for action in d["history"]],
2158
+ history=[Action2.__fromdict__(action) for action in d["history"]],
2148
2159
  uuid2edgerecord={k: BiEdgeRecord.__fromdict__(v) for k, v in d["uuid2edgerecord"].items()},
2149
2160
  uuid2segmentrecord={k: Segment2.__fromdict__(v) for k, v in d["uuid2segmentrecord"].items()},
2150
2161
  idx2pathrecord=[Path2.__fromdict(v) for v in d["idx2pathrecord"]],
@@ -2551,6 +2562,7 @@ class PublicState(PClass):
2551
2562
  terminal = field(type=bool)
2552
2563
  def __todict__(self):
2553
2564
  return {
2565
+ "game_config": self.game_config.__todict__(),
2554
2566
  "deadlines": [deadline.__todict__() if deadline else None for deadline in self.deadlines],
2555
2567
  "game_started_at": self.game_started_at,
2556
2568
  "allotted_times": [allotted_time.__todict__() if allotted_time else None for allotted_time in self.allotted_times], # List[AllottedTime|None]
@@ -2577,6 +2589,7 @@ class PublicState(PClass):
2577
2589
  @staticmethod
2578
2590
  def __fromdict__(d):
2579
2591
  return PublicState(
2592
+ game_config=PublicGameConfig.__fromdict__(d["game_config"]),
2580
2593
  deadlines=[RemainingAllottedTime.__fromdict__(x) for x in d["deadlines"]],
2581
2594
  game_started_at=d["game_started_at"],
2582
2595
  allotted_times=[AllottedTime.__fromdict__(x) if x else None for x in d["allotted_times"]], # List[AllottedTime|None]
@@ -4557,7 +4570,7 @@ def get_deadline(s, max_allotted_time):
4557
4570
  since_action_idx = max_allotted_time.since_action_idx
4558
4571
  if since_action_idx == -1:
4559
4572
  allotted_since = datetime.strptime(
4560
- s.kernel.started_at,
4573
+ s.kernel.game_config.started_at,
4561
4574
  "%Y-%m-%d %H:%M:%S"
4562
4575
  )
4563
4576
  else:
@@ -4621,40 +4634,43 @@ def get_public_history(s):
4621
4634
  return [action.get_public(s) for action in s.kernel.history]
4622
4635
 
4623
4636
 
4624
- def imagine_history(public_state, private_state):
4637
+ @dispatch(PlayerState)
4638
+ def imagine_history(ps) -> list[Action2]:
4625
4639
  pass
4626
4640
 
4627
- def imagine_player_scores(public_state, private_state):
4628
- pass
4629
4641
 
4630
- def imagine_legal_actions(public_state, private_state):
4642
+ @dispatch(PlayerState)
4643
+ def imagine_players(ps) -> list[Player]:
4631
4644
  pass
4632
4645
 
4633
- def imagine_players(public_state, private_state):
4634
- pass
4635
4646
 
4636
- def imagine_decks(public_state, private_state):
4647
+ @dispatch(PlayerState)
4648
+ def imagine_decks(ps) -> list[Deck]:
4637
4649
  pass
4638
4650
 
4639
4651
 
4640
- def imagine_state(public_state, private_state):
4641
- public_game_config = public_state.game_config
4652
+ @dispatch(PlayerState)
4653
+ def imagine_state(ps):
4654
+ public = ps.public
4655
+ game_config = public.game_config
4656
+
4657
+ # candidates = get_candidates(ps)
4642
4658
 
4643
4659
  imagined_kernel = init_state_kernel(
4644
4660
  GameConfig(
4645
4661
  seed=random.randint(0, 2**31 - 1),
4646
- uuid=public_game_config.uuid,
4647
- num_players=public_game_config.num_players,
4648
- fig=public_game_config.fig,
4649
- started_at=public_game_config.started_at,
4662
+ uuid=game_config.uuid,
4663
+ num_players=game_config.num_players,
4664
+ fig=game_config.fig,
4665
+ started_at=game_config.started_at,
4650
4666
  ),
4651
- edges=public_state.edges,
4652
- nodes=public_state.nodes,
4653
- piles=public_state.piles,
4654
- player_idxs=public_state.player_idxs,
4655
- decks=imagine_decks(public_state, private_state),
4656
- players=imagine_players(public_state, private_state),
4657
- history=imagine_history(public_state, private_state),
4667
+ edges=public.edges,
4668
+ nodes=public.nodes,
4669
+ piles=public.piles,
4670
+ player_idxs=public.player_idxs,
4671
+ decks=imagine_decks(ps),
4672
+ players=imagine_players(ps),
4673
+ history=imagine_history(ps),
4658
4674
  )
4659
4675
  return init_memoized_state(imagined_kernel)
4660
4676
 
@@ -4713,7 +4729,7 @@ def getpublicstate(s):
4713
4729
  return PublicState(
4714
4730
  game_config=getpublicgameconfig(s.kernel.game_config),
4715
4731
  deadlines=get_deadlines(s),
4716
- game_started_at=s.kernel.started_at,
4732
+ game_started_at=s.kernel.game_config.started_at,
4717
4733
  allotted_times=get_max_allotted_times(s),
4718
4734
  all_pieces=list(s.kernel.pieceuuid2piece.values()),
4719
4735
  to_play_2=getpublictoplay(s),
@@ -5562,10 +5578,11 @@ def get_default_toplay(s):
5562
5578
  return None
5563
5579
 
5564
5580
 
5581
+ @dispatch(PlayerState)
5565
5582
  def get_intuited_best_actions(ps):
5566
- if not ps.legal_actions_3:
5583
+ if not ps.private.legal_actions_3:
5567
5584
  return None
5568
- return ps.legal_actions_3[:8]
5585
+ return ps.private.legal_actions_3[:8]
5569
5586
 
5570
5587
 
5571
5588
  def get_spread(q_values, p_idx):
@@ -5579,10 +5596,12 @@ def getvproxy0(ps):
5579
5596
  return 0
5580
5597
 
5581
5598
 
5599
+ @dispatch(PlayerState, Action2)
5582
5600
  def imagine_dynamics(ps, a):
5583
5601
  return dynamics(imagine_state(ps), a)
5584
5602
 
5585
5603
 
5604
+ @dispatch(State, Action2)
5586
5605
  def dynamics(s, a):
5587
5606
  scores = get_public_player_scores(s)
5588
5607
  next_s = getnextstate2(s, a)
@@ -5591,6 +5610,7 @@ def dynamics(s, a):
5591
5610
  return next_s, rewards
5592
5611
 
5593
5612
 
5613
+ @dispatch(PlayerState)
5594
5614
  def alpha0(ps):
5595
5615
  td = 3
5596
5616
  legal_actions = ps.legal_actions_3
@@ -5598,7 +5618,7 @@ def alpha0(ps):
5598
5618
  return None
5599
5619
  intuited = get_intuited_best_actions(ps)
5600
5620
  q_proxies = [getqproxy0(ps, a, td) for a in intuited]
5601
- max_spread_idx = get_max_spread_idx(q_proxies, ps.player.player_idx)
5621
+ max_spread_idx = get_max_spread_idx(q_proxies, ps.private.player.player_idx)
5602
5622
  return intuited[max_spread_idx]
5603
5623
 
5604
5624
 
@@ -5608,6 +5628,7 @@ def get_max_spread_idx(q_proxies, p_idx):
5608
5628
  return max_spread_idx
5609
5629
 
5610
5630
 
5631
+ @dispatch(PlayerState, Action2, int)
5611
5632
  def getqproxy0(ps, a, td):
5612
5633
 
5613
5634
  def qproxybase():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.2095
3
+ Version: 0.3.2099
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=aq2Vxkuz1J4LGAPlO8OZtW1Tns81gL68UICMfsZzeHY,199556
3
+ graph_games_proto/fns.py,sha256=c5Vj7Ye-LnNQBbOm7tQg0EWvcinATUSeDLWduCdrHaw,199901
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.2095.dist-info/METADATA,sha256=3B4hZJi4LhHbTKGGFf-y7t0nTc0sQ-w_1rPTCZ0-jyA,188
7
- graph_games_proto-0.3.2095.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.2095.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.2095.dist-info/RECORD,,
6
+ graph_games_proto-0.3.2099.dist-info/METADATA,sha256=tsn8lVkH1Vnv04mvMZhdfh8vRmWeDEW65g-VkZ5GXRQ,188
7
+ graph_games_proto-0.3.2099.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.2099.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.2099.dist-info/RECORD,,