Skip to main content

Simple maze environments using mujoco-py

Project description

mujoco-maze

Actions Status PyPI version Black

Some maze environments for reinforcement learning (RL) based on mujoco-py and openai gym.

Thankfully, this project is based on the code from rllab and tensorflow/models.

Note that d4rl and dm_control have similar maze environments, and you can also check them. But, if you want more customizable or minimal one, I recommend this.

Usage

Importing mujoco_maze registers environments and you can load environments by gym.make. All available environments listed are listed in [Environments] section.

E.g.,:

import gym
import mujoco_maze  # noqa
env = gym.make("Ant4Rooms-v0")

Environments

  • PointUMaze/AntUmaze/SwimmerUmaze

    PointUMaze

    • PointUMaze-v0/AntUMaze-v0/SwimmerUMaze-v0 (Distance-based Reward)
    • PointUmaze-v1/AntUMaze-v1/SwimmerUMaze-v (Goal-based Reward i.e., 1.0 or -ε)
  • PointSquareRoom/AntSquareRoom/SwimmerSquareRoom

    SwimmerSquareRoom

    • PointSquareRoom-v0/AntSquareRoom-v0/SwimmerSquareRoom-v0 (Distance-based Reward)
    • PointSquareRoom-v1/AntSquareRoom-v1/SwimmerSquareRoom-v1 (Goal-based Reward)
    • PointSquareRoom-v2/AntSquareRoom-v2/SwimmerSquareRoom-v2 (No Reward)
  • Point4Rooms/Ant4Rooms/Swimmer4Rooms

    Point4Rooms

    • Point4Rooms-v0/Ant4Rooms-v0/Swimmer4Rooms-v0 (Distance-based Reward)
    • Point4Rooms-v1/Ant4Rooms-v1/Swimmer4Rooms-v1 (Goal-based Reward)
    • Point4Rooms-v2/Ant4Rooms-v2/Swimmer4Rooms-v2 (Multiple Goals (0.5 pt or 1.0 pt))
  • PointCorridor/AntCorridor/SwimmerCorridor

    PointCorridor

    • PointCorridor-v0/AntCorridor-v0/SwimmerCorridor-v0 (Distance-based Reward)
    • PointCorridor-v1/AntCorridor-v1/SwimmerCorridor-v1 (Goal-based Reward)
    • PointCorridor-v2/AntCorridor-v2/SwimmerCorridor-v2 (No Reward)
  • PointPush/AntPush

    PointPush

    • PointPush-v0/AntPush-v0 (Distance-based Reward)
    • PointPush-v1/AntPush-v1 (Goal-based Reward)
  • PointFall/AntFall

    PointFall

    • PointFall-v0/AntFall-v0 (Distance-based Reward)
    • PointFall-v1/AntFall-v1 (Goal-based Reward)
  • PointBilliard

    PointBilliard

    • PointBilliard-v0 (Distance-based Reward)
    • PointBilliard-v1 (Goal-based Reward)
    • PointBilliard-v2 (Multiple Goals (0.5 pt or 1.0 pt))
    • PointBilliard-v3 (Two goals (0.5 pt or 1.0 pt))
    • PointBilliard-v4 (No Reward)

Customize Environments

You can define your own task by using components in maze_task.py, like:

import gym
import numpy as np
from mujoco_maze.maze_env_utils import MazeCell
from mujoco_maze.maze_task import MazeGoal, MazeTask
from mujoco_maze.point import PointEnv


class GoalRewardEMaze(MazeTask):
    REWARD_THRESHOLD: float = 0.9
    PENALTY: float = -0.0001

    def __init__(self, scale):
        super().__init__(scale)
        self.goals = [MazeGoal(np.array([0.0, 4.0]) * scale)]

    def reward(self, obs):
        return 1.0 if self.termination(obs) else self.PENALTY

    @staticmethod
    def create_maze():
        E, B, R = MazeCell.EMPTY, MazeCell.BLOCK, MazeCell.ROBOT
        return [
            [B, B, B, B, B],
            [B, R, E, E, B],
            [B, B, B, E, B],
            [B, E, E, E, B],
            [B, B, B, E, B],
            [B, E, E, E, B],
            [B, B, B, B, B],
        ]


gym.envs.register(
    id="PointEMaze-v0",
    entry_point="mujoco_maze.maze_env:MazeEnv",
    kwargs=dict(
        model_cls=PointEnv,
        maze_task=GoalRewardEMaze,
        maze_size_scaling=GoalRewardEMaze.MAZE_SIZE_SCALING.point,
        inner_reward_scaling=GoalRewardEMaze.INNER_REWARD_SCALING,
    )
)

You can also customize models. See point.py or so.

Warning

Reacher enviroments are not tested.

[Experimental] Web-based visualizer

By passing a port like gym.make("PointEMaze-v0", websock_port=7777), one can use a web-based visualizer when calling env.render(). WebBasedVis

This feature is experimental and can produce some zombie proceses.

License

This project is licensed under Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).

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

mujoco-maze-0.2.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

mujoco_maze-0.2.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file mujoco-maze-0.2.0.tar.gz.

File metadata

  • Download URL: mujoco-maze-0.2.0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.12.9-arch1-1

File hashes

Hashes for mujoco-maze-0.2.0.tar.gz
Algorithm Hash digest
SHA256 20ed18a7d3ecb5632baef55f108c4b52117174a0209c05053ec7a9b85c0ce8ad
MD5 59abfb021b546aa3d6ecec2610893a15
BLAKE2b-256 3123e76f762d623f8c7cc2c6aa18918387265cc5a0dbe44b5142b509ba39ee69

See more details on using hashes here.

File details

Details for the file mujoco_maze-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mujoco_maze-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.5 Linux/5.12.9-arch1-1

File hashes

Hashes for mujoco_maze-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c587d91823368202c0ecfd1daf1c0fadfe31d87d39666e8df5dcf7ade797d4c7
MD5 82f9d7a93ecebbca4c41b2f1875c041b
BLAKE2b-256 7460d267997abe3a9a299ff11c061e2d523d1022b9aa89f06837da0cac9e8c72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page