graph-games-proto 0.3.2096__py3-none-any.whl → 0.3.2100__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 +45 -34
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2100.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2100.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2100.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2100.dist-info}/top_level.txt +0 -0
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)
|
@@ -1159,7 +1170,6 @@ class PrivateState(PClass):
|
|
1159
1170
|
class PublicDeck(PClass):
|
1160
1171
|
idx = field(type=int)
|
1161
1172
|
uuid = field(type=str)
|
1162
|
-
units = field(type=list) # List[Card]
|
1163
1173
|
facedown_stack_len = field(type=int)
|
1164
1174
|
discard_len = field(type=int)
|
1165
1175
|
faceup_spots = field(type=list) # List[Card]
|
@@ -1167,7 +1177,6 @@ class PublicDeck(PClass):
|
|
1167
1177
|
return {
|
1168
1178
|
"idx": self.idx,
|
1169
1179
|
"uuid": self.uuid,
|
1170
|
-
"units": [unit.__todict__() for unit in self.units],
|
1171
1180
|
"facedown_stack_len": self.facedown_stack_len,
|
1172
1181
|
"discard_len": self.discard_len,
|
1173
1182
|
"faceup_spots": self.faceup_spots,
|
@@ -1177,7 +1186,6 @@ class PublicDeck(PClass):
|
|
1177
1186
|
return PublicDeck(
|
1178
1187
|
idx=d["idx"],
|
1179
1188
|
uuid=d["uuid"],
|
1180
|
-
units=[Card.__fromdict__(card) for card in d["units"]],
|
1181
1189
|
facedown_stack_len=d["facedown_stack_len"],
|
1182
1190
|
discard_len=d["discard_len"],
|
1183
1191
|
faceup_spots=d["faceup_spots"],
|
@@ -1679,7 +1687,6 @@ class Action2(PClass):
|
|
1679
1687
|
class Deck(PClass):
|
1680
1688
|
idx = field(type=int)
|
1681
1689
|
uuid = field(type=str)
|
1682
|
-
units = field(type=list) # List[Card]
|
1683
1690
|
facedown_stack = field(type=list) # List[str]
|
1684
1691
|
discard = field(type=list) # List[str]
|
1685
1692
|
faceup_spots = field(type=list) # List[str]
|
@@ -1687,7 +1694,6 @@ class Deck(PClass):
|
|
1687
1694
|
return {
|
1688
1695
|
"idx": self.idx,
|
1689
1696
|
"uuid": self.uuid,
|
1690
|
-
"units": [unit.__todict__() for unit in self.units],
|
1691
1697
|
"facedown_stack": self.facedown_stack,
|
1692
1698
|
"discard": self.discard,
|
1693
1699
|
"faceup_spots": self.faceup_spots,
|
@@ -1697,7 +1703,6 @@ class Deck(PClass):
|
|
1697
1703
|
return Deck(
|
1698
1704
|
idx=d["idx"],
|
1699
1705
|
uuid=d["uuid"],
|
1700
|
-
units=[], # TODO: Card.__fromdict__(card) for card in d["cards"]
|
1701
1706
|
facedown_stack=d["facedown_stack"],
|
1702
1707
|
discard=d["discard"],
|
1703
1708
|
faceup_spots=d["faceup_spots"],
|
@@ -2091,7 +2096,7 @@ class StateKernel(PClass):
|
|
2091
2096
|
piles = field(type=list) # List[Pile]
|
2092
2097
|
players = field(type=list) # List[Player]
|
2093
2098
|
player_idxs = field(type=list) # List[int]
|
2094
|
-
history = field(type=list) # List[
|
2099
|
+
history = field(type=list) # List[Action2]
|
2095
2100
|
pieceuuid2piece = field(type=dict) # Dict[str, Piece]
|
2096
2101
|
edgeuuid2idx = field(type=dict) # Dict[str, int]
|
2097
2102
|
carduuid2card = field(type=dict) # Dict[str, Card]
|
@@ -2144,7 +2149,7 @@ class StateKernel(PClass):
|
|
2144
2149
|
piles=[Pile.__fromdict__(pile) for pile in d["piles"]],
|
2145
2150
|
players=[Player.__fromdict__(player) for player in d["players"]],
|
2146
2151
|
player_idxs=d["player_idxs"],
|
2147
|
-
history=[
|
2152
|
+
history=[Action2.__fromdict__(action) for action in d["history"]],
|
2148
2153
|
uuid2edgerecord={k: BiEdgeRecord.__fromdict__(v) for k, v in d["uuid2edgerecord"].items()},
|
2149
2154
|
uuid2segmentrecord={k: Segment2.__fromdict__(v) for k, v in d["uuid2segmentrecord"].items()},
|
2150
2155
|
idx2pathrecord=[Path2.__fromdict(v) for v in d["idx2pathrecord"]],
|
@@ -2226,7 +2231,6 @@ def init_state_kernel(game_config, **kwargs):
|
|
2226
2231
|
deck_obj = Deck(
|
2227
2232
|
uuid=dek.uuid,
|
2228
2233
|
idx=dek.idx,
|
2229
|
-
units=[],
|
2230
2234
|
faceup_spots=[],
|
2231
2235
|
discard=[],
|
2232
2236
|
facedown_stack=[card.uuid for card in cards],
|
@@ -4623,40 +4627,43 @@ def get_public_history(s):
|
|
4623
4627
|
return [action.get_public(s) for action in s.kernel.history]
|
4624
4628
|
|
4625
4629
|
|
4626
|
-
|
4630
|
+
@dispatch(PlayerState)
|
4631
|
+
def imagine_history(ps) -> list[Action2]:
|
4627
4632
|
pass
|
4628
4633
|
|
4629
|
-
def imagine_player_scores(public_state, private_state):
|
4630
|
-
pass
|
4631
4634
|
|
4632
|
-
|
4635
|
+
@dispatch(PlayerState)
|
4636
|
+
def imagine_players(ps) -> list[Player]:
|
4633
4637
|
pass
|
4634
4638
|
|
4635
|
-
def imagine_players(public_state, private_state):
|
4636
|
-
pass
|
4637
4639
|
|
4638
|
-
|
4640
|
+
@dispatch(PlayerState)
|
4641
|
+
def imagine_decks(ps) -> list[Deck]:
|
4639
4642
|
pass
|
4640
4643
|
|
4641
4644
|
|
4642
|
-
|
4643
|
-
|
4645
|
+
@dispatch(PlayerState)
|
4646
|
+
def imagine_state(ps):
|
4647
|
+
public = ps.public
|
4648
|
+
game_config = public.game_config
|
4649
|
+
|
4650
|
+
# candidates = get_candidates(ps)
|
4644
4651
|
|
4645
4652
|
imagined_kernel = init_state_kernel(
|
4646
4653
|
GameConfig(
|
4647
4654
|
seed=random.randint(0, 2**31 - 1),
|
4648
|
-
uuid=
|
4649
|
-
num_players=
|
4650
|
-
fig=
|
4651
|
-
started_at=
|
4655
|
+
uuid=game_config.uuid,
|
4656
|
+
num_players=game_config.num_players,
|
4657
|
+
fig=game_config.fig,
|
4658
|
+
started_at=game_config.started_at,
|
4652
4659
|
),
|
4653
|
-
edges=
|
4654
|
-
nodes=
|
4655
|
-
piles=
|
4656
|
-
player_idxs=
|
4657
|
-
decks=imagine_decks(
|
4658
|
-
players=imagine_players(
|
4659
|
-
history=imagine_history(
|
4660
|
+
edges=public.edges,
|
4661
|
+
nodes=public.nodes,
|
4662
|
+
piles=public.piles,
|
4663
|
+
player_idxs=public.player_idxs,
|
4664
|
+
decks=imagine_decks(ps),
|
4665
|
+
players=imagine_players(ps),
|
4666
|
+
history=imagine_history(ps),
|
4660
4667
|
)
|
4661
4668
|
return init_memoized_state(imagined_kernel)
|
4662
4669
|
|
@@ -4744,7 +4751,6 @@ def getpublicdeck(s, d):
|
|
4744
4751
|
return PublicDeck(
|
4745
4752
|
idx=d.idx,
|
4746
4753
|
uuid=d.uuid,
|
4747
|
-
units=d.units,
|
4748
4754
|
facedown_stack_len=len(d.facedown_stack),
|
4749
4755
|
discard_len=len(d.discard),
|
4750
4756
|
faceup_spots=d.faceup_spots,
|
@@ -5564,10 +5570,11 @@ def get_default_toplay(s):
|
|
5564
5570
|
return None
|
5565
5571
|
|
5566
5572
|
|
5573
|
+
@dispatch(PlayerState)
|
5567
5574
|
def get_intuited_best_actions(ps):
|
5568
|
-
if not ps.legal_actions_3:
|
5575
|
+
if not ps.private.legal_actions_3:
|
5569
5576
|
return None
|
5570
|
-
return ps.legal_actions_3[:8]
|
5577
|
+
return ps.private.legal_actions_3[:8]
|
5571
5578
|
|
5572
5579
|
|
5573
5580
|
def get_spread(q_values, p_idx):
|
@@ -5581,10 +5588,12 @@ def getvproxy0(ps):
|
|
5581
5588
|
return 0
|
5582
5589
|
|
5583
5590
|
|
5591
|
+
@dispatch(PlayerState, Action2)
|
5584
5592
|
def imagine_dynamics(ps, a):
|
5585
5593
|
return dynamics(imagine_state(ps), a)
|
5586
5594
|
|
5587
5595
|
|
5596
|
+
@dispatch(State, Action2)
|
5588
5597
|
def dynamics(s, a):
|
5589
5598
|
scores = get_public_player_scores(s)
|
5590
5599
|
next_s = getnextstate2(s, a)
|
@@ -5593,6 +5602,7 @@ def dynamics(s, a):
|
|
5593
5602
|
return next_s, rewards
|
5594
5603
|
|
5595
5604
|
|
5605
|
+
@dispatch(PlayerState)
|
5596
5606
|
def alpha0(ps):
|
5597
5607
|
td = 3
|
5598
5608
|
legal_actions = ps.legal_actions_3
|
@@ -5600,7 +5610,7 @@ def alpha0(ps):
|
|
5600
5610
|
return None
|
5601
5611
|
intuited = get_intuited_best_actions(ps)
|
5602
5612
|
q_proxies = [getqproxy0(ps, a, td) for a in intuited]
|
5603
|
-
max_spread_idx = get_max_spread_idx(q_proxies, ps.player.player_idx)
|
5613
|
+
max_spread_idx = get_max_spread_idx(q_proxies, ps.private.player.player_idx)
|
5604
5614
|
return intuited[max_spread_idx]
|
5605
5615
|
|
5606
5616
|
|
@@ -5610,6 +5620,7 @@ def get_max_spread_idx(q_proxies, p_idx):
|
|
5610
5620
|
return max_spread_idx
|
5611
5621
|
|
5612
5622
|
|
5623
|
+
@dispatch(PlayerState, Action2, int)
|
5613
5624
|
def getqproxy0(ps, a, td):
|
5614
5625
|
|
5615
5626
|
def qproxybase():
|
@@ -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=q656HgMAmHaIlbYI1lBYZLLTvRfa7X9tfCUoC-oQINI,199495
|
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.2100.dist-info/METADATA,sha256=rpyhU4WzhqGJrINJ3gDW4851KSujWfNJX3sF5ZwJnBo,188
|
7
|
+
graph_games_proto-0.3.2100.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.2100.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.2100.dist-info/RECORD,,
|
File without changes
|
File without changes
|