This environment is part of the Toy Text environments. Please read that page first for general information.

Action Space


Observation Space




The Taxi Problem from “Hierarchical Reinforcement Learning with the MAXQ Value Function Decomposition” by Tom Dietterich


There are four designated locations in the grid world indicated by R(ed), G(reen), Y(ellow), and B(lue). When the episode starts, the taxi starts off at a random square and the passenger is at a random location. The taxi drives to the passenger’s location, picks up the passenger, drives to the passenger’s destination (another one of the four specified locations), and then drops off the passenger. Once the passenger is dropped off, the episode ends.


|R: | : :G|
| : | : : |
| : : : : |
| | : | : |
|Y| : |B: |


There are 6 discrete deterministic actions:

  • 0: move south

  • 1: move north

  • 2: move east

  • 3: move west

  • 4: pickup passenger

  • 5: drop off passenger


There are 500 discrete states since there are 25 taxi positions, 5 possible locations of the passenger (including the case when the passenger is in the taxi), and 4 destination locations.

Note that there are 400 states that can actually be reached during an episode. The missing states correspond to situations in which the passenger is at the same location as their destination, as this typically signals the end of an episode. Four additional states can be observed right after a successful episodes, when both the passenger and the taxi are at the destination. This gives a total of 404 reachable discrete states.

Each state space is represented by the tuple: (taxi_row, taxi_col, passenger_location, destination)

An observation is an integer that encodes the corresponding state. The state tuple can then be decoded with the “decode” method.

Passenger locations:

  • 0: R(ed)

  • 1: G(reen)

  • 2: Y(ellow)

  • 3: B(lue)

  • 4: in taxi


  • 0: R(ed)

  • 1: G(reen)

  • 2: Y(ellow)

  • 3: B(lue)


  • -1 per step unless other reward is triggered.

  • +20 delivering passenger.

  • -10 executing “pickup” and “drop-off” actions illegally.



Version History#

  • v3: Map Correction + Cleaner Domain Description

  • v2: Disallow Taxi start location = goal location, Update Taxi observations in the rollout, Update Taxi reward threshold.

  • v1: Remove (3,2) from locs, add passidx<4 check

  • v0: Initial versions release