38

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

Toke Faurby
  • 5,788
  • 9
  • 41
  • 62

1 Answers1

59

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]
TripleAntigen
  • 2,221
  • 1
  • 31
  • 44
Toke Faurby
  • 5,788
  • 9
  • 41
  • 62
  • What is the shape of `self.action_space = spaces.Box( np.array([-1,0,0]), np.array([+1,+1,+1])) # steer, gas, brake`? Is it correct self.action_space.shape == [2, 3]? – Artod Jan 24 '22 at 20:54
  • 1
    I ran a test and it gave me (3,). So essentially `self.action_space.shape` returns the number of actions at least for the continuous actions, right? – Artod Jan 24 '22 at 21:03