Name | alphacube JSON |
Version |
0.1.5
JSON |
| download |
home_page | None |
Summary | A powerful & flexible Rubik's Cube solver |
upload_time | 2025-07-12 16:51:47 |
maintainer | None |
docs_url | None |
author | Kyo Takano |
requires_python | >=3.6 |
license | MIT License
Copyright (c) 2023 Kyo Takano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
rubiks-cube
solver
ai
|
VCS |
 |
bugtrack_url |
|
requirements |
torch
numpy
rich
pydantic
requests
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# AlphaCube
AlphaCube is a powerful & flexible Rubik's Cube solver that extends [EfficientCube](https://github.com/kyo-takano/efficientcube). It uses a Deep Neural Network (DNN) to find optimal/near-optimal solutions for a given scrambled state.
> [!NOTE]
> **🎮 Try the interactive demo: [alphacube.dev](https://alphacube.dev)**
## Use Cases
- Solve any scrambled Rubik's Cube configuration with ease.
- Find efficient algorithms, optimizing for either solution length or ergonomic move sequences.
- Incorporate solving capabilities into custom Rubik's Cube applications and tools.
- Analyze the statistical properties and solution space of the Rubik's Cube.
- Illustrate AI/ML concepts such as self-supervised learning and heuristic search.
## Installation
Open a terminal and execute the following command:
```sh
pip install -U alphacube
```
## Usage
The first time you run `alphacube.load()`, the required model data will be downloaded and cached on your system for future use.
### Basic Usage
```python
import alphacube
# Load a pre-trained model (defaults to "small" on CPU, "large" on GPU)
alphacube.load()
# Solve a scramble
result = alphacube.solve(
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
beam_width=1024, # Number of candidate solutions to consider at each depth of search
)
print(result)
```
> **Output**
>
> ```python
> {
> 'solutions': [
> "D L D2 R' U2 D B' D' U2 B U2 B' U' B2 D B2 D' B2 F2 U2 F2"
> ],
> 'num_nodes': 19744, # Total search nodes explored
> 'time': 1.4068585219999659 # Time in seconds
> }
> ```
### Better Solutions
Increasing `beam_width` makes the search more exhaustive, yielding shorter solutions at the cost of extra compute:
```python
result = alphacube.solve(
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
beam_width=65536,
)
print(result)
```
> **Output**
>
> ```python
> {
> 'solutions': [
> "D' R' D2 F' L2 F' U B F D L D' L B D2 R2 F2 R2 F'",
> "D2 L2 R' D' B D2 B' D B2 R2 U2 L' U L' D' U2 R' F2 R'"
> ],
> 'num_nodes': 968984,
> 'time': 45.690575091997744
> }
> ```
`beam_width` values between 1024 and 65536 typically offer a good trade-off between solution quality and speed. Tune according to your needs.
### GPU Acceleration
For maximal performance, use the `"large"` model on a GPU (or MPS if you have Mac).
```python
alphacube.load("large")
result = alphacube.solve(
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
beam_width=65536,
)
print(result)
```
> **Output**
>
> ```python
> {
> 'solutions': ["D F L' F' U2 B2 U F' L R2 B2 U D' F2 U2 R D'"],
> 'num_nodes': 903448,
> 'time': 20.46845487099995
> }
> ```
> [!IMPORTANT]
> When running on a CPU, the default `"small"` model is recommended. The `"base"` and `"large"` models are significantly slower without a GPU.
Please refer to our [documentation](https://alphacube.dev/docs) for more, especially ["Getting Started"](https://alphacube.dev/docs/getting-started/index.html)
### Applying Ergonomic Bias
The `ergonomic_bias` parameter can influence the solver to prefer certain types of moves, generating solutions that might be easier to perform.
```python
# Define desirability for each move type (higher is more desirable)
ergonomic_bias = {
"U": 0.9, "U'": 0.9, "U2": 0.8,
"R": 0.8, "R'": 0.8, "R2": 0.75,
"L": 0.55, "L'": 0.4, "L2": 0.3,
"F": 0.7, "F'": 0.6, "F2": 0.6,
"D": 0.3, "D'": 0.3, "D2": 0.2,
"B": 0.05, "B'": 0.05, "B2": 0.01,
"u": 0.45, "u'": 0.45, "u2": 0.4,
"r": 0.3, "r'": 0.3, "r2": 0.25,
"l": 0.2, "l'": 0.2, "l2": 0.15,
"f": 0.35, "f'": 0.3, "f2": 0.25,
"d": 0.15, "d'": 0.15, "d2": 0.1,
"b": 0.03, "b'": 0.03, "b2": 0.01
}
result = alphacube.solve(
scramble="D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2",
beam_width=65536,
ergonomic_bias=ergonomic_bias
)
print(result)
```
> **Output**
>
> ```python
> {
> 'solutions': [
> "u' U' f' R2 U2 R' L' F' R D2 f2 R2 U2 R U L' U R L",
> "u' U' f' R2 U2 R' L' F' R D2 f2 R2 U2 R d F' U f F",
> "u' U' f' R2 U2 R' L' F' R u2 F2 R2 D2 R u f' l u U"
> ],
> 'num_nodes': 1078054,
> 'time': 56.13087955299852
> }
> ```
## How It Works
At its core, AlphaCube uses the deep learning method from ["Self-Supervision is All You Need for Solving Rubik's Cube" (TMLR'23)](https://openreview.net/forum?id=bnBeNFB27b), the official code for which is available at [`kyo-takano/efficientcube`](https://github.com/kyo-takano/efficientcube).
The provided models (`"small"`, `"base"`, and `"large"`) are **compute-optimally trained** in the Half-Turn Metric. This means model size and training data were scaled together to maximize prediction accuracy for a given computational budget, as detailed in the paper.
> [!NOTE]
> **📖 Read more: ["How It Works"](https://alphacube.dev/docs/how-it-works)** on our documentation site.
## Contributing
You are welcome to collaborate on AlphaCube! Please read our [Contributing Guide](https://github.com/kyo-takano/alphacube/blob/main/CONTRIBUTING.md) to get started.
## License
AlphaCube is open source under the [MIT License](LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "alphacube",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "rubiks-cube, solver, ai",
"author": "Kyo Takano",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# AlphaCube\n\nAlphaCube is a powerful & flexible Rubik's Cube solver that extends [EfficientCube](https://github.com/kyo-takano/efficientcube). It uses a Deep Neural Network (DNN) to find optimal/near-optimal solutions for a given scrambled state.\n\n> [!NOTE]\n> **\ud83c\udfae Try the interactive demo: [alphacube.dev](https://alphacube.dev)**\n\n## Use Cases\n\n- Solve any scrambled Rubik's Cube configuration with ease.\n- Find efficient algorithms, optimizing for either solution length or ergonomic move sequences.\n- Incorporate solving capabilities into custom Rubik's Cube applications and tools.\n- Analyze the statistical properties and solution space of the Rubik's Cube.\n- Illustrate AI/ML concepts such as self-supervised learning and heuristic search.\n\n## Installation\n\nOpen a terminal and execute the following command:\n\n```sh\npip install -U alphacube\n```\n\n## Usage\n\nThe first time you run `alphacube.load()`, the required model data will be downloaded and cached on your system for future use.\n\n### Basic Usage\n\n```python\nimport alphacube\n\n# Load a pre-trained model (defaults to \"small\" on CPU, \"large\" on GPU)\nalphacube.load()\n\n# Solve a scramble\nresult = alphacube.solve(\n scramble=\"D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2\",\n beam_width=1024, # Number of candidate solutions to consider at each depth of search\n)\nprint(result)\n```\n\n> **Output**\n>\n> ```python\n> {\n> 'solutions': [\n> \"D L D2 R' U2 D B' D' U2 B U2 B' U' B2 D B2 D' B2 F2 U2 F2\"\n> ],\n> 'num_nodes': 19744, # Total search nodes explored\n> 'time': 1.4068585219999659 # Time in seconds\n> }\n> ```\n\n### Better Solutions\n\nIncreasing `beam_width` makes the search more exhaustive, yielding shorter solutions at the cost of extra compute:\n\n```python\nresult = alphacube.solve(\n scramble=\"D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2\",\n beam_width=65536,\n)\nprint(result)\n```\n\n> **Output**\n>\n> ```python\n> {\n> 'solutions': [\n> \"D' R' D2 F' L2 F' U B F D L D' L B D2 R2 F2 R2 F'\",\n> \"D2 L2 R' D' B D2 B' D B2 R2 U2 L' U L' D' U2 R' F2 R'\"\n> ],\n> 'num_nodes': 968984,\n> 'time': 45.690575091997744\n> }\n> ```\n\n`beam_width` values between 1024 and 65536 typically offer a good trade-off between solution quality and speed. Tune according to your needs.\n\n### GPU Acceleration\n\nFor maximal performance, use the `\"large\"` model on a GPU (or MPS if you have Mac).\n\n```python\nalphacube.load(\"large\")\nresult = alphacube.solve(\n scramble=\"D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2\",\n beam_width=65536,\n)\nprint(result)\n```\n\n> **Output**\n>\n> ```python\n> {\n> 'solutions': [\"D F L' F' U2 B2 U F' L R2 B2 U D' F2 U2 R D'\"],\n> 'num_nodes': 903448,\n> 'time': 20.46845487099995\n> }\n> ```\n\n> [!IMPORTANT]\n> When running on a CPU, the default `\"small\"` model is recommended. The `\"base\"` and `\"large\"` models are significantly slower without a GPU.\n\nPlease refer to our [documentation](https://alphacube.dev/docs) for more, especially [\"Getting Started\"](https://alphacube.dev/docs/getting-started/index.html)\n\n### Applying Ergonomic Bias\n\nThe `ergonomic_bias` parameter can influence the solver to prefer certain types of moves, generating solutions that might be easier to perform.\n\n```python\n# Define desirability for each move type (higher is more desirable)\nergonomic_bias = {\n \"U\": 0.9, \"U'\": 0.9, \"U2\": 0.8,\n \"R\": 0.8, \"R'\": 0.8, \"R2\": 0.75,\n \"L\": 0.55, \"L'\": 0.4, \"L2\": 0.3,\n \"F\": 0.7, \"F'\": 0.6, \"F2\": 0.6,\n \"D\": 0.3, \"D'\": 0.3, \"D2\": 0.2,\n \"B\": 0.05, \"B'\": 0.05, \"B2\": 0.01,\n \"u\": 0.45, \"u'\": 0.45, \"u2\": 0.4,\n \"r\": 0.3, \"r'\": 0.3, \"r2\": 0.25,\n \"l\": 0.2, \"l'\": 0.2, \"l2\": 0.15,\n \"f\": 0.35, \"f'\": 0.3, \"f2\": 0.25,\n \"d\": 0.15, \"d'\": 0.15, \"d2\": 0.1,\n \"b\": 0.03, \"b'\": 0.03, \"b2\": 0.01\n}\n\nresult = alphacube.solve(\n scramble=\"D U F2 L2 U' B2 F2 D L2 U R' F' D R' F' U L D' F' D R2\",\n beam_width=65536,\n ergonomic_bias=ergonomic_bias\n)\nprint(result)\n```\n\n> **Output**\n>\n> ```python\n> {\n> 'solutions': [\n> \"u' U' f' R2 U2 R' L' F' R D2 f2 R2 U2 R U L' U R L\",\n> \"u' U' f' R2 U2 R' L' F' R D2 f2 R2 U2 R d F' U f F\",\n> \"u' U' f' R2 U2 R' L' F' R u2 F2 R2 D2 R u f' l u U\"\n> ],\n> 'num_nodes': 1078054,\n> 'time': 56.13087955299852\n> }\n> ```\n\n## How It Works\n\nAt its core, AlphaCube uses the deep learning method from [\"Self-Supervision is All You Need for Solving Rubik's Cube\" (TMLR'23)](https://openreview.net/forum?id=bnBeNFB27b), the official code for which is available at [`kyo-takano/efficientcube`](https://github.com/kyo-takano/efficientcube).\n\nThe provided models (`\"small\"`, `\"base\"`, and `\"large\"`) are **compute-optimally trained** in the Half-Turn Metric. This means model size and training data were scaled together to maximize prediction accuracy for a given computational budget, as detailed in the paper.\n\n> [!NOTE]\n> **\ud83d\udcd6 Read more: [\"How It Works\"](https://alphacube.dev/docs/how-it-works)** on our documentation site.\n\n## Contributing\n\nYou are welcome to collaborate on AlphaCube! Please read our [Contributing Guide](https://github.com/kyo-takano/alphacube/blob/main/CONTRIBUTING.md) to get started.\n\n## License\n\nAlphaCube is open source under the [MIT License](LICENSE).\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2023 Kyo Takano\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "A powerful & flexible Rubik's Cube solver",
"version": "0.1.5",
"project_urls": {
"Documentation": "https://alphacube.dev/docs/index.html",
"Source": "https://github.com/kyo-takano/alphacube"
},
"split_keywords": [
"rubiks-cube",
" solver",
" ai"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "883eb938ff762e2a1e7d385f5e535c321cfa456e58c8fddd69ffeb4926097543",
"md5": "ed0b6e361f49988d6ce4aeb1458eede5",
"sha256": "c5995262982a949690f008aa2beb74f81b094a61090a696dc622c470ed24c10e"
},
"downloads": -1,
"filename": "alphacube-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ed0b6e361f49988d6ce4aeb1458eede5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 27099,
"upload_time": "2025-07-12T16:51:47",
"upload_time_iso_8601": "2025-07-12T16:51:47.599803Z",
"url": "https://files.pythonhosted.org/packages/88/3e/b938ff762e2a1e7d385f5e535c321cfa456e58c8fddd69ffeb4926097543/alphacube-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-12 16:51:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kyo-takano",
"github_project": "alphacube",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "torch",
"specs": [
[
">=",
"2.0"
]
]
},
{
"name": "numpy",
"specs": [
[
">=",
"2.0"
]
]
},
{
"name": "rich",
"specs": [
[
">=",
"13.0"
]
]
},
{
"name": "pydantic",
"specs": [
[
">=",
"2.0"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.28.2"
]
]
}
],
"lcname": "alphacube"
}