OpenAI Gym: Understanding `action_space` notation (spaces.Box)

Toke Faurby picture Toke Faurby · Jun 7, 2017 · Viewed 13.7k times · Source

I want to setup an RL agent on the OpenAI CarRacing-v0 environment, but before that I want to understand the action space. In the code on github line 119 says:

self.action_space = spaces.Box( np.array([-1,0,0]), np.array([+1,+1,+1]))  # steer, gas, brake

How do I read this line? Although my problem is concrete wrt CarRacing-v0 I would like to understand the spaces.Box() notation in general

Answer

Toke Faurby picture Toke Faurby · Jun 7, 2017

Box means that you are dealing with real valued quantities.

The first array np.array([-1,0,0] are the lowest accepted values, and the second np.array([+1,+1,+1]) are the highest accepted values. In this case (using the comment) we see that we have 3 available actions:

  1. Steering: Real valued in [-1, 1]
  2. Gas: Real valued in [0, 1]
  3. Brake: Real valued in [0, 1]