Minimalistic Gridworld Environment (MiniGrid)

Maxime Chevalier-Boisvert acaec3c75a Added figure for empty environment vor 7 Jahren
basicrl d65ae2c098 Added missing dependency vor 7 Jahren
figures acaec3c75a Added figure for empty environment vor 7 Jahren
gym_minigrid 63d3d94699 Implemented box object type vor 7 Jahren
.gitignore 8fc72cda9f Fixed basicrl code vor 7 Jahren
LICENSE 51a5d9079d Initial commit vor 7 Jahren
README.md 491c79586b Update README.md vor 7 Jahren
run_tests.py de3f757e3e Added to run_tests.sh vor 7 Jahren
setup.py f28a1ba73f Updated README vor 7 Jahren
standalone.py 8af443c879 Added action enumeration, started work on QA environment vor 7 Jahren

README.md

Minimalistic Gridworld Environment (MiniGrid)

There are other gridworld Gym environments out there, but this one is designed to be particularly simple, lightweight and fast. The code has very few dependencies, making it less likely to break or fail to install. It loads no external sprites/textures, and it can run at up to 5800 FPS on a quad-core laptop, which means you can run your experiments faster.

This environment has been built at the MILA as part of the Baby AI Game project.

Installation

Clone this repository and install the other dependencies with pip3:

git clone https://github.com/maximecb/gym-minigrid.git
cd gym-minigrid
pip3 install -e .

Optionally, if you wish use the reinforcement learning code included under /basicrl, you can install its dependencies as follows:

cd basicrl

# PyTorch
conda install pytorch torchvision -c soumith

# Dependencies needed by OpenAI baselines
sudo apt install libopenmpi-dev zlib1g-dev cmake

# OpenAI baselines
git clone https://github.com/openai/baselines.git
cd baselines
pip3 install -e .
cd ..

# Other requirements
pip3 install -r requirements.txt

Note: the basicrl code is a custom fork of this repository, which was modified to work with this environment.

Basic Usage

To run the standalone UI application, which allows you to manually control the agent with the arrow keys:

./standalone.py

The environment being run can be selected with the --env-name option, eg:

./standalone.py --env-name MiniGrid-Empty-8x8-v0

Basic reinforcement learning code is provided in the basicrl subdirectory. You can perform training using the ACKTR algorithm with:

python3 basicrl/main.py --env-name MiniGrid-Empty-6x6-v0 --no-vis --num-processes 32 --algo acktr

You can view the result of training using the enjoy.py script:

python3 basicrl/enjoy.py --env-name MiniGrid-Empty-6x6-v0 --load-dir ./trained_models/acktr

Included Environments

The environments listed below are implemented in the gym_minigrid/envs directory.

Empty environment

Registered configurations:

  • MiniGrid-Empty-8x8-v0
  • MiniGrid-Empty-6x6-v0

This environment is an empty room, and the goal of the agent is to reach the green goal square, which provides a sparse reward. A small penalty is subtracted for the number of steps to reach the goal. This environment is useful, with small rooms, to validate that your RL algorithm works correctly, and with large rooms to experiment with sparse rewards.

Door & key environment

Registered configurations:

  • MiniGrid-DoorKey-8x8-v0
  • MiniGrid-DoorKey-16x16-v0

This environment has a key that the agent must pick up in order to unlock a goal and then get to the green goal square. This environment is difficult, because of the sparse reward, to solve using classical RL algorithms. It is useful to experiment with curiosity or curriculum learning.

Multi-room environment

Registered configurations:

  • MiniGrid-MultiRoom-N6-v0

This environment has a series of connected rooms with doors that must be opened in order to get to the next room. The final room has the green goal square the agent must get to. This environment is extremely difficult to solve using classical RL. However, by gradually increasing the number of rooms and building a curriculum, the environment can be solved.

Fetch environment

Registered configurations:

  • MiniGrid-Fetch-8x8-v0

This environment has multiple objects of assorted types and colors. The agent receives a textual string as part of its observation telling it which object to pick up. Picking up the wrong object produces a negative reward.

Four room question answering environment

Registered configurations:

  • MiniGrid-FourRoomQA-v0

This environment is inspired by the Embodied Question Answering paper. There are four colored rooms, and the agent is placed at a random position. Multiple objects of different types and colors are also placed at random positions in random rooms. A question and answer pair is generated, the question is given to the agent as an observation, and the agent has a limited number of time steps to explore the environment and produce a response.