A Gym environment for the sliding block puzzle game
Project description
Puzzle15Gym
A Gym environment for the 15-puzzle game: https://en.wikipedia.org/wiki/15_puzzle.
The blank space is represented by -1.
Usage
Initiating the env via gym
import gym
import puzzle15Gym
env_3x3_random = gym.make('Puzzle3x3Random-v0')
env_3x3_fixed = gym.make('Puzzle3x3Fixed-v0')
env_4x4_random = gym.make('Puzzle4x4Random-v0')
env_4x4_fixed = gym.make('Puzzle4x4Fixed-v0')
env_5x5_random = gym.make('Puzzle5x5Random-v0')
env_5x5_fixed = gym.make('Puzzle5x5Fixed-v0')
Initiating the env directly
from puzzle15Gym import Puzzle15Env
env_random = Puzzle15Env(height=4, width=4)
env_random = Puzzle15Env(custom_puzzle="2 8 6|7 1 3|-1 5 4")
env_3x3_random = gym.make('Puzzle3x3Random-v0')
# Reset the environment
observation, info = env_3x3.reset()
# Take a step
action = env_3x3.action_space.sample()
observation, reward, done, truncated, info = env_3x3.step(action)
# Render the environment. The only render mode is 'human' which renders visual output.
env_3x3.render()
# Close the environment
env_3x3.close()
Environment Details
- Action Space: Discrete(4) -
0: up,1: right,2: down,3: left. - Observation Space:
Box(-1, height*width-1, (height*width), int32). Contains unique values from-1to (width * height - 1), excluding0. - Reward:
1if the puzzle is solved,0if not,-2if invalid move. - Done:
Trueif the puzzle is solved,Falseotherwise.
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
puzzle15gym-1.0.0.tar.gz
(17.5 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 puzzle15gym-1.0.0.tar.gz.
File metadata
- Download URL: puzzle15gym-1.0.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83d3d75e50004098509e6d9bf0c4273547b023481159b75b1d2b21ebded0dfde
|
|
| MD5 |
00328caf0f991c0ec2374e7ce0842b38
|
|
| BLAKE2b-256 |
b8d5d75dc19a2a45ee97d121e9e2879cb475801f79952299bce56815ec9123e5
|
File details
Details for the file puzzle15gym-1.0.0-py3-none-any.whl.
File metadata
- Download URL: puzzle15gym-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.1 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 |
4dd1fa8cd5bfa9536d5176210ce4f4d63a5ae4b9c5f14e1a93b9b1156d978cbe
|
|
| MD5 |
e75c03726db91ef6133f7c32c982583c
|
|
| BLAKE2b-256 |
7c07fb6bce020e8ca8ff0b4f2efc3840dc03a854c54bd9349b7d65c46e2347cb
|