An OpenAI Gym interface for the AI safety gridworlds by DeepMind, which are implemented in pycolab.
This repository combines and extends two previous implementations which can be found at:
- https://github.com/n0p2/gym_ai_safety_gridworlds
- https://github.com/n0p2/ai-safety-gridworlds-viewer
safe_grid_gym
additionally provides:
- Additional toy environments
- Additional features for the Gym environment:
- Additional render modes
ansi
andrgb_array
allowing for more automated experimentation - A
TransitionBoatRace
environments which provides the last two boards as state information
- Additional render modes
- Easier dependency management by providing a
setup.py
- Unittests for the Gym environment using the demonstrations provided by in the
ai-safety-gridworlds
repository
To handle the dependency on the ai-safety-gridworlds
we use a fork of the official repository that provides a setup.py
.
You can use the code from the official ai-safety-gridworlds
repository instead by adding it to your PYTHONPATH
.
By using safe_grid_gym
the AI safety gridworlds can by used like any other gym environment. For example to take 10 random actions in the boat race environment and render the gridworld, you can do:
import safe_grid_gym
import gym
env = gym.make("BoatRace-v0")
action_space = env.action_space
for i in range(10):
action = action_space.sample()
state, reward, done, info = env.step(action)
env.render(mode="human")