1414
1515acrobot_v_router = APIRouter (prefix = "/gymnasium/acrobot-env/v" , tags = ["Acrobot Vector env API" ])
1616
17-
1817NUM_COPIES = 0
1918ENV_NAME = "Acrobot"
2019VECTORIZATION_MODE = 'sync'
2423 0 : None
2524}
2625
27-
2826# actions that the environment accepts
2927ACTIONS_SPACE = {0 : "apply -1 torque to the actuated joint" ,
3028 1 : "apply 0 torque to the actuated joint" ,
@@ -164,7 +162,6 @@ async def reset(seed: int = Body(default=42), cidx: int = Body(...),
164162
165163@acrobot_v_router .post ("/step" )
166164async def step (action : dict [str , list [int ]] = Body (title = 'actions' ), cidx : int = Body (...)) -> JSONResponse :
167-
168165 global NUM_COPIES
169166
170167 actions = action ['actions' ]
@@ -191,17 +188,20 @@ async def step(action: dict[str, list[int]] = Body(title='actions'), cidx: int =
191188
192189 # if we truncate or terminate
193190 # set the environment step type to finished
194- for i , tr in enumerate (truncates ):
195- if tr :
196- step_types [i ] = TimeStepType .LAST
191+ for i , tr in enumerate (terminates ):
192+ # if tr:
193+ # step_types[i] = TimeStepType.LAST
197194
198195 if terminates [i ]:
199196 step_types [i ] = TimeStepType .LAST
200197
198+ for i in truncates :
199+ infos [i ]['truncated' ] = truncates [i ]
200+
201201 step = TimeStepV (observations = observations_ar ,
202202 rewards = rewards ,
203203 step_types = step_types ,
204- infos = [] ,
204+ infos = infos ,
205205 discounts = [1.0 ] * NUM_COPIES )
206206
207207 logger .info (f'Step in environment { ENV_NAME } and index { cidx } ' )
0 commit comments