A hierarchical multi-level maze environment for Gymnasium
Project description
Multi-Level Maze Gymnasium Environment
Multi-Level Maze is a Gymnasium environment that generates hierarchical mazes using recursive spanning-tree connectivity. Each maze consists of multiple levels of structure, where every sub-block is internally connected.
Getting Started
Installation
You can install it using:
pip install multi-level-maze
Then, in your Python environment:
import gymnasium as gym
import multi_level_maze
env = gym.make("MultiLevelMaze-v0", size=3, levels=3, maze_seed=2, max_steps=1000, cell_size=30)
obs, info = env.reset()
done, truncated = False, False
while not (done or truncated):
env.render()
action = env.action_space.sample()
obs, reward, done, truncated, info = env.step(action)
env.close()
Environment Parameters
You can customize the environment using the following arguments when creating it with gym.make("MultiLevelMaze-v0", ...).
| Argument | Type | Default | Description |
|---|---|---|---|
size |
int | 3 | Base grid size for each level. The total maze size is size ** levels. |
levels |
int | 2 | Number of hierarchical levels (recursive subdivisions). |
max_steps |
int | 1000 | Maximum steps per episode before truncation. |
cell_size |
int | 50 | Pixel size of each maze cell in render mode. |
maze_seed |
int | 1 | Seed controlling the maze structure. Fixed per environment. |
render_fps |
int | 5 | Frames per second when rendering with Pygame. |
Reproducibility
- The maze structure is fixed by
maze_seedand reused across resets. - The starting position and goal are randomized each time you call
reset(seed=...). - Using the same
seedreproduces the same starting and goal positions. - To generate a completely new maze, reinstantiate the environment with a different
maze_seed.
Observations and Actions
Observation Space: A concatenated vector of one-hot encodings representing the agent’s and goal’s positions at each hierarchical level.
Action Space: Discrete with 4 actions:
| Action | Meaning |
|---|---|
| 0 | Move up |
| 1 | Move down |
| 2 | Move left |
| 3 | Move right |
Citation
If you use this environment in your research, please cite it using the CITATION.cff file included in this repository.
License
Copyright (C) 2025 Ali Jahani
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program;
if not, see https://www.gnu.org/licenses.
TODO
- Vectorization
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multi_level_maze-1.0.0.tar.gz.
File metadata
- Download URL: multi_level_maze-1.0.0.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02f22ab8dde7a0a1fdf899592db865da7fed356425e36202eb29027c13472303
|
|
| MD5 |
2630cb3aa36f23999be8f340465a0ac2
|
|
| BLAKE2b-256 |
d1a7cfc6d1dd751f097ad4c30ead0da215cedf9e9e1c4c2af84e1ed52ce74e41
|
File details
Details for the file multi_level_maze-1.0.0-py3-none-any.whl.
File metadata
- Download URL: multi_level_maze-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a485698352e733abd44f2ed2b52a154619cefb8647d9636b08067a32d308a39e
|
|
| MD5 |
807cbf21ee35615d10189b3161a960d0
|
|
| BLAKE2b-256 |
bdd534f9c9a849c547f23316619707f13f6ee2731a76793abf8f568bf7c8393d
|