OpenAI Gym Interface

Games defined with GDY files can easily be wrapped by OpenAI’s gym interface.

The simplest way to use a pre-made environment is to just use the following code:

import gym
import griddly

if __name__ == '__main__':

    env = gym.make('GDY-Sokoban-v0')

The gym.make command can also send several Griddly specific parameters to the environment:

env = gym.make(

See also

More examples and a full listing of all the games can be found on the page for each game in Games

Registering Your Own Environment

It’s easy to register your own GDY files and wrap them with OpenAI gym using the GymWrapperFactory:

import gym
from griddly import GymWrapperFactory, gd

if __name__ == '__main__':
    wrapper = GymWrapperFactory()

    wrapper.build_gym_from_yaml('MyNewEnvironment', 'my_new_env_gdy.yaml')

    env = gym.make('GDY-MyNewEnvironment-v0')

Observer Types

When generating an environment you can specify how you want the environment to be rendered. You can do this by setting the player_observer_type and global_observer_type parameters in the gym.make function, or the build_gym_from_yaml function.

See also

For more information about observation spaces, states and event history see Observation Spaces

The Global Observer

The global observer can be used alongside any of the other observers and will always render the entire environment regardless of how other observers are defined. This means that you can pass vector observations to your agents and then render with sprites or blocks to make awesome demos!

env = gym.make(f'GDY-Sokoban-Adv-v0', global_observer_type=gd.ObserverType.SPRITE_2D)