### Clone Repository and Install Dependencies Source: https://github.com/cubing/cubing.js/blob/main/CONTRIBUTING.md Clone the cubing.js repository and install development dependencies to set up your local environment. This command also starts the development server. ```shell git clone https://github.com/cubing/cubing.js && cd cubing.js make dev ``` -------------------------------- ### Twisty Player with Experimental Setup Alg Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Use the 'experimental-setup-alg' parameter for a setup algorithm and a multi-line algorithm for the main sequence. ```html ``` -------------------------------- ### Twisty Player with Experimental Setup Anchor Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Set 'experimental-setup-anchor' to 'end' to have the algorithm end in the solved state. When used with 'experimental-setup-alg', the player starts from the result of the setup alg. ```html ``` -------------------------------- ### Set Experimental Setup Algorithm Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/twisty/attributes.html The `experimental-setup-alg` attribute allows for setting a specific algorithm for the initial setup of the puzzle, distinct from the main algorithm. ```html experimental-setup-alg="L' U R U' L U R'" ``` -------------------------------- ### Install Cubing.js with npm Source: https://github.com/cubing/cubing.js/blob/main/README.md Install the cubing.js library using npm for use in your Node.js projects. Ensure you have Node.js and npm installed. ```shell npm install cubing ``` -------------------------------- ### Development Build Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/vr/README.md Run this command in the first shell to start the development build process. ```shell make dev ``` -------------------------------- ### Set Experimental Setup Anchor Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/twisty/attributes.html Configure the anchor point for the experimental setup algorithm using the `experimental-setup-anchor` attribute. Common values include 'end'. ```html experimental-setup-anchor="end" ``` -------------------------------- ### GAN356i Move Sequence Comparison Examples Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Examples demonstrating the comparison of byte sequences for cube moves, using a JavaScript function to highlight differences. ```bytes 00 00 24 18 49 92 24 49 61 aa db b6 49 92 aa 24 6d db -- // DF UB UF •• • •• •• ``` ```bytes 00 08 24 10 49 92 24 4d 61 aa db b6 49 92 a2 24 6d db -- // DF UB FU • • • • •• •• ``` ```bytes 30 00 24 00 49 92 24 49 61 aa db b6 49 8a b2 24 6d db -- // DF UB UL • • •• •• • ``` ```bytes 20 10 24 00 49 92 24 49 61 aa db b6 49 8e a2 24 6d db -- // DF UB LU ``` -------------------------------- ### Install Development Dependencies on macOS Source: https://github.com/cubing/cubing.js/blob/main/README.md Install the necessary tools for developing cubing.js on macOS using Homebrew. This includes git, git-lfs, node, and bun. ```shell brew install git git-lfs node oven-sh/bun/bun ``` -------------------------------- ### Basic Algorithm Sequences Source: https://github.com/cubing/cubing.js/blob/main/src/sites/alpha.twizzle.net/explore/help.html Examples of legal algorithm sequences on a 3x3x3 cube, demonstrating move notation and basic operations. ```alg R U R' U R U2 R' ``` ```alg [R' D R F D F', U2] ``` ```alg (U F R)3' ``` -------------------------------- ### Create a new cubing.js project Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/index.html Use `create-cubing-app` to quickly set up a new project with cubing.js. This command-line tool initializes a project structure and installs dependencies. ```bash npm create --yes cubing-app@latest my-cubing-project cd my-cubing-project npm run dev ``` -------------------------------- ### Include Cubing.js via CDN Source: https://github.com/cubing/cubing.js/blob/main/README.md Use this snippet to include the Twisty player component in your HTML via a CDN. This is the easiest way to get started. ```html ``` -------------------------------- ### Set Experimental Stickering Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/twisty/attributes.html Configure experimental stickering schemes using the `experimental-stickering` attribute. 'OLL' is an example for a specific set of algorithms. ```html experimental-stickering="OLL" ``` -------------------------------- ### GAN356i Cube State Byte Sequences Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Examples of byte sequences representing different cube states and algorithms. ```bytes 00 00 30 00 49 92 24 55 6d 92 db b6 49 86 aa 24 6d db da // H-perm ``` ```bytes 18 08 20 28 49 92 24 41 6d 92 db b6 49 82 a2 24 6d db b2 // UF/UR/UB/UL flip + H-perm ``` ```bytes 42 14 20 10 49 92 24 41 6d 92 db b6 49 82 a2 24 6d db 9e // UF/UR/UB/UL flip ``` ```bytes 00 00 24 10 49 92 44 41 6d 92 db b6 45 92 b6 24 6d db 56 // UF/LF flip ``` ```bytes 40 00 24 10 49 92 24 41 6d 92 db b6 49 82 b6 24 6d db 44 // UF/UL flip ``` ```bytes 00 14 24 10 49 92 24 41 6d 92 db b6 49 92 a2 24 6d db 30 // UF/UB flip ``` ```bytes 02 00 20 10 49 92 24 41 6d 92 db b6 49 92 b6 24 6d db 02 // UF/UR flip ``` ```bytes 00 60 24 00 a1 92 24 49 6d 64 1b ba 19 b2 b6 52 6c 57 ca // ULB sticker is yellow ``` ```bytes 00 a0 24 00 c9 92 24 49 76 62 1b 37 48 92 b5 12 6d d7 ea // ULB sticcker is blue ``` ```bytes 00 80 24 00 68 93 24 49 6d 89 6d b6 28 72 b6 a4 23 d7 af // ULB sticker is orange ``` ```bytes 00 20 24 00 d2 92 24 49 76 a4 1b b7 58 b2 b5 24 4d d6 a9 // ULB sticker is green ``` ```bytes 00 20 24 00 d2 92 24 49 76 a4 1b b7 58 b2 b5 24 4d d6 a9 // ULB sticker is red ``` ```bytes 92 24 49 49 92 24 00 00 92 00 24 49 db b6 6d 6d db b6 10 // centers: U -> R -> F ``` ```bytes 24 49 00 92 00 00 92 24 b6 49 6d db b6 6d 92 db 24 49 08 // centers: U -> F -> R ``` ```bytes 00 00 30 00 49 92 24 89 6d 92 db b6 c9 46 b6 24 6d 5b b1 // mirror T-perm ``` ```bytes 00 00 a5 00 49 12 a4 88 6d 92 db b6 c9 52 36 24 6d 5b 92 // E-perm ``` ```bytes 00 00 b1 00 49 12 a4 48 6d 92 db b6 49 86 36 24 6d db 73 // T-perm ``` ```bytes 01 00 44 01 49 92 24 08 6d 92 db b6 49 91 b6 24 6d db 44 // URF CCW, UFL CW ``` ```bytes 00 a0 44 01 49 92 24 48 6d 92 db b6 49 12 b6 24 6d 5b 2c // URF CCW, ULB CW ``` ```bytes 80 00 46 01 49 92 24 48 6d 92 db b6 49 92 16 24 6d db 1c // URF CCW, UBR CW ``` ```bytes 00 00 04 82 49 92 a4 88 6d 92 db b6 49 90 b6 24 6d db ea // URF CW, UFR CCW ``` ```bytes 00 80 04 02 49 92 a4 48 6d 92 db b6 49 b2 b4 24 6d 5b da // URF CW, ULB CCW ``` ```bytes 80 02 04 02 49 12 a4 48 6d 92 db b6 49 92 36 24 6d db c6 // URF CW, UBR CCW ``` ```bytes 42 14 20 10 59 aa 42 41 69 9a eb c2 55 82 a2 1c 5d 99 92 // superflip ``` ```bytes 00 00 24 00 6d 93 24 49 6d 49 db b6 48 92 b6 92 24 db 6d // D' ``` ```bytes 00 00 24 00 24 93 25 49 6d 6d db b6 48 92 b6 49 92 da 6c // D2 ``` ```bytes 00 00 24 00 92 92 25 49 6d 24 db b6 49 92 b6 6d 49 da 6b // D ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db 6a // solved ``` ```bytes 00 00 49 00 49 12 24 92 6d 92 db b6 c9 b6 24 24 6d db 61 // U' ``` ```bytes 00 00 92 00 49 12 a4 b6 6d 92 db b6 c9 24 49 24 6d 5b 62 // U2 ``` ```bytes 00 00 b6 00 49 92 a4 24 6d 92 db b6 49 49 92 24 6d 5b 5f // U ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db 5e // solved ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db 5e // solved ``` ```bytes 00 00 b1 00 49 12 a4 48 6d 92 db b6 49 86 36 24 6d db 73 // T-perm ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db 5e // solved ``` ```bytes 00 00 28 00 49 92 24 51 6d 92 db b6 49 86 b6 24 6d db 06 // UL -> UF -> UR * ** ** ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db 5e // solved ``` ```bytes 00 00 30 00 49 92 24 45 6d 92 db b6 49 8a b6 24 6d db fa // UR -> UF -> UL ``` ```bytes 04 00 a1 08 49 12 a4 40 6d 92 db b6 49 92 36 24 6d db URF/UBR UR/FU ``` ```bytes 06 00 b5 00 49 12 a4 48 6d 92 c3 b6 49 92 36 24 4d db URF/UBR UR/DB ``` ```bytes 06 00 a5 00 49 12 a4 48 6d 92 db b0 49 92 36 24 6d db URF/UBR UR/DR ``` ```bytes 06 00 a9 00 49 12 a4 48 61 8a db b6 49 92 36 24 6d db URF/UBR UR/DF ``` ```bytes 06 00 b1 00 49 12 a4 48 6d 92 db 86 49 92 36 0c 6d db URF/UBR UR/DL ``` ```bytes 0a 00 b1 00 49 12 a4 48 6d 92 db b6 19 92 36 24 6d d1 URF/UBR UR/BL ``` ```bytes 0a 00 a5 00 49 12 a4 48 6d 92 db b6 49 92 36 24 6d 8b URF/UBR UR/BR ``` ```bytes 04 00 a5 00 49 12 a0 48 6d 92 db b6 49 92 36 24 6d db URF/UBR UR/FR ``` ```bytes 04 00 b1 00 49 12 84 48 6d 92 db b6 43 92 36 24 6d db URF/UBR UR/FL ``` ```bytes 00 00 b5 00 49 12 a4 48 6d 92 db b6 49 92 26 24 6d db URF/UBR UR/UB ``` ```bytes 0a 04 a1 00 49 12 a4 48 6d 92 db b6 49 92 22 24 6d db URF/UBR UR/BU ``` ```bytes 00 00 b1 00 49 12 a4 48 6d 92 db b6 49 86 36 24 6d db URF/UBR UR/UL ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db solved ``` ```bytes 18 00 a1 00 49 12 a4 48 6d 92 db b6 49 82 36 24 6d db URF/UBR UR/LU ``` ```bytes 04 00 a1 08 49 12 a4 40 6d 92 db b6 49 92 36 24 6d db URF/UBR UR/FU ``` ```bytes 00 00 24 00 49 92 24 49 6d 92 db b6 49 92 b6 24 6d db solved ``` ```bytes 00 00 a9 00 49 12 a4 44 6d 92 db b6 49 92 36 24 6d db URF/UBR UR/UF ``` -------------------------------- ### Twisty Player with Experimental 2D LL Visualization Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Use 'experimental-2D-LL' for a specific 2D visualization mode for Last Layer algorithms. This example also configures background and control panel visibility. ```html ``` -------------------------------- ### Gan 356i Gyroscopic Data Battery Example Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Shows a sample byte sequence for gyroscopic data when the battery is at approximately 30-40%. ```text ≈30-40% battery: 0000000000000028c40e0000000000000000 ``` -------------------------------- ### Interactive Smart Puzzle Connection with UI Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/bluetooth/index.html An example demonstrating how to connect to a smart puzzle using a button click, with optional keyboard debugging. It integrates with twisty-player and twisty-alg-viewer for a visual representation of cube movements. ```html ``` -------------------------------- ### Example Cube Algorithms Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/multi-alg/index.html Common algorithms for solving the Rubik's Cube, such as T-Perm, J-Perm, and U-Perm. These are sequences of moves used in speedcubing. ```alg R U R' U' R' F R2 U' R' U' R U R' F' ``` ```alg U' R U R' F' R U R' U' R' F R2 U' R' ``` ```alg R2 U R U R' U' R' U' R' U R' ``` -------------------------------- ### Gan 356i FaceletStatus 1 Solved State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when the cube is in a solved state. ```text solved 18 08 20 28 49 92 24 41 6d 92 db b6 49 82 a2 24 6d db 52 ``` -------------------------------- ### Import Cubing.js Modules in Node.js Source: https://github.com/cubing/cubing.js/blob/main/README.md Import specific modules from the cubing.js library after installation. Requires ES2022 module compatibility. ```javascript import { Alg } from "cubing/alg"; import { TwistyPlayer } from "cubing/twisty"; ``` -------------------------------- ### Gan 356i Gravity Sensor Data Examples Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Provides sample byte sequences for gravity sensor readings (x, y, z axes) when the cube is flat on a table and when rotated along the x-axis from standard orientation. ```text Flat on table: 00 01 66 00 8b ca 2b 01 40 01 92 cb 09 01 52 00 26 c9 x from standard orientation: c8 e7 a3 26 6f db y: 21 ff 32 fe cb 3e z: 16 28 29 16 e1 d8 ``` -------------------------------- ### Gan 356i FaceletStatus 1 Superflip State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when the cube is in a superflip state. ```text superflip 00 00 30 00 59 aa 42 55 69 9a eb c2 55 86 aa 1c 5d 99 26 ``` -------------------------------- ### Gan 356i FaceletStatus 1 UF/UL Flip State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when the UF/UL edges are flipped. ```text UF/UL flip 08 08 20 00 49 92 24 55 6d 92 db b6 49 86 a2 24 6d db f0 ``` -------------------------------- ### Gan 356i FaceletStatus 1 UF/UR Flip State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when the UF/UR edges are flipped. ```text UF/UR flip 10 08 30 00 49 92 24 55 6d 92 db b6 49 82 a2 24 6d db d8 ``` -------------------------------- ### Gan 356i FaceletStatus 1 Solved State (Repeat) Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md A repeated example byte sequence for the 'FaceletStatus 1' when the cube is in a solved state. ```text solved 18 08 20 28 49 92 24 41 6d 92 db b6 49 82 a2 24 6d db 10 ``` -------------------------------- ### Gan 356i FaceletStatus 1 UF/UB Flip State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when the UF/UB edges are flipped. ```text UF/UB flip 18 00 20 00 49 92 24 55 6d 92 db b6 49 82 aa 24 6d db b6 ``` -------------------------------- ### Connect to a Smart Puzzle Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/bluetooth/index.html Connect to a smart puzzle and add a listener for algorithm leaf updates. This is a basic setup for receiving data from a connected device. ```javascript import { connectSmartPuzzle } from "https://cdn.cubing.net/v0/js/cubing/bluetooth"; const puzzle = await connectSmartPuzzle(); puzzle.addAlgLeafListener((e) => { console.log(e.latestAlgLeaf); }); ``` -------------------------------- ### Gan 356i FaceletStatus 1 Corners Solved, Edges Scrambled State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when corners are solved but edges are scrambled. ```text corners solved, edges scrambled 04 10 2c 00 59 da 02 45 61 a2 e3 c2 15 96 ae 2c 55 b5 98 ``` -------------------------------- ### Gan 356i FaceletStatus 1 Edges Solved, Corners Scrambled State Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Example byte sequence for the 'FaceletStatus 1' when edges are solved but corners are scrambled. ```text edges solved, corners scrambled 18 2a 40 ec c9 12 a4 a1 8c 95 58 b6 48 02 a2 a0 ab da d6 ``` -------------------------------- ### Serve VR Server Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/vr/README.md Navigate to the server directory and run this command in the third shell to serve the VR application. Access the application via the provided URLs. ```shell cd parcel/vr/server/ make serve ``` -------------------------------- ### Set Camera Longitude Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/twisty/attributes.html Control the horizontal rotation of the camera with the `camera-longitude` attribute. '0' is the default starting position. ```html camera-longitude="0" ``` -------------------------------- ### Clone and Develop Cubing.js Source: https://github.com/cubing/cubing.js/blob/main/README.md Clone the cubing.js repository and run the development server. Visit http://cubing.localhost:3333 to see the changes. Refer to contribution guidelines for more details. ```shell git clone https://github.com/cubing/cubing.js && cd cubing.js make dev # Now visit http://cubing.localhost:3333 ``` -------------------------------- ### Alg Constructor and String Conversion Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Demonstrates how to create an Alg object from a string and convert it back to a string representation. ```APIDOC ## Alg Constructor and String Conversion ### Description Parse an alg by passing it to the `Alg` constructor. You can call `.toString()` to get back a string representation. ### Method `new Alg(algString)` ### Parameters #### Path Parameters - **algString** (string) - Required - The string representation of the algorithm. ### Response #### Success Response (Alg Object) - **Alg Object** - An immutable Alg object. ### Request Example ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg" const alg = new Alg("R U R' U R U2' R'"); console.log(alg.toString()); ``` ### Response Example ``` "R U R' U R U2' R'" ``` ``` -------------------------------- ### Alg.experimentalSimplify([options]) Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Attempts to simplify the algorithm, canceling out adjacent inverse moves. ```APIDOC ## Alg.experimentalSimplify([options]) ### Description Attempts to simplify the algorithm, canceling out adjacent inverse moves. This method returns a new Alg object. ### Method `alg.experimentalSimplify([options])` ### Parameters #### Path Parameters - **options** (object) - Optional - An object containing simplification options. - **cancel** (boolean) - Optional - Whether to cancel adjacent inverse moves. ### Request Example ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg"; const commutator = new Alg("[R, [U': L']]"); const niklas = commutator.concat("U'"); niklas.expand().simplify({cancel: true}).log(); ``` ### Response Example ``` Alg {} "R U' L' U R' U' L" ``` ``` -------------------------------- ### Display OLL Stickering with Twisty Player Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Use the `experimental-stickering` attribute to display OLL stickering. This is useful for showing algorithms corresponding to a specific step in a speedsolving method. ```html ``` -------------------------------- ### Set Puzzle Type Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/twisty/attributes.html Specify the type of puzzle to be displayed using the `puzzle` attribute. For example, 'fto' for a Floppy Top Orientation. ```html puzzle="fto" ``` -------------------------------- ### Run All Checks in Cubing.js Source: https://github.com/cubing/cubing.js/blob/main/README.md Run all possible checks to ensure code quality and identify potential issues within the cubing.js project. ```shell make check ``` -------------------------------- ### Basic Twisty Player Usage Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Create a basic Twisty Player instance by providing an algorithm to the 'alg' attribute. ```html ``` -------------------------------- ### Generate a 3x3x3 Scramble Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/scramble/index.html Use `randomScrambleForEvent` to get a scramble for a specific event. This returns a Promise for an Alg object, which is best used with `await`. ```javascript ``` -------------------------------- ### Run Fast Checks in Cubing.js Source: https://github.com/cubing/cubing.js/blob/main/README.md Execute a quick set of checks for issues in your cubing.js development environment. For a comprehensive check, use 'make check'. ```shell make check-fast ``` -------------------------------- ### Access VR Experiments Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/vr/README.md Open these URLs in your browser to view the VR experiments. The first URL accesses the proxy, and the second accesses the main experiment page, with an option to hide control planes. ```shell open http://localhost:333/vr/proxy/proxy.html ``` ```shell open http://localhost:333/vr/index.html?showControlPlanes=false ``` -------------------------------- ### Parcel Build Source: https://github.com/cubing/cubing.js/blob/main/src/sites/experiments.cubing.net/cubing.js/vr/README.md Execute this command in the second shell to build the project using Parcel. ```shell make parcel ``` -------------------------------- ### Gan 356i Move Codes Source: https://github.com/cubing/cubing.js/blob/main/src/cubing/bluetooth/docs/gan356i.md Lists the byte codes corresponding to specific cube moves. For example, `02` represents U' and `03` represents R. ```text | Code | Move | | ---- | | `00` | U | | `02` | U' | | `03` | R | | `05` | R' | | `06` | F | | `08` | F' | | `09` | D | | `0b` | D' | | `0c` | L | | `0e` | L' | | `0f` | B | | `11` | B' | ``` -------------------------------- ### Display Cross Stickering with Twisty Player Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Use the `experimental-stickering` attribute to display Cross stickering. This is useful for showing algorithms corresponding to a specific step in a speedsolving method. Cross is currently only supported on the default D face (yellow). ```html ``` -------------------------------- ### Connect to Smart Puzzles Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/index.html Use `connectSmartPuzzle` to connect to Bluetooth-enabled smart cubes and listen for cube move events. ```javascript import { connectSmartPuzzle } from "https://cdn.cubing.net/v0/js/cubing/bluetooth"; const puzzle = await connectSmartPuzzle(); puzzle.addAlgLeafListener((e) => {  console.log(e.latestAlgLeaf); }); ``` -------------------------------- ### Importing cubing.js via npm Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/index.html Import specific modules from the 'cubing' npm package for use in your project. This is an alternative to CDN imports. ```javascript import { Alg } from "cubing/alg"; import { TwistyPlayer } from "cubing/twisty"; import { randomScrambleForEvent } from "cubing/scramble"; ``` -------------------------------- ### Twisty Player with Multiple Parameters Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Configure a Twisty Player with various parameters like puzzle type, algorithm, and visual settings. ```html ``` -------------------------------- ### Alg Class for Cube Notation Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/index.html Import and use the `Alg` class to parse, manipulate, and log cube notation. Compatible with SiGN and WCA notation. ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg"; const commutator = new Alg("[R, [U': L']]"); commutator.invert().expand().log(); ``` -------------------------------- ### Alg.log() Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Logs a canonical string representation of the alg to the console. ```APIDOC ## Alg.log() ### Description As a convenience, you can use `.log()` to view an alg in a JavaScript console. This results in a canonical string for the alg with whitespace collapsed. ### Method `alg.log()` ### Parameters None ### Request Example ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg" new Alg("R U R' U R U2' R'").log(); ``` ### Response Example ``` Alg {} "R U R' U R U2' R'" ``` ``` -------------------------------- ### Expand Alg with Depth Option Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Expands an algorithm with a specified depth limit. Imports the Alg class. ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg"; const oll = new Alg("[F: [R, U]]"); oll.expand({depth: 1}).log(); ``` -------------------------------- ### Invert and Expand Alg Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Inverts an algorithm and then expands the resulting algorithm. Imports the Alg class. ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg"; const sune = new Alg("[R U R2', [R: U]]"); const antiSune = sune.invert(); antiSune.log(); antiSune.expand().log(); ``` -------------------------------- ### Run Tests Source: https://github.com/cubing/cubing.js/blob/main/CONTRIBUTING.md Execute the test suite to ensure your changes do not introduce regressions. This command is used to verify the integrity of the codebase during development. ```shell make test ``` -------------------------------- ### Log Alg to Console Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Use the .log() method for convenient viewing of an Alg object in a JavaScript console. This method outputs a canonical string representation with whitespace collapsed. Imports the Alg class. ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg" new Alg("R U R' U R U2' R'").log(); ``` -------------------------------- ### Convert Algorithm to KTransformation Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/kpuzzle/index.html Use this to convert a string algorithm into a KTransformation object. This requires importing a puzzle definition and initializing its KPuzzle instance. ```javascript import { cube3x3x3 } from "https://cdn.cubing.net/v0/js/cubing/puzzles"; const kpuzzle = await cube3x3x3.kpuzzle(); const suneTransformation = kpuzzle.algToTransformation("R U R' U R U2' R'"); console.log(suneTransformation.repetitionOrder()); ``` -------------------------------- ### Twisty Player with 2D Visualization Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/twisty/index.html Enable 2D visualization for supported puzzles using the 'visualization' parameter set to '2D'. ```html ``` -------------------------------- ### Alg.expand() Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/alg/index.html Expands the algorithm, resolving any cube notation like commutators or conjugates. ```APIDOC ## Alg.expand([options]) ### Description Expands the algorithm, resolving any cube notation like commutators or conjugates. This method returns a new Alg object. ### Method `alg.expand([options])` ### Parameters #### Path Parameters - **options** (object) - Optional - An object containing expansion options. - **depth** (number) - Optional - The maximum depth to expand. ### Request Example ```javascript import { Alg } from "https://cdn.cubing.net/v0/js/cubing/alg"; const commutator = new Alg("[R, [U': L']]"); commutator.expand().log(); ``` ### Response Example ``` Alg {} "R U' L' U R' U' L U" ``` ``` -------------------------------- ### Generate Scrambles for Unofficial Events Source: https://github.com/cubing/cubing.js/blob/main/src/docs/js.cubing.net/cubing/scramble/index.html Shows how to generate scrambles for supported unofficial cubing events. ```javascript ```