emilgoldsmith/elm-speedcubing/6.0.0

NOTE: the latest version is 14.1.0

Cube

Definition

type alias Cube =

This type represents a 3x3 Rubik's Cube that can be displayed. That means that encoded in the model is also the orientation of the whole cube. This means that a cube with yellow facing upwards is not the same as a cube in the same state with the green face facing upwards.

You can use the helper functions below to manipulate and display the cube. You could for example do something like this:

import Algorithm
import Cube


Cube.solved
    |> Cube.applyAlgorithm
        (
            Algorithm.fromTurnList
                [
                    Algorithm.Turn
                        Algorithm.U
                        Algorithm.Halfway
                        Algorithm.Clockwise
                ]
        )
    |> Cube.viewUFRNoLetters

Constructors

solved : Cube

A solved cube with the initial orientation, so the up face has UpColor etc.

Modifiers

applyAlgorithm : Algorithm -> Cube -> Cube

Apply the given moves of the algorithm to the cube. Reminder that this again depends on the orientation of the cube how the turns will be applied, though problems with this aren't expected to arise often given "normal use".

Displayers

viewUFRWithLetters : List (Attribute msg) -> Int -> Cube -> Html msg

Display the Up, Front and Right sides of the cube with letters signifying the sides of the cube being displayed on the center caps

viewUFRNoLetters : List (Attribute msg) -> Int -> Cube -> Html msg

Display the Up, Front and Right sides of the cube with no letters or anything on the center caps

viewUBLWithLetters : List (Attribute msg) -> Int -> Cube -> Html msg

Display the Up, Back and Left sides of the cube with letters signifying the sides of the cube being displayed on the center caps

Algorithm Helpers

Some algorithm functionality such as whether two algorithms are equivalent can only be determined in the context of having a cube, so they belong here and not in the Algorithm module.

Check that two algorithms produce the exact same result when applied to a cube. They also have to end at the exact same orientation, so while you may very rarely want this, you are probably looking for algorithmResultAreEquivalentIndependentOfFinalRotation

Checks that two algorithms produce the exact same result, but they are allowed to leave the cube in different orientations / rotations and still be considered equivalent