Check if an `env`'s observation and action spaces are continuous. Parameters ---------- env : ``gym.wrappers`` or ``gym.envs`` instance The environment to evaluate. tuple_action : bool Whether the `env`'s action space is an instance of `gym.spaces.Tuple`
(env, tuple_action, tuple_obs)
| 295 | |
| 296 | |
| 297 | def is_continuous(env, tuple_action, tuple_obs): |
| 298 | """ |
| 299 | Check if an `env`'s observation and action spaces are continuous. |
| 300 | |
| 301 | Parameters |
| 302 | ---------- |
| 303 | env : ``gym.wrappers`` or ``gym.envs`` instance |
| 304 | The environment to evaluate. |
| 305 | tuple_action : bool |
| 306 | Whether the `env`'s action space is an instance of `gym.spaces.Tuple` |
| 307 | or `gym.spaces.Dict`. |
| 308 | tuple_obs : bool |
| 309 | Whether the `env`'s observation space is an instance of `gym.spaces.Tuple` |
| 310 | or `gym.spaces.Dict`. |
| 311 | |
| 312 | Returns |
| 313 | ------- |
| 314 | cont_action : bool |
| 315 | Whether the `env`'s action space is continuous. |
| 316 | cont_obs : bool |
| 317 | Whether the `env`'s observation space is continuous. |
| 318 | """ |
| 319 | Continuous = gym.spaces.box.Box |
| 320 | if tuple_obs: |
| 321 | spaces = env.observation_space.spaces |
| 322 | cont_obs = all(isinstance(s, Continuous) for s in spaces) |
| 323 | else: |
| 324 | cont_obs = isinstance(env.observation_space, Continuous) |
| 325 | |
| 326 | if tuple_action: |
| 327 | spaces = env.action_space.spaces |
| 328 | cont_action = all(isinstance(s, Continuous) for s in spaces) |
| 329 | else: |
| 330 | cont_action = isinstance(env.action_space, Continuous) |
| 331 | return cont_action, cont_obs |
| 332 | |
| 333 | |
| 334 | def action_stats(env, md_action, cont_action): |