Rubik Sim
This project allows to simulate a 3x3 Rubik's cube and perform operations over it.
⚙️ Setup
Requirements
- Python 3.9 or higher
Installation
The package is installable via pip:
pip install rubik-sim
Alternatively, the 'develop' branch can be installed for the latest changes
pip install git+https://github.com/Jtachan/genetic_rubiks_solver.git@develop
🏃 Usage
Initializing the cube
The package allows importing all the classes directly from the module.
To initialize the cube, it is only needed the RubiksCube class.
This generates a fully solved cube. To obtain a random state using scramble()
from rubik_sim import RubiksCube
my_cube = RubiksCube() # Solved cube
my_cube.scramble() # Updates the cube by 25 random moves
The number of moves to scramble the cube can also be specified as a parameter:
RubiksCube.scramble(nof_moves: int = 25)
It is also possible to initialize any cube from a string of characters defining the color of each tile.
my_cube = RubiksCube.from_color_code(
'BBBBBBBBBGGGGGGGGGOOOOOOOOOYYYYYYYYYRRRRRRRRRWWWWWWWWW'
)
The only supported colors are green ('G'), orange ('O'), yellow ('Y'), red ('R'), white ('W') and blue ('B').
Representation
The cube's state can be represented by calling print()
>>> print(my_cube)
['B' 'B' 'B']
['B' 'B' 'B']
['B' 'B' 'B']
['G' 'G' 'G']['O' 'O' 'O']['Y' 'Y' 'Y']['R' 'R' 'R']
['G' 'G' 'G']['O' 'O' 'O']['Y' 'Y' 'Y']['R' 'R' 'R']
['G' 'G' 'G']['O' 'O' 'O']['Y' 'Y' 'Y']['R' 'R' 'R']
['W' 'W' 'W']
['W' 'W' 'W']
['W' 'W' 'W']
From the representation, the faces are:
- Blue = Top (up) face
- Green = Left face
- Orange = Front face
- Yellow = Right face
- Red = Back face
- White = Bottom (down) face
Rotating the cube
RubiksCube.perform_operations(operations: Sequence[NOTATION_MOVES])
This method updates the current state of the cube by performing operations over it. The supported operations are:
U, U', U2, D, D', D2, R, R', R2, L, L', L2, F, F', F2, B, B', B2, M, M', M2, E, E', E2, S, S' and S2.
These are the general notations for the possible moves on the cube. More about the Rubik's cube notation: https://ruwix.com/the-rubiks-cube/notation/
Any missing notation can be performed with the current notations.
Metadata
Release files for rubik-sim 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rubik-sim-1.0.0.tar.gz | 8.2 kB | Without provenance | Details for rubik-sim-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rubik_sim-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for rubik_sim-1.0.0-py3-none-any.whl |
Total release size: 16.0 kB
Release files / rubik-sim-1.0.0.tar.gz
| Download URL | rubik-sim-1.0.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8f3e8cac60758b2082c7da7b74ad5c5cb2d86a88afd52a3d961b24b68a734a4
|
|
BLAKE2b-256 checksum How to use checksums |
caec8c1d617a5aa591725cbba6c10328417325fd2d2aa8b2b59e3cc961d4ccd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Release files / rubik_sim-1.0.0-py3-none-any.whl
| Download URL | rubik_sim-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dab9b7327f0e6cc5cb85252e6fa9ade1a514e2f210bb12d868fef3bffa060d6f
|
|
BLAKE2b-256 checksum How to use checksums |
a4eeece317383c8785dcf0284b18f808c1c3e7d24b717e919af5dd0275228925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Security for rubik-sim 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.