graph-games-proto 0.3.2096__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 +45 -26
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2099.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2099.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2099.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.2096.dist-info → graph_games_proto-0.3.2099.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)
|
@@ -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[
|
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=[
|
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"]],
|
@@ -4623,40 +4634,43 @@ def get_public_history(s):
|
|
4623
4634
|
return [action.get_public(s) for action in s.kernel.history]
|
4624
4635
|
|
4625
4636
|
|
4626
|
-
|
4637
|
+
@dispatch(PlayerState)
|
4638
|
+
def imagine_history(ps) -> list[Action2]:
|
4627
4639
|
pass
|
4628
4640
|
|
4629
|
-
def imagine_player_scores(public_state, private_state):
|
4630
|
-
pass
|
4631
4641
|
|
4632
|
-
|
4642
|
+
@dispatch(PlayerState)
|
4643
|
+
def imagine_players(ps) -> list[Player]:
|
4633
4644
|
pass
|
4634
4645
|
|
4635
|
-
def imagine_players(public_state, private_state):
|
4636
|
-
pass
|
4637
4646
|
|
4638
|
-
|
4647
|
+
@dispatch(PlayerState)
|
4648
|
+
def imagine_decks(ps) -> list[Deck]:
|
4639
4649
|
pass
|
4640
4650
|
|
4641
4651
|
|
4642
|
-
|
4643
|
-
|
4652
|
+
@dispatch(PlayerState)
|
4653
|
+
def imagine_state(ps):
|
4654
|
+
public = ps.public
|
4655
|
+
game_config = public.game_config
|
4656
|
+
|
4657
|
+
# candidates = get_candidates(ps)
|
4644
4658
|
|
4645
4659
|
imagined_kernel = init_state_kernel(
|
4646
4660
|
GameConfig(
|
4647
4661
|
seed=random.randint(0, 2**31 - 1),
|
4648
|
-
uuid=
|
4649
|
-
num_players=
|
4650
|
-
fig=
|
4651
|
-
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,
|
4652
4666
|
),
|
4653
|
-
edges=
|
4654
|
-
nodes=
|
4655
|
-
piles=
|
4656
|
-
player_idxs=
|
4657
|
-
decks=imagine_decks(
|
4658
|
-
players=imagine_players(
|
4659
|
-
history=imagine_history(
|
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),
|
4660
4674
|
)
|
4661
4675
|
return init_memoized_state(imagined_kernel)
|
4662
4676
|
|
@@ -5564,10 +5578,11 @@ def get_default_toplay(s):
|
|
5564
5578
|
return None
|
5565
5579
|
|
5566
5580
|
|
5581
|
+
@dispatch(PlayerState)
|
5567
5582
|
def get_intuited_best_actions(ps):
|
5568
|
-
if not ps.legal_actions_3:
|
5583
|
+
if not ps.private.legal_actions_3:
|
5569
5584
|
return None
|
5570
|
-
return ps.legal_actions_3[:8]
|
5585
|
+
return ps.private.legal_actions_3[:8]
|
5571
5586
|
|
5572
5587
|
|
5573
5588
|
def get_spread(q_values, p_idx):
|
@@ -5581,10 +5596,12 @@ def getvproxy0(ps):
|
|
5581
5596
|
return 0
|
5582
5597
|
|
5583
5598
|
|
5599
|
+
@dispatch(PlayerState, Action2)
|
5584
5600
|
def imagine_dynamics(ps, a):
|
5585
5601
|
return dynamics(imagine_state(ps), a)
|
5586
5602
|
|
5587
5603
|
|
5604
|
+
@dispatch(State, Action2)
|
5588
5605
|
def dynamics(s, a):
|
5589
5606
|
scores = get_public_player_scores(s)
|
5590
5607
|
next_s = getnextstate2(s, a)
|
@@ -5593,6 +5610,7 @@ def dynamics(s, a):
|
|
5593
5610
|
return next_s, rewards
|
5594
5611
|
|
5595
5612
|
|
5613
|
+
@dispatch(PlayerState)
|
5596
5614
|
def alpha0(ps):
|
5597
5615
|
td = 3
|
5598
5616
|
legal_actions = ps.legal_actions_3
|
@@ -5600,7 +5618,7 @@ def alpha0(ps):
|
|
5600
5618
|
return None
|
5601
5619
|
intuited = get_intuited_best_actions(ps)
|
5602
5620
|
q_proxies = [getqproxy0(ps, a, td) for a in intuited]
|
5603
|
-
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)
|
5604
5622
|
return intuited[max_spread_idx]
|
5605
5623
|
|
5606
5624
|
|
@@ -5610,6 +5628,7 @@ def get_max_spread_idx(q_proxies, p_idx):
|
|
5610
5628
|
return max_spread_idx
|
5611
5629
|
|
5612
5630
|
|
5631
|
+
@dispatch(PlayerState, Action2, int)
|
5613
5632
|
def getqproxy0(ps, a, td):
|
5614
5633
|
|
5615
5634
|
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=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.
|
7
|
-
graph_games_proto-0.3.
|
8
|
-
graph_games_proto-0.3.
|
9
|
-
graph_games_proto-0.3.
|
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,,
|
File without changes
|
File without changes
|