A Gymnasium environment for maze-based reinforcement learning
Project description
MazeGym
A Gymnasium-based environment for maze-based reinforcement learning tasks.
Installation
# From PyPI (once published)
pip install mazegym
# From source
git clone https://github.com/yourusername/mazegym.git
cd mazegym
pip install -e .
Usage
Creating a random maze
import gymnasium as gym
import mazegym
import numpy as np
import matplotlib.pyplot as plt
# Create a 10x10 maze environment
env = mazegym.MazeEnvironment(width=10, height=10)
# Reset the environment to get initial state
obs, info = env.reset()
# Visualize the maze
plt.figure(figsize=(8, 8))
plt.imshow(obs, cmap='gray')
plt.title('Maze Environment')
plt.colorbar(ticks=[0, 1, 2, 3], labels=['Path', 'Wall', 'Agent', 'Goal'])
plt.show()
# Get valid moves
print(f"Valid moves: {info['valid_moves']}")
Creating a custom maze
import gymnasium as gym
import mazegym
import numpy as np
# Create a custom 5x5 maze with a specific layout
grid = np.ones((5, 5), dtype=np.int8) # All walls
grid[1:4, 2] = 0 # Vertical path
grid[1, 1:3] = 0 # Horizontal path for agent
grid[3, 2:4] = 0 # Horizontal path for goal
grid[1, 1] = 2 # Agent position
grid[3, 3] = 3 # Goal position
env = mazegym.MazeEnvironment(grid=grid)
Taking actions
# Take a step with action 1 (right)
obs, reward, done, truncated, info = env.step(1)
# Check if the episode is done (reached goal)
if done:
print(f"Goal reached! Reward: {reward}")
License
GNU General Public License v3.0
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.
Project details
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 mazegym-1.0.0.tar.gz.
File metadata
- Download URL: mazegym-1.0.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d089040b52003da8ef692f435b820bb9a5e244978de12f84ac4413ae4d7726c6
|
|
| MD5 |
8e2039f9fcb7a45adb04603811f50633
|
|
| BLAKE2b-256 |
74d35ea100314ac1f2badd1ead740ef0665d4cdd390e71fc5a2ef9af0f9ba364
|
File details
Details for the file mazegym-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mazegym-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49b523f739876b6523f6088c65cf3f7ef5cfa2b1e492140d7f25395a8b7befa5
|
|
| MD5 |
4ee3ce3652f4f4451b8f7531babf5063
|
|
| BLAKE2b-256 |
a3361412855e3583c4671333bdfb3ac8a1db29ab909d23bfb2e54388265847f7
|