Skip to main content

MazeGym

codecov PyPI version

A Gymnasium env for training reinforcement learning agents to navigate mazes.

Library used: GitHub.

9x9 maze

Random moves are used for this demo.

Maze9x9

21x21 maze

Random moves are used for this demo.

Maze21x21

35x15 maze

Random moves are used for this demo.

Maze35x15

Usage

Initiating the env via gym

import gymnasium as gym
import mazegym

env_9x9_random = gym.make('Maze9x9Random-v0')
env_35x15_random = gym.make('Maze35x15Random-v0')

env_5x5_fixed = gym.make('Maze5x5Fixed-v0')
env_3x7_fixed = gym.make('Maze3x7Fixed-v0')

Initiating the env directly

from mazegym import MazeEnvironment

#Random env
env_random = MazeEnvironment(width=10, height=5)

# Fixed env
fixed_grid = np.ones((3, 7), dtype=np.int8)
fixed_grid[1, :] = 0
fixed_grid[1, 0] = 2
fixed_grid[1, 6] = 3
env_fixed = MazeEnvironment(grid=grid)

Making moves

import gymnasium as gym

env_35x15_random = gym.make('Maze35x15Random-v0')

# Reset the environment
observation, info = env_35x15_random.reset()

# Make a random valid move

valid_moves = info.get("valid_moves")
move = random.choice(valid_moves)
observation, reward, done, truncated, info = env_35x15_random.step(move)

# Render the environment. The only render mode is 'human' which renders visual output.
env_35x15_random.render()

# Close the environment
env_35x15_random.close()

Configurable parameters:

  • width: width of maze.
  • height: height of maze.
  • grid: User for custom mazes.
  • vision_range: Range of tiles your agent can see forward. Agent only sees forward and remembers previously visited tiles. If vision_range is not specified all map is visible.
  • wall_path_swap: Tuple accepting two elements. Allows environment randomness making a wall become a path and a path become a wall. First value is the transformation chance. The second value is the frequency of transformations. No effects if tuple value is None.
  • max_steps: Maximum steps until episode terminates. Defaults to: (3 × width × height).

Either width and height or grid is required. Width ang height are used for random mazes while grid is used for custom mazes.

Environment Details

  • Action Space: Discrete(4) - Four possible actions: 0 (up), 1 (right), 2 (down), 3 (left). Invalid moves (moving into walls) results in an error.
  • Observation Space: Box(0, 3, (height, width), int8). Contains values: 0 for empty paths, 1 for walls, 2 for the agent, 3 for the goal.
  • Reward: 100 if the goal is reached, -1 for each step taken. -2 for an illegal move.
  • Done: True if the agent reaches the goal, False otherwise.
  • Truncated: True if maximum steps are exceeded, False otherwise.

Metadata

Release files for mazegym 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mazegym 1.2.3
File Size Uploaded Provenance
mazegym-1.2.3.tar.gz 20.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mazegym 1.2.3
File Interpreter ABI Platform
mazegym-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 39.9 kB

Release files / mazegym-1.2.3.tar.gz

Download URL mazegym-1.2.3.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
42aab4db6605e1406a7ba91594593f387182c0114a9386fbfc6b4f08916fa899
BLAKE2b-256 checksum
How to use checksums
3942c07448b08bc55291284279ea061ff92b07a3399517fea8e4194292aeb09b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / mazegym-1.2.3-py3-none-any.whl

Download URL mazegym-1.2.3-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f244dc98cb8ae3e642b45e0776688b116ece16a69614c54e0d84271b0e676809
BLAKE2b-256 checksum
How to use checksums
82ebc8c2871ee37a05239ba4c6e081d102f001863eaeba869d85fef3fc83a47a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for mazegym 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page