Skip to content

Commit

Permalink
Fix render_mode in documentation
Browse files Browse the repository at this point in the history
This replaces gym's old render(mode=...) interface
  • Loading branch information
eleurent committed Mar 2, 2023
1 parent 29a38d2 commit abcef8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions docs/source/multi_agent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ To that end, update the :ref:`environment configuration <Configuring an environm

import gymnasium as gym

env = gym.make('highway-v0')
env = gym.make('highway-v0', render_mode='rgb_array')

env.configure({"controlled_vehicles": 2}) # Two controlled vehicles
env.configure({"vehicles_count": 1}) # A single other vehicle, for the sake of visualisation
env.reset(seed=0)

from matplotlib import pyplot as plt
%matplotlib inline
plt.imshow(env.render(mode="rgb_array"))
plt.imshow(env.render())
plt.title("Controlled vehicles are in green")
plt.show()

Expand All @@ -53,14 +53,14 @@ The type of actions contained in the tuple must be described by a standard :ref:
env.reset()

_, (ax1, ax2) = plt.subplots(nrows=2)
ax1.imshow(env.render(mode="rgb_array"))
ax1.imshow(env.render())
ax1.set_title("Initial state")

# Make the first vehicle change to the left lane, and the second one to the right
action_1, action_2 = 0, 2 # See highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_ALL
env.step((action_1, action_2))

ax2.imshow(env.render(mode="rgb_array"))
ax2.imshow(env.render())
ax2.set_title("After sending actions to each vehicle")
plt.show()

Expand Down
6 changes: 3 additions & 3 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Here is a quick example of how to create an environment:
from matplotlib import pyplot as plt
%matplotlib inline

env = gym.make('highway-v0')
env = gym.make('highway-v0', render_mode='rgb_array')
env.reset()
for _ in range(3):
action = env.action_type.actions_indexes["IDLE"]
obs, reward, done, truncated, info = env.step(action)
env.render()

plt.imshow(env.render(mode="rgb_array"))
plt.imshow(env.render())
plt.show()

All the environments
Expand Down Expand Up @@ -70,7 +70,7 @@ For example, the number of lanes can be changed with:

env.config["lanes_count"] = 2
env.reset()
plt.imshow(env.render(mode="rgb_array"))
plt.imshow(env.render())
plt.show()

.. note::
Expand Down

0 comments on commit abcef8d

Please sign in to comment.