Home

Awesome

mazelab: A customizable framework to create maze and gridworld environments.

This repository contains a customizable framework to create maze and gridworld environments with gym-like API. It has modular designs and it allows large flexibility for the users to easily define their own environments such as changing rendering colors, adding more objects, define available actions etc. The motivation of this repository is, as maze or gridworld are used very often in the reinforcement learning community, however, it is still lack of a standardized framework.

The repo will be actively maintained, any comments, feedbacks or improvements are highly welcomed.

Installation

Install dependencies

Run the following command to install all required dependencies:

pip install -r requirements.txt

Note that it is highly recommanded to use an Miniconda environment:

conda create -n mazelab python=3.7

Install mazelab

Run the following commands to install mazelab from source:

git clone https://github.com/zuoxingdong/mazelab.git
cd mazelab
pip install -e .

Installing from source allows to flexibly modify and adapt the code as you pleased, this is very convenient for research purpose which often needs fast prototyping.

Getting started

Detailed tutorials is coming soon. For now, it is recommended to have a look in examples/ or the source code.

Examples

We have provided a Jupyter Notebook for each example to illustrate how to make various of maze environments, and generate animation of the agent's trajectory following the optimal actions solved by our build-in Dijkstra optimal planner.

Simple empty maze

Simple empty maze

Random shape maze

Random shape maze

Random maze

Random maze

U-maze

U-maze

Double T-maze

Double T-maze

Morris water maze

Morris water maze

How to create your own maze/gridworld environment

    class Maze(BaseMaze):
        @property
        def size(self):
            return 10, 10

        def make_objects(self):
            free = Object('free', 0, color.free, False, np.stack(np.where(x == 0), axis=1))
            obstacle = Object('obstacle', 1, color.obstacle, True, np.stack(np.where(x == 1), axis=1))
            agent = Object('agent', 2, color.agent, False, [])
            goal = Object('goal', 3, color.goal, False, [])
            return free, obstacle, agent, goal
    gym.envs.register(id=some_name, entry_point=your_file_or_class, max_episode_steps=some_steps)
    actions = dijkstra_solver(impassable_array, motions, start, goal)

What's new

Roadmap

Reference

Please use this bibtex if you want to cite this repository in your publications:

@misc{mazelab,
      author = {Zuo, Xingdong},
      title = {mazelab: A customizable framework to create maze and gridworld environments.},
      year = {2018},
      publisher = {GitHub},
      journal = {GitHub repository},
      howpublished = {\url{https://github.com/zuoxingdong/mazelab}},
    }