Search code examples
pythondocumentationopenai-gymterminationracing

OpenAI gym CarRacing-v2 episode termination


I am using gym==0.26.0 library and am trying to understand what means that an episode is finished/done in the CarRacing-v2 environment. In the documentation is written this.

### Rewards
The reward is -0.1 every frame and +1000/N for every track tile visited,
where N is the total number of tiles visited in the track. For example,
if you have finished in 732 frames, your reward is
1000 - 0.1*732 = 926.8 points.

### Episode Termination
The episode finishes when all of the tiles are visited. The car can also go
outside of the playfield - that is, far off the track, in which case it will receive -100 reward and die.

How many tiles does the track have? They write that the episode finishes when all of the tiles are visited but I cannnot find how many tiles does the track have. And is there a limit on how many steps can each episode have?

https://github.com/openai/gym/blob/master/gym/envs/box2d/car_racing.py https://www.gymlibrary.dev/environments/box2d/car_racing/


Solution

  • The maximum number of steps is 1000 per episode. It seems unclear how many track tiles each episode has.

    You can get more information calling .spec

    gym.make("CarRacing-v2").spec
    
    spec: EnvSpec(id='CarRacing-v2', entry_point='gymnasium.envs.box2d.car_racing:CarRacing', reward_threshold=900, nondeterministic=False, max_episode_steps=1000, order_enforce=True, autoreset=False, disable_env_checker=False, apply_api_compatibility=False, kwargs={'continuous': False, 'render_mode': None}, namespace=None, name='CarRacing', version=2)