# RubiksCubeGym
### An OpenAI Gym environment for various twisty puzzles.
![PyPI](https://img.shields.io/pypi/v/rubiks_cube_gym)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/rubiks_cube_gym)
![PyPI - License](https://img.shields.io/pypi/l/rubiks_cube_gym)
![PyPI - Downloads](https://img.shields.io/pypi/dm/rubiks_cube_gym)
Currently available environments:
- [x] 2x2x2 Pocket Rubik's Cube
- [x] Pyraminx
- [x] Skewb
### Citation
```
@article{hukmani2021solving,
title={Solving Twisty Puzzles Using Parallel Q-learning.},
author={Hukmani, Kavish and Kolekar, Sucheta and Vobugari, Sreekumar},
journal={Engineering Letters},
volume={29},
number={4},
year={2021}
}
```
## Details:
### 2x2x2 Pocket Rubik's Cube
![Mapping of tiles](images/rubiks_cube_222_mapping.png)
| | |
|--|--|
| Action Space | Discrete(3) |
| Observation Space| Discrete(3674160) |
| Actions | F, R, U |
| Rewards | (-inf, 100] |
| Max steps | 250 |
| Reward Types | Base, Layer By Layer Method, Ortega Method |
| Render Modes | 'human', 'rgb_array', 'ansi' |
### Pyraminx without tips
![Mapping of tiles](images/pyraminx_mapping.png)
| | |
|--|--|
| Action Space | Discrete(4) |
| Observation Space| Discrete(933120) |
| Actions | L, R, U, B |
| Rewards | (-inf, 100] |
| Max steps | 250 |
| Reward Types | Base, Layer by Layer Method |
| Render Modes | 'human', 'rgb_array', 'ansi' |
### Skewb
![Mapping of tiles](images/skewb_mapping.png)
| | |
|--|--|
| Action Space | Discrete(4) |
| Observation Space| Discrete(3149280) |
| Actions | L, R, U, B |
| Rewards | (-inf, 100] |
| Max steps | 250 |
| Reward Types | Base, Sarah's Method(Advanced) |
| Render Modes | 'human', 'rgb_array', 'ansi' |
## Installation
Via PyPI
pip install rubiks-cube-gym
Or build from source
git clone https://github.com/DoubleGremlin181/RubiksCubeGym.git
cd RubiksCubeGym
pip install -e .
## Requirements
- gym
- numpy
- opencv-python
- wget
## Scrambling
You can pass the scramble as a parameter for the reset function
`self.reset(scramble="R U R' U'")`
The scramble should follow the [WCA Notation](https://www.worldcubeassociation.org/regulations/#article-12-notation)
## Example
import gym
import rubiks_cube_gym
env = gym.make('rubiks-cube-222-lbl-v0')
env.reset(scramble="R U R' U' R' F R2 U' R' U' R U R' F'")
for _ in range(4):
env.render()
print(env.step(1))
env.render(render_time=0)
env.close()
</br>
(3178426, -26, False, {'cube': array([ 0, 9, 2, 15, 4, 5, 6, 21, 16, 10, 1, 11, 12, 13, 14, 23, 17, 7, 3, 19, 20, 18, 22, 8], dtype=uint8), 'cube_reduced': 'WRWGOOGYRBWBOOGYRGWBYBYR'})
(1542962, -1, False, {'cube': array([ 0, 21, 2, 23, 4, 5, 6, 18, 17, 16, 15, 11, 12, 13, 14, 8, 7, 10, 9, 19, 20, 3, 22, 1], dtype=uint8), 'cube_reduced': 'WYWYOOGBRRGBOOGRGBRBYWYW'})
(1682970, -1, False, {'cube': array([ 0, 18, 2, 8, 4, 5, 6, 3, 7, 17, 23, 11, 12, 13, 14, 1, 10, 16, 21, 19, 20, 9, 22, 15], dtype=uint8), 'cube_reduced': 'WBWROOGWGRYBOOGWBRYBYRYG'})
(2220193, 25, False, {'cube': array([ 0, 3, 2, 1, 4, 5, 6, 9, 10, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], dtype=uint8), 'cube_reduced': 'WWWWOOGRBGRBOOGGRRBBYYYY'})
![Output](images/example.gif)
You can find my implementation and results using Parallel Q-learning [here](https://github.com/DoubleGremlin181/RubiksCubeRL).
Raw data
{
"_id": null,
"home_page": "https://github.com/DoubleGremlin181/RubiksCubeGym/",
"name": "rubiks-cube-gym",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "environment,agent,rl,rubiks,cube,openai-gym,gym",
"author": "Kavish Hukmani",
"author_email": "khukmani@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6d/3e/5bccf8682617630b432574c9e087b6096e1a0f17fca8ce6ceebb48a496d3/rubiks_cube_gym-0.5.2.tar.gz",
"platform": null,
"description": "# RubiksCubeGym \n### An OpenAI Gym environment for various twisty puzzles. \n\n![PyPI](https://img.shields.io/pypi/v/rubiks_cube_gym)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/rubiks_cube_gym)\n![PyPI - License](https://img.shields.io/pypi/l/rubiks_cube_gym)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/rubiks_cube_gym)\n\nCurrently available environments: \n\n - [x] 2x2x2 Pocket Rubik's Cube \n - [x] Pyraminx\n - [x] Skewb\n \n### Citation\n```\n@article{hukmani2021solving,\n title={Solving Twisty Puzzles Using Parallel Q-learning.},\n author={Hukmani, Kavish and Kolekar, Sucheta and Vobugari, Sreekumar},\n journal={Engineering Letters},\n volume={29},\n number={4},\n year={2021}\n}\n```\n\n## Details: \n### 2x2x2 Pocket Rubik's Cube \n![Mapping of tiles](images/rubiks_cube_222_mapping.png)\n| | |\n|--|--|\n| Action Space | Discrete(3) |\n| Observation Space| Discrete(3674160) |\n| Actions | F, R, U | \n| Rewards | (-inf, 100] |\n| Max steps | 250 |\n| Reward Types | Base, Layer By Layer Method, Ortega Method |\n| Render Modes | 'human', 'rgb_array', 'ansi' |\n\n### Pyraminx without tips \n![Mapping of tiles](images/pyraminx_mapping.png)\n| | |\n|--|--|\n| Action Space | Discrete(4) |\n| Observation Space| Discrete(933120) |\n| Actions | L, R, U, B | \n| Rewards | (-inf, 100] |\n| Max steps | 250 |\n| Reward Types | Base, Layer by Layer Method |\n| Render Modes | 'human', 'rgb_array', 'ansi' |\n\n### Skewb\n![Mapping of tiles](images/skewb_mapping.png)\n| | |\n|--|--|\n| Action Space | Discrete(4) |\n| Observation Space| Discrete(3149280) |\n| Actions | L, R, U, B | \n| Rewards | (-inf, 100] |\n| Max steps | 250 |\n| Reward Types | Base, Sarah's Method(Advanced) |\n| Render Modes | 'human', 'rgb_array', 'ansi' |\n\n## Installation\nVia PyPI\n\n pip install rubiks-cube-gym\nOr build from source\n\n git clone https://github.com/DoubleGremlin181/RubiksCubeGym.git\n cd RubiksCubeGym\n pip install -e .\n\n## Requirements\n\n - gym\n - numpy\n - opencv-python\n - wget\n\n## Scrambling\nYou can pass the scramble as a parameter for the reset function\n`self.reset(scramble=\"R U R' U'\")`\n\nThe scramble should follow the [WCA Notation](https://www.worldcubeassociation.org/regulations/#article-12-notation)\n\n## Example\n import gym \n import rubiks_cube_gym \n \n env = gym.make('rubiks-cube-222-lbl-v0') \n env.reset(scramble=\"R U R' U' R' F R2 U' R' U' R U R' F'\") \n \n for _ in range(4): \n env.render() \n print(env.step(1)) \n env.render(render_time=0) \n env.close()\n \n</br>\n\n (3178426, -26, False, {'cube': array([ 0, 9, 2, 15, 4, 5, 6, 21, 16, 10, 1, 11, 12, 13, 14, 23, 17, 7, 3, 19, 20, 18, 22, 8], dtype=uint8), 'cube_reduced': 'WRWGOOGYRBWBOOGYRGWBYBYR'})\n (1542962, -1, False, {'cube': array([ 0, 21, 2, 23, 4, 5, 6, 18, 17, 16, 15, 11, 12, 13, 14, 8, 7, 10, 9, 19, 20, 3, 22, 1], dtype=uint8), 'cube_reduced': 'WYWYOOGBRRGBOOGRGBRBYWYW'})\n (1682970, -1, False, {'cube': array([ 0, 18, 2, 8, 4, 5, 6, 3, 7, 17, 23, 11, 12, 13, 14, 1, 10, 16, 21, 19, 20, 9, 22, 15], dtype=uint8), 'cube_reduced': 'WBWROOGWGRYBOOGWBRYBYRYG'})\n (2220193, 25, False, {'cube': array([ 0, 3, 2, 1, 4, 5, 6, 9, 10, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], dtype=uint8), 'cube_reduced': 'WWWWOOGRBGRBOOGGRRBBYYYY'})\n\n![Output](images/example.gif)\n\nYou can find my implementation and results using Parallel Q-learning [here](https://github.com/DoubleGremlin181/RubiksCubeRL).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "OpenAI Gym environments for various twisty puzzles",
"version": "0.5.2",
"project_urls": {
"Homepage": "https://github.com/DoubleGremlin181/RubiksCubeGym/"
},
"split_keywords": [
"environment",
"agent",
"rl",
"rubiks",
"cube",
"openai-gym",
"gym"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5c864c838482fe0d17237f327571d61c4cf78be19bf6e2fca92652d715c4babb",
"md5": "c952517f590cadd9043c7c9ecb7c14f8",
"sha256": "bf04565afa3b6522141dd70f1be611a7767b994c4a51f27d3e44bd5f2d0961cc"
},
"downloads": -1,
"filename": "rubiks_cube_gym-0.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c952517f590cadd9043c7c9ecb7c14f8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13565,
"upload_time": "2024-01-08T21:25:51",
"upload_time_iso_8601": "2024-01-08T21:25:51.893854Z",
"url": "https://files.pythonhosted.org/packages/5c/86/4c838482fe0d17237f327571d61c4cf78be19bf6e2fca92652d715c4babb/rubiks_cube_gym-0.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6d3e5bccf8682617630b432574c9e087b6096e1a0f17fca8ce6ceebb48a496d3",
"md5": "eba7f8424110ea340c7124af2d0ad8b5",
"sha256": "fedfde7dcd24c4c333342415648a4b87f3b94c6ac9096c2f3621930c526c08da"
},
"downloads": -1,
"filename": "rubiks_cube_gym-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "eba7f8424110ea340c7124af2d0ad8b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9216,
"upload_time": "2024-01-08T21:25:53",
"upload_time_iso_8601": "2024-01-08T21:25:53.317302Z",
"url": "https://files.pythonhosted.org/packages/6d/3e/5bccf8682617630b432574c9e087b6096e1a0f17fca8ce6ceebb48a496d3/rubiks_cube_gym-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-08 21:25:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DoubleGremlin181",
"github_project": "RubiksCubeGym",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "rubiks-cube-gym"
}