graph-games-proto 0.3.1902__py3-none-any.whl → 0.3.1905__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 +86 -14
- {graph_games_proto-0.3.1902.dist-info → graph_games_proto-0.3.1905.dist-info}/METADATA +1 -1
- {graph_games_proto-0.3.1902.dist-info → graph_games_proto-0.3.1905.dist-info}/RECORD +5 -5
- {graph_games_proto-0.3.1902.dist-info → graph_games_proto-0.3.1905.dist-info}/WHEEL +0 -0
- {graph_games_proto-0.3.1902.dist-info → graph_games_proto-0.3.1905.dist-info}/top_level.txt +0 -0
graph_games_proto/fns.py
CHANGED
@@ -2972,6 +2972,49 @@ def handle_draw_discard_action(game, action):
|
|
2972
2972
|
)
|
2973
2973
|
|
2974
2974
|
|
2975
|
+
def get_follow_up_draw_legal_actions(game, action):
|
2976
|
+
to_return = []
|
2977
|
+
legal_action = action.legal_action
|
2978
|
+
if len(game.history) >= 2:
|
2979
|
+
last_action = game.history[-2]
|
2980
|
+
if (last_action.legal_action.player_idx != legal_action.player_idx) or last_action.legal_action.name == "INITIAL-GOAL-KEEP":
|
2981
|
+
|
2982
|
+
if len(game.decks[0].facedown_stack) >= 1:
|
2983
|
+
to_return.append(
|
2984
|
+
LegalAction(
|
2985
|
+
auto_preferred=True,
|
2986
|
+
player_idx=legal_action.player_idx,
|
2987
|
+
name="DRAW",
|
2988
|
+
instruction="draw a unit",
|
2989
|
+
allotted_seconds=DEFAULT_ALLOTTED_SECONDS,
|
2990
|
+
allotted_since_action_idx=(len(game.history) - 1),
|
2991
|
+
draw=LegalActionDraw(
|
2992
|
+
deck_idx=0,
|
2993
|
+
quantity=1,
|
2994
|
+
)
|
2995
|
+
)
|
2996
|
+
)
|
2997
|
+
|
2998
|
+
for card_uuid in game.decks[0].faceup_spots:
|
2999
|
+
if card_uuid:
|
3000
|
+
if not game.carduuid2card[card_uuid].is_wild:
|
3001
|
+
to_return.append(
|
3002
|
+
LegalAction(
|
3003
|
+
player_idx=legal_action.player_idx,
|
3004
|
+
name="FACEUP-DRAW",
|
3005
|
+
instruction="draw a faceup unit",
|
3006
|
+
allotted_seconds=DEFAULT_ALLOTTED_SECONDS,
|
3007
|
+
allotted_since_action_idx=(len(game.history) - 1),
|
3008
|
+
faceup_draw=LegalActionFaceupDraw(
|
3009
|
+
deck_idx=0,
|
3010
|
+
card_uuid=card_uuid,
|
3011
|
+
)
|
3012
|
+
)
|
3013
|
+
)
|
3014
|
+
|
3015
|
+
return to_return
|
3016
|
+
|
3017
|
+
|
2975
3018
|
def append_follow_up_draw_legal_actions(game, action):
|
2976
3019
|
legal_action = action.legal_action
|
2977
3020
|
if len(game.history) >= 2:
|
@@ -4036,9 +4079,9 @@ def isactionlegal2(s, a):
|
|
4036
4079
|
|
4037
4080
|
def calc_legal_actions3(state_kernal):
|
4038
4081
|
history = state_kernal.history
|
4082
|
+
last_action = history[-1] if len(history) > 0 else None
|
4039
4083
|
|
4040
|
-
if
|
4041
|
-
# Initial
|
4084
|
+
if last_action is None:
|
4042
4085
|
return [
|
4043
4086
|
LegalAction(
|
4044
4087
|
player_idx=player.idx,
|
@@ -4054,19 +4097,48 @@ def calc_legal_actions3(state_kernal):
|
|
4054
4097
|
for player in state_kernal.players
|
4055
4098
|
]
|
4056
4099
|
|
4057
|
-
|
4058
|
-
|
4059
|
-
|
4060
|
-
|
4061
|
-
|
4062
|
-
|
4063
|
-
|
4064
|
-
last_player_idx = last_action.legal_action.player_idx
|
4065
|
-
last_player_shuffled_idx = last_action.player_idxs.index(last_player_idx)
|
4066
|
-
next_player_shuffled_idx = (last_player_shuffled_idx + 1) % len(last_action.player_idxs)
|
4067
|
-
return get_default_legal_actions(state_kernal, state_kernal.player_idxs[next_player_shuffled_idx])
|
4100
|
+
elif last_action.legal_action.faceup_draw:
|
4101
|
+
faceup_draw = last_action.legal_action.faceup_draw
|
4102
|
+
deck = state_kernal.decks[faceup_draw.deck_idx]
|
4103
|
+
spot_idx = next((i for i, card_uuid in enumerate(deck.faceup_spots) if card_uuid == faceup_draw.card_uuid), None)
|
4104
|
+
drawn_card = deck.faceup_spots[spot_idx] if spot_idx is not None else None
|
4105
|
+
if not state_kernal.carduuid2card[drawn_card].is_wild:
|
4106
|
+
return get_follow_up_draw_legal_actions(state_kernal, last_action)
|
4068
4107
|
|
4069
|
-
|
4108
|
+
elif last_action.legal_action.draw:
|
4109
|
+
if last_action.legal_action.draw.quantity == 1:
|
4110
|
+
return get_follow_up_draw_legal_actions(state_kernal, last_action)
|
4111
|
+
|
4112
|
+
elif last_action.legal_action.draw_discard:
|
4113
|
+
draw_discard = last_action.legal_action.draw_discard
|
4114
|
+
player = state_kernal.players[last_action.legal_action.player_idx]
|
4115
|
+
return [
|
4116
|
+
LegalAction(
|
4117
|
+
player_idx=player.idx,
|
4118
|
+
name="GOAL-KEEP",
|
4119
|
+
instruction="Your move. Please select the routes you want to keep.",
|
4120
|
+
allotted_seconds=INITIAL_ALLOTTED_SECONDS,
|
4121
|
+
allotted_since_action_idx=(len(state_kernal.history) - 1),
|
4122
|
+
keep=LegalActionKeep(
|
4123
|
+
deck_idx=draw_discard.deck_idx,
|
4124
|
+
min=draw_discard.min,
|
4125
|
+
max=draw_discard.max,
|
4126
|
+
)
|
4127
|
+
)
|
4128
|
+
]
|
4129
|
+
|
4130
|
+
if last_action.legal_action.name == "INITIAL-GOAL-KEEP":
|
4131
|
+
return get_default_legal_actions(state_kernal, state_kernal.player_idxs[0])
|
4132
|
+
|
4133
|
+
next_player_idx = get_next_player_shuffled_idx(state_kernal, last_action)
|
4134
|
+
return get_default_legal_actions(state_kernal, state_kernal.player_idxs[next_player_idx])
|
4135
|
+
|
4136
|
+
|
4137
|
+
def get_next_player_shuffled_idx(state_kernal, last_action):
|
4138
|
+
last_player_idx = last_action.legal_action.player_idx
|
4139
|
+
last_player_shuffled_idx = state_kernal.player_idxs.index(last_player_idx)
|
4140
|
+
next_player_shuffled_idx = (last_player_shuffled_idx + 1) % len(state_kernal.player_idxs)
|
4141
|
+
return next_player_shuffled_idx
|
4070
4142
|
|
4071
4143
|
|
4072
4144
|
class StateKernal(PClass):
|
@@ -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=_NOoU958Q_W5w40CBDIhaeg-h3V1E253NTvjOw2cii4,192148
|
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.1905.dist-info/METADATA,sha256=lnlzJE-qXiGmg9zk1VnkdSlnKHHzVwEJ1t1kcTZDTjM,188
|
7
|
+
graph_games_proto-0.3.1905.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
8
|
+
graph_games_proto-0.3.1905.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
|
9
|
+
graph_games_proto-0.3.1905.dist-info/RECORD,,
|
File without changes
|
File without changes
|