Batch JAX differential verification
This commit is contained in:
@@ -129,10 +129,12 @@ def legal_action_mask(state: RefState) -> list[bool]:
|
||||
return mask
|
||||
|
||||
|
||||
def step(state: RefState, action: int) -> tuple[RefState, list[float], bool]:
|
||||
def step(
|
||||
state: RefState, action: int, *, validate: bool = True
|
||||
) -> tuple[RefState, list[float], bool]:
|
||||
if state.done or action < 0 or action >= N_ACTIONS:
|
||||
return clone_state(state), [0.0, 0.0], state.done
|
||||
if not legal_action_mask(state)[action]:
|
||||
if validate and not legal_action_mask(state)[action]:
|
||||
return clone_state(state), [0.0, 0.0], state.done
|
||||
|
||||
next_state = clone_state(state)
|
||||
|
||||
Reference in New Issue
Block a user