We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Taxi environment doesn't match paper
![image](https://user-images.githubusercontent.com/11912669/63098742-89f7ab00-bf41-11e9-8d95-d4936dbd189a.png)

The map implemented in Taxi-v2 differs slightly from the one in the original paper (shown above). Namely, the paper example has a wall that prevents transitioning from (1,1) to (1,2), but the gym environment implemented doesn't. Any reason for that?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gym/envs/toy_text/taxi.py`
Content:
```
1 import sys
2 from contextlib import closing
3 from six import StringIO
4 from gym import utils
5 from gym.envs.toy_text import discrete
6 import numpy as np
7 
8 MAP = [
9     "+---------+",
10     "|R: | : :G|",
11     "| : : : : |",
12     "| : : : : |",
13     "| | : | : |",
14     "|Y| : |B: |",
15     "+---------+",
16 ]
17 
18 
19 class TaxiEnv(discrete.DiscreteEnv):
20     """
21     The Taxi Problem
22     from "Hierarchical Reinforcement Learning with the MAXQ Value Function Decomposition"
23     by Tom Dietterich
24 
25     Description:
26     There are four designated locations in the grid world indicated by R(ed), B(lue), G(reen), and Y(ellow). When the episode starts, the taxi starts off at a random square and the passenger is at a random location. The taxi drive to the passenger's location, pick up the passenger, drive to the passenger's destination (another one of the four specified locations), and then drop off the passenger. Once the passenger is dropped off, the episode ends.
27 
28     Observations: 
29     There are 500 discrete states since there are 25 taxi positions, 5 possible locations of the passenger (including the case when the passenger is the taxi), and 4 destination locations. 
30     
31     Actions: 
32     There are 6 discrete deterministic actions:
33     - 0: move south
34     - 1: move north
35     - 2: move east 
36     - 3: move west 
37     - 4: pickup passenger
38     - 5: dropoff passenger
39     
40     Rewards: 
41     There is a reward of -1 for each action and an additional reward of +20 for delievering the passenger. There is a reward of -10 for executing actions "pickup" and "dropoff" illegally.
42     
43 
44     Rendering:
45     - blue: passenger
46     - magenta: destination
47     - yellow: empty taxi
48     - green: full taxi
49     - other letters (R, G, B and Y): locations for passengers and destinations
50 
51     actions:
52     - 0: south
53     - 1: north
54     - 2: east
55     - 3: west
56     - 4: pickup
57     - 5: dropoff
58 
59     state space is represented by:
60         (taxi_row, taxi_col, passenger_location, destination)
61     """
62     metadata = {'render.modes': ['human', 'ansi']}
63 
64     def __init__(self):
65         self.desc = np.asarray(MAP, dtype='c')
66 
67         self.locs = locs = [(0,0), (0,4), (4,0), (4,3)]
68 
69         num_states = 500
70         num_rows = 5
71         num_columns = 5
72         max_row = num_rows - 1
73         max_col = num_columns - 1
74         initial_state_distrib = np.zeros(num_states)
75         num_actions = 6
76         P = {state: {action: []
77                      for action in range(num_actions)} for state in range(num_states)}
78         for row in range(num_rows):
79             for col in range(num_columns):
80                 for pass_idx in range(len(locs) + 1):  # +1 for being inside taxi
81                     for dest_idx in range(len(locs)):
82                         state = self.encode(row, col, pass_idx, dest_idx)
83                         if pass_idx < 4 and pass_idx != dest_idx:
84                             initial_state_distrib[state] += 1
85                         for action in range(num_actions):
86                             # defaults
87                             new_row, new_col, new_pass_idx = row, col, pass_idx
88                             reward = -1 # default reward when there is no pickup/dropoff
89                             done = False
90                             taxi_loc = (row, col)
91 
92                             if action == 0:
93                                 new_row = min(row + 1, max_row)
94                             elif action == 1:
95                                 new_row = max(row - 1, 0)
96                             if action == 2 and self.desc[1 + row, 2 * col + 2] == b":":
97                                 new_col = min(col + 1, max_col)
98                             elif action == 3 and self.desc[1 + row, 2 * col] == b":":
99                                 new_col = max(col - 1, 0)
100                             elif action == 4:  # pickup
101                                 if (pass_idx < 4 and taxi_loc == locs[pass_idx]):
102                                     new_pass_idx = 4
103                                 else: # passenger not at location
104                                     reward = -10
105                             elif action == 5:  # dropoff
106                                 if (taxi_loc == locs[dest_idx]) and pass_idx == 4:
107                                     new_pass_idx = dest_idx
108                                     done = True
109                                     reward = 20
110                                 elif (taxi_loc in locs) and pass_idx == 4:
111                                     new_pass_idx = locs.index(taxi_loc)
112                                 else: # dropoff at wrong location
113                                     reward = -10
114                             new_state = self.encode(
115                                 new_row, new_col, new_pass_idx, dest_idx)
116                             P[state][action].append(
117                                 (1.0, new_state, reward, done))
118         initial_state_distrib /= initial_state_distrib.sum()
119         discrete.DiscreteEnv.__init__(
120             self, num_states, num_actions, P, initial_state_distrib)
121 
122     def encode(self, taxi_row, taxi_col, pass_loc, dest_idx):
123         # (5) 5, 5, 4
124         i = taxi_row
125         i *= 5
126         i += taxi_col
127         i *= 5
128         i += pass_loc
129         i *= 4
130         i += dest_idx
131         return i
132 
133     def decode(self, i):
134         out = []
135         out.append(i % 4)
136         i = i // 4
137         out.append(i % 5)
138         i = i // 5
139         out.append(i % 5)
140         i = i // 5
141         out.append(i)
142         assert 0 <= i < 5
143         return reversed(out)
144 
145     def render(self, mode='human'):
146         outfile = StringIO() if mode == 'ansi' else sys.stdout
147 
148         out = self.desc.copy().tolist()
149         out = [[c.decode('utf-8') for c in line] for line in out]
150         taxi_row, taxi_col, pass_idx, dest_idx = self.decode(self.s)
151 
152         def ul(x): return "_" if x == " " else x
153         if pass_idx < 4:
154             out[1 + taxi_row][2 * taxi_col + 1] = utils.colorize(
155                 out[1 + taxi_row][2 * taxi_col + 1], 'yellow', highlight=True)
156             pi, pj = self.locs[pass_idx]
157             out[1 + pi][2 * pj + 1] = utils.colorize(out[1 + pi][2 * pj + 1], 'blue', bold=True)
158         else:  # passenger in taxi
159             out[1 + taxi_row][2 * taxi_col + 1] = utils.colorize(
160                 ul(out[1 + taxi_row][2 * taxi_col + 1]), 'green', highlight=True)
161 
162         di, dj = self.locs[dest_idx]
163         out[1 + di][2 * dj + 1] = utils.colorize(out[1 + di][2 * dj + 1], 'magenta')
164         outfile.write("\n".join(["".join(row) for row in out]) + "\n")
165         if self.lastaction is not None:
166             outfile.write("  ({})\n".format(["South", "North", "East", "West", "Pickup", "Dropoff"][self.lastaction]))
167         else: outfile.write("\n")
168 
169         # No need to return anything for human
170         if mode != 'human':
171             with closing(outfile):
172                 return outfile.getvalue()
173
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gym/envs/toy_text/taxi.py b/gym/envs/toy_text/taxi.py
--- a/gym/envs/toy_text/taxi.py
+++ b/gym/envs/toy_text/taxi.py
@@ -8,7 +8,7 @@
 MAP = [
     "+---------+",
     "|R: | : :G|",
-    "| : : : : |",
+    "| : | : : |",
     "| : : : : |",
     "| | : | : |",
     "|Y| : |B: |",
@@ -23,12 +23,25 @@
     by Tom Dietterich
 
     Description:
-    There are four designated locations in the grid world indicated by R(ed), B(lue), G(reen), and Y(ellow). When the episode starts, the taxi starts off at a random square and the passenger is at a random location. The taxi drive to the passenger's location, pick up the passenger, drive to the passenger's destination (another one of the four specified locations), and then drop off the passenger. Once the passenger is dropped off, the episode ends.
+    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.
 
     Observations: 
-    There are 500 discrete states since there are 25 taxi positions, 5 possible locations of the passenger (including the case when the passenger is the taxi), and 4 destination locations. 
+    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. 
+    
+    Passenger locations:
+    - 0: R(ed)
+    - 1: G(reen)
+    - 2: Y(ellow)
+    - 3: B(lue)
+    - 4: in taxi
     
-    Actions: 
+    Destinations:
+    - 0: R(ed)
+    - 1: G(reen)
+    - 2: Y(ellow)
+    - 3: B(lue)
+        
+    Actions:
     There are 6 discrete deterministic actions:
     - 0: move south
     - 1: move north
@@ -46,15 +59,8 @@
     - magenta: destination
     - yellow: empty taxi
     - green: full taxi
-    - other letters (R, G, B and Y): locations for passengers and destinations
-
-    actions:
-    - 0: south
-    - 1: north
-    - 2: east
-    - 3: west
-    - 4: pickup
-    - 5: dropoff
+    - other letters (R, G, Y and B): locations for passengers and destinations
+    
 
     state space is represented by:
         (taxi_row, taxi_col, passenger_location, destination)

{"golden_diff": "diff --git a/gym/envs/toy_text/taxi.py b/gym/envs/toy_text/taxi.py\n--- a/gym/envs/toy_text/taxi.py\n+++ b/gym/envs/toy_text/taxi.py\n@@ -8,7 +8,7 @@\n MAP = [\n     \"+---------+\",\n     \"|R: | : :G|\",\n-    \"| : : : : |\",\n+    \"| : | : : |\",\n     \"| : : : : |\",\n     \"| | : | : |\",\n     \"|Y| : |B: |\",\n@@ -23,12 +23,25 @@\n     by Tom Dietterich\n \n     Description:\n-    There are four designated locations in the grid world indicated by R(ed), B(lue), G(reen), and Y(ellow). When the episode starts, the taxi starts off at a random square and the passenger is at a random location. The taxi drive to the passenger's location, pick up the passenger, drive to the passenger's destination (another one of the four specified locations), and then drop off the passenger. Once the passenger is dropped off, the episode ends.\n+    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.\n \n     Observations: \n-    There are 500 discrete states since there are 25 taxi positions, 5 possible locations of the passenger (including the case when the passenger is the taxi), and 4 destination locations. \n+    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. \n+    \n+    Passenger locations:\n+    - 0: R(ed)\n+    - 1: G(reen)\n+    - 2: Y(ellow)\n+    - 3: B(lue)\n+    - 4: in taxi\n     \n-    Actions: \n+    Destinations:\n+    - 0: R(ed)\n+    - 1: G(reen)\n+    - 2: Y(ellow)\n+    - 3: B(lue)\n+        \n+    Actions:\n     There are 6 discrete deterministic actions:\n     - 0: move south\n     - 1: move north\n@@ -46,15 +59,8 @@\n     - magenta: destination\n     - yellow: empty taxi\n     - green: full taxi\n-    - other letters (R, G, B and Y): locations for passengers and destinations\n-\n-    actions:\n-    - 0: south\n-    - 1: north\n-    - 2: east\n-    - 3: west\n-    - 4: pickup\n-    - 5: dropoff\n+    - other letters (R, G, Y and B): locations for passengers and destinations\n+    \n \n     state space is represented by:\n         (taxi_row, taxi_col, passenger_location, destination)\n", "issue": "Taxi environment doesn't match paper\n![image](https://user-images.githubusercontent.com/11912669/63098742-89f7ab00-bf41-11e9-8d95-d4936dbd189a.png)\r\n\r\nThe map implemented in Taxi-v2 differs slightly from the one in the original paper (shown above). Namely, the paper example has a wall that prevents transitioning from (1,1) to (1,2), but the gym environment implemented doesn't. Any reason for that?\n", "before_files": [{"content": "import sys\nfrom contextlib import closing\nfrom six import StringIO\nfrom gym import utils\nfrom gym.envs.toy_text import discrete\nimport numpy as np\n\nMAP = [\n    \"+---------+\",\n    \"|R: | : :G|\",\n    \"| : : : : |\",\n    \"| : : : : |\",\n    \"| | : | : |\",\n    \"|Y| : |B: |\",\n    \"+---------+\",\n]\n\n\nclass TaxiEnv(discrete.DiscreteEnv):\n    \"\"\"\n    The Taxi Problem\n    from \"Hierarchical Reinforcement Learning with the MAXQ Value Function Decomposition\"\n    by Tom Dietterich\n\n    Description:\n    There are four designated locations in the grid world indicated by R(ed), B(lue), G(reen), and Y(ellow). When the episode starts, the taxi starts off at a random square and the passenger is at a random location. The taxi drive to the passenger's location, pick up the passenger, drive to the passenger's destination (another one of the four specified locations), and then drop off the passenger. Once the passenger is dropped off, the episode ends.\n\n    Observations: \n    There are 500 discrete states since there are 25 taxi positions, 5 possible locations of the passenger (including the case when the passenger is the taxi), and 4 destination locations. \n    \n    Actions: \n    There are 6 discrete deterministic actions:\n    - 0: move south\n    - 1: move north\n    - 2: move east \n    - 3: move west \n    - 4: pickup passenger\n    - 5: dropoff passenger\n    \n    Rewards: \n    There is a reward of -1 for each action and an additional reward of +20 for delievering the passenger. There is a reward of -10 for executing actions \"pickup\" and \"dropoff\" illegally.\n    \n\n    Rendering:\n    - blue: passenger\n    - magenta: destination\n    - yellow: empty taxi\n    - green: full taxi\n    - other letters (R, G, B and Y): locations for passengers and destinations\n\n    actions:\n    - 0: south\n    - 1: north\n    - 2: east\n    - 3: west\n    - 4: pickup\n    - 5: dropoff\n\n    state space is represented by:\n        (taxi_row, taxi_col, passenger_location, destination)\n    \"\"\"\n    metadata = {'render.modes': ['human', 'ansi']}\n\n    def __init__(self):\n        self.desc = np.asarray(MAP, dtype='c')\n\n        self.locs = locs = [(0,0), (0,4), (4,0), (4,3)]\n\n        num_states = 500\n        num_rows = 5\n        num_columns = 5\n        max_row = num_rows - 1\n        max_col = num_columns - 1\n        initial_state_distrib = np.zeros(num_states)\n        num_actions = 6\n        P = {state: {action: []\n                     for action in range(num_actions)} for state in range(num_states)}\n        for row in range(num_rows):\n            for col in range(num_columns):\n                for pass_idx in range(len(locs) + 1):  # +1 for being inside taxi\n                    for dest_idx in range(len(locs)):\n                        state = self.encode(row, col, pass_idx, dest_idx)\n                        if pass_idx < 4 and pass_idx != dest_idx:\n                            initial_state_distrib[state] += 1\n                        for action in range(num_actions):\n                            # defaults\n                            new_row, new_col, new_pass_idx = row, col, pass_idx\n                            reward = -1 # default reward when there is no pickup/dropoff\n                            done = False\n                            taxi_loc = (row, col)\n\n                            if action == 0:\n                                new_row = min(row + 1, max_row)\n                            elif action == 1:\n                                new_row = max(row - 1, 0)\n                            if action == 2 and self.desc[1 + row, 2 * col + 2] == b\":\":\n                                new_col = min(col + 1, max_col)\n                            elif action == 3 and self.desc[1 + row, 2 * col] == b\":\":\n                                new_col = max(col - 1, 0)\n                            elif action == 4:  # pickup\n                                if (pass_idx < 4 and taxi_loc == locs[pass_idx]):\n                                    new_pass_idx = 4\n                                else: # passenger not at location\n                                    reward = -10\n                            elif action == 5:  # dropoff\n                                if (taxi_loc == locs[dest_idx]) and pass_idx == 4:\n                                    new_pass_idx = dest_idx\n                                    done = True\n                                    reward = 20\n                                elif (taxi_loc in locs) and pass_idx == 4:\n                                    new_pass_idx = locs.index(taxi_loc)\n                                else: # dropoff at wrong location\n                                    reward = -10\n                            new_state = self.encode(\n                                new_row, new_col, new_pass_idx, dest_idx)\n                            P[state][action].append(\n                                (1.0, new_state, reward, done))\n        initial_state_distrib /= initial_state_distrib.sum()\n        discrete.DiscreteEnv.__init__(\n            self, num_states, num_actions, P, initial_state_distrib)\n\n    def encode(self, taxi_row, taxi_col, pass_loc, dest_idx):\n        # (5) 5, 5, 4\n        i = taxi_row\n        i *= 5\n        i += taxi_col\n        i *= 5\n        i += pass_loc\n        i *= 4\n        i += dest_idx\n        return i\n\n    def decode(self, i):\n        out = []\n        out.append(i % 4)\n        i = i // 4\n        out.append(i % 5)\n        i = i // 5\n        out.append(i % 5)\n        i = i // 5\n        out.append(i)\n        assert 0 <= i < 5\n        return reversed(out)\n\n    def render(self, mode='human'):\n        outfile = StringIO() if mode == 'ansi' else sys.stdout\n\n        out = self.desc.copy().tolist()\n        out = [[c.decode('utf-8') for c in line] for line in out]\n        taxi_row, taxi_col, pass_idx, dest_idx = self.decode(self.s)\n\n        def ul(x): return \"_\" if x == \" \" else x\n        if pass_idx < 4:\n            out[1 + taxi_row][2 * taxi_col + 1] = utils.colorize(\n                out[1 + taxi_row][2 * taxi_col + 1], 'yellow', highlight=True)\n            pi, pj = self.locs[pass_idx]\n            out[1 + pi][2 * pj + 1] = utils.colorize(out[1 + pi][2 * pj + 1], 'blue', bold=True)\n        else:  # passenger in taxi\n            out[1 + taxi_row][2 * taxi_col + 1] = utils.colorize(\n                ul(out[1 + taxi_row][2 * taxi_col + 1]), 'green', highlight=True)\n\n        di, dj = self.locs[dest_idx]\n        out[1 + di][2 * dj + 1] = utils.colorize(out[1 + di][2 * dj + 1], 'magenta')\n        outfile.write(\"\\n\".join([\"\".join(row) for row in out]) + \"\\n\")\n        if self.lastaction is not None:\n            outfile.write(\"  ({})\\n\".format([\"South\", \"North\", \"East\", \"West\", \"Pickup\", \"Dropoff\"][self.lastaction]))\n        else: outfile.write(\"\\n\")\n\n        # No need to return anything for human\n        if mode != 'human':\n            with closing(outfile):\n                return outfile.getvalue()\n", "path": "gym/envs/toy_text/taxi.py"}], "after_files": [{"content": "import sys\nfrom contextlib import closing\nfrom six import StringIO\nfrom gym import utils\nfrom gym.envs.toy_text import discrete\nimport numpy as np\n\nMAP = [\n    \"+---------+\",\n    \"|R: | : :G|\",\n    \"| : | : : |\",\n    \"| : : : : |\",\n    \"| | : | : |\",\n    \"|Y| : |B: |\",\n    \"+---------+\",\n]\n\n\nclass TaxiEnv(discrete.DiscreteEnv):\n    \"\"\"\n    The Taxi Problem\n    from \"Hierarchical Reinforcement Learning with the MAXQ Value Function Decomposition\"\n    by Tom Dietterich\n\n    Description:\n    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.\n\n    Observations: \n    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. \n    \n    Passenger locations:\n    - 0: R(ed)\n    - 1: G(reen)\n    - 2: Y(ellow)\n    - 3: B(lue)\n    - 4: in taxi\n    \n    Destinations:\n    - 0: R(ed)\n    - 1: G(reen)\n    - 2: Y(ellow)\n    - 3: B(lue)\n        \n    Actions:\n    There are 6 discrete deterministic actions:\n    - 0: move south\n    - 1: move north\n    - 2: move east \n    - 3: move west \n    - 4: pickup passenger\n    - 5: dropoff passenger\n    \n    Rewards: \n    There is a reward of -1 for each action and an additional reward of +20 for delievering the passenger. There is a reward of -10 for executing actions \"pickup\" and \"dropoff\" illegally.\n    \n\n    Rendering:\n    - blue: passenger\n    - magenta: destination\n    - yellow: empty taxi\n    - green: full taxi\n    - other letters (R, G, Y and B): locations for passengers and destinations\n    \n\n    state space is represented by:\n        (taxi_row, taxi_col, passenger_location, destination)\n    \"\"\"\n    metadata = {'render.modes': ['human', 'ansi']}\n\n    def __init__(self):\n        self.desc = np.asarray(MAP, dtype='c')\n\n        self.locs = locs = [(0,0), (0,4), (4,0), (4,3)]\n\n        num_states = 500\n        num_rows = 5\n        num_columns = 5\n        max_row = num_rows - 1\n        max_col = num_columns - 1\n        initial_state_distrib = np.zeros(num_states)\n        num_actions = 6\n        P = {state: {action: []\n                     for action in range(num_actions)} for state in range(num_states)}\n        for row in range(num_rows):\n            for col in range(num_columns):\n                for pass_idx in range(len(locs) + 1):  # +1 for being inside taxi\n                    for dest_idx in range(len(locs)):\n                        state = self.encode(row, col, pass_idx, dest_idx)\n                        if pass_idx < 4 and pass_idx != dest_idx:\n                            initial_state_distrib[state] += 1\n                        for action in range(num_actions):\n                            # defaults\n                            new_row, new_col, new_pass_idx = row, col, pass_idx\n                            reward = -1 # default reward when there is no pickup/dropoff\n                            done = False\n                            taxi_loc = (row, col)\n\n                            if action == 0:\n                                new_row = min(row + 1, max_row)\n                            elif action == 1:\n                                new_row = max(row - 1, 0)\n                            if action == 2 and self.desc[1 + row, 2 * col + 2] == b\":\":\n                                new_col = min(col + 1, max_col)\n                            elif action == 3 and self.desc[1 + row, 2 * col] == b\":\":\n                                new_col = max(col - 1, 0)\n                            elif action == 4:  # pickup\n                                if (pass_idx < 4 and taxi_loc == locs[pass_idx]):\n                                    new_pass_idx = 4\n                                else: # passenger not at location\n                                    reward = -10\n                            elif action == 5:  # dropoff\n                                if (taxi_loc == locs[dest_idx]) and pass_idx == 4:\n                                    new_pass_idx = dest_idx\n                                    done = True\n                                    reward = 20\n                                elif (taxi_loc in locs) and pass_idx == 4:\n                                    new_pass_idx = locs.index(taxi_loc)\n                                else: # dropoff at wrong location\n                                    reward = -10\n                            new_state = self.encode(\n                                new_row, new_col, new_pass_idx, dest_idx)\n                            P[state][action].append(\n                                (1.0, new_state, reward, done))\n        initial_state_distrib /= initial_state_distrib.sum()\n        discrete.DiscreteEnv.__init__(\n            self, num_states, num_actions, P, initial_state_distrib)\n\n    def encode(self, taxi_row, taxi_col, pass_loc, dest_idx):\n        # (5) 5, 5, 4\n        i = taxi_row\n        i *= 5\n        i += taxi_col\n        i *= 5\n        i += pass_loc\n        i *= 4\n        i += dest_idx\n        return i\n\n    def decode(self, i):\n        out = []\n        out.append(i % 4)\n        i = i // 4\n        out.append(i % 5)\n        i = i // 5\n        out.append(i % 5)\n        i = i // 5\n        out.append(i)\n        assert 0 <= i < 5\n        return reversed(out)\n\n    def render(self, mode='human'):\n        outfile = StringIO() if mode == 'ansi' else sys.stdout\n\n        out = self.desc.copy().tolist()\n        out = [[c.decode('utf-8') for c in line] for line in out]\n        taxi_row, taxi_col, pass_idx, dest_idx = self.decode(self.s)\n\n        def ul(x): return \"_\" if x == \" \" else x\n        if pass_idx < 4:\n            out[1 + taxi_row][2 * taxi_col + 1] = utils.colorize(\n                out[1 + taxi_row][2 * taxi_col + 1], 'yellow', highlight=True)\n            pi, pj = self.locs[pass_idx]\n            out[1 + pi][2 * pj + 1] = utils.colorize(out[1 + pi][2 * pj + 1], 'blue', bold=True)\n        else:  # passenger in taxi\n            out[1 + taxi_row][2 * taxi_col + 1] = utils.colorize(\n                ul(out[1 + taxi_row][2 * taxi_col + 1]), 'green', highlight=True)\n\n        di, dj = self.locs[dest_idx]\n        out[1 + di][2 * dj + 1] = utils.colorize(out[1 + di][2 * dj + 1], 'magenta')\n        outfile.write(\"\\n\".join([\"\".join(row) for row in out]) + \"\\n\")\n        if self.lastaction is not None:\n            outfile.write(\"  ({})\\n\".format([\"South\", \"North\", \"East\", \"West\", \"Pickup\", \"Dropoff\"][self.lastaction]))\n        else: outfile.write(\"\\n\")\n\n        # No need to return anything for human\n        if mode != 'human':\n            with closing(outfile):\n                return outfile.getvalue()\n", "path": "gym/envs/toy_text/taxi.py"}]}