Gym library for training RL agents on Rush Hour game
Project description
ParkingLotGym
A custom AI Gymnasium environment for the Rush hour puzzle: https://en.wikipedia.org/wiki/Rush_Hour_(puzzle).
Example solvable in 60 moves
Random moves are used for this demo. Click on .gif if still.
Example solvable in 5 moves
Random moves are used for this demo. Click if .gif if still.
Usage
Initiating the env via gym
import gymnasium as gym
env_6x6_random = gym.make('Puzzle6x6Moves15-v0')
env_4x4_random = gym.make('Puzzle6x6Moves30-v0')
env_6x6_fixed = gym.make('Puzzle6x6Moves13Fixed-v0')
env_6x6_fixed = gym.make('Puzzle6x6Moves6Fixed-v0')
Initiating the env directly
from parkinglotgym import ParkingLotEnv
env_random = ParkingLotEnv(15)
env_fixed = ParkingLotEnv
("""
....O
FF..O
.AA..
..BB.
.CC..
.DD..
""")
Making moves
import gymnasium as gym
env_3x3_fixed = gym.make('Puzzle6x6Moves13Fixed-v0')
# Reset the environment
observation, info = env_3x3_fixed.reset()
# Make a random valid move
import random
# Grab list of vehicles with their available moves.
available_moves = info["available_moves"]
# Drop moves from now, leave only vehicles.
movable_vehicles = [v for v, moves in available_moves.items()]
# Select a random vehicle to move.
vehicle = random.choice(movable_vehicles)
# Select a random move for the chosen vehicle.
move = random.choice(available_moves[vehicle])
# Render the environment. The only render mode is 'human' which renders visual output.
env_3x3_fixed.render()
# Close the environment
env_3x3_fixed.close()
Environment Details
- Action Space: MultiDiscrete([num_vehicles, max_moves*2], start=[2, -max_moves]) - First value selects vehicle ID (starting at 2), second value indicates steps to move (negative for backward, positive for forward). Moving 0 steps is not allowed.
- Observation Space:
Box(0, num_vehicles+1, (height, width), int32). Contains values:0for empty cells,1for walls,2and up for vehicles. '2` represents the main vehicle. - Reward:
0if the puzzle is solved,-1if not solved yet,-2if invalid move. - Done:
Trueif the puzzle is solved,Falseotherwise.
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
parkinglotgym-1.1.2.tar.gz
(18.0 kB
view details)
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 parkinglotgym-1.1.2.tar.gz.
File metadata
- Download URL: parkinglotgym-1.1.2.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7f7ca23f268fda51b3c40e6784c1d04074f837a5da173b3e2c5a825947e8c2e
|
|
| MD5 |
4370323d7336c0e888d3a94c16ec9ee1
|
|
| BLAKE2b-256 |
11985eed502bb8cd758280186cf196783e6dc4fe113769480f1434001af3d7a3
|
File details
Details for the file parkinglotgym-1.1.2-py3-none-any.whl.
File metadata
- Download URL: parkinglotgym-1.1.2-py3-none-any.whl
- Upload date:
- Size: 17.9 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 |
620495ada15ddc29299f86683103299ea9d814b67bf2cee24253d4838b87babb
|
|
| MD5 |
641427e305791b87f88c9e06fe829325
|
|
| BLAKE2b-256 |
c13574e64a1ea5258050663e8c3df879ac12153a4e3599f9f8c627ce1093b4a4
|