@@ -137,7 +137,7 @@ def action_to_order(
137
137
and battle .force_switch == [True , True ]
138
138
and 1 <= action [0 ] <= 6
139
139
and 1 <= action [1 ] <= 6
140
- )
140
+ ), "invalid action"
141
141
order1 = DoublesEnv ._action_to_order_individual (action [0 ], battle , fake , 0 )
142
142
order2 = DoublesEnv ._action_to_order_individual (action [1 ], battle , fake , 1 )
143
143
joined_orders = DoubleBattleOrder .join_orders (
@@ -159,6 +159,9 @@ def action_to_order(
159
159
def _action_to_order_individual (
160
160
action : np .int64 , battle : DoubleBattle , fake : bool , pos : int
161
161
) -> Optional [BattleOrder ]:
162
+ assert (
163
+ battle .force_switch != [[False , True ], [True , False ]][pos ] or action == 0
164
+ ), "invalid action"
162
165
if action == 0 :
163
166
order = None
164
167
elif action < 7 :
@@ -243,7 +246,7 @@ def order_to_action(
243
246
and battle .force_switch == [True , True ]
244
247
and isinstance (order .first_order , Pokemon )
245
248
and isinstance (order .second_order , Pokemon )
246
- )
249
+ ), "invalid order"
247
250
action1 = DoublesEnv ._order_to_action_individual (
248
251
order .first_order , battle , fake , 0
249
252
)
@@ -261,6 +264,9 @@ def order_to_action(
261
264
def _order_to_action_individual (
262
265
order : Optional [BattleOrder ], battle : DoubleBattle , fake : bool , pos : int
263
266
) -> np .int64 :
267
+ assert (
268
+ battle .force_switch != [[False , True ], [True , False ]][pos ] or order is None
269
+ ), "invalid order"
264
270
if order is None :
265
271
action = 0
266
272
elif isinstance (order , DefaultBattleOrder ):
0 commit comments