emilgoldsmith/elm-speedcubing/3.0.0

NOTE: the latest version is 14.1.0

AUF

Types and helpers to deal with Adjust U Face (AUF), which are the moves needed either to adjust the U face to the right angle for executing your algorithms for several algorithm sets such as OLL and PLL, or the last move needed to solve the cube for example after PLL. See https://www.speedsolving.com/wiki/index.php/AUF for more information

Definition and Constructors

type AUF
= None
| Clockwise
| Halfway
| CounterClockwise

The 4 different AUFs. U, U', U2, and nothing. Use these value constructors together with @all when you need to construct in different ways.

all : Nonempty AUF

A nonempty list containing all the possible aufs. Could for example be used to generate a random auf or generate all the possible versions of an algorithm

import List.Nonempty


-- They are all there!
List.Nonempty.length all --> 4


-- Generate a random one
List.Nonempty.sample all


import PLL


-- Get all versions of a Y perm
all
    |> List.Nonempty.map (Tuple.pair PLL.Y)
    |> List.Nonempty.map (\(pll, postAuf) ->
        List.Nonempty.map
            (\preAuf -> (preAuf, pll, postAuf))
            all
    )

Helpers

Get the algorithm that corresponds to the AUF

import Algorithm


toAlgorithm Halfway
-->  Algorithm.build
-->    [ Algorithm.Turn
-->        Algorithm.U
-->        Algorithm.Halfway
-->        Algorithm.Clockwise
-->    ]
toString : AUF -> String

Get an algorithm string representation of the AUF

toString Halfway --> "U2"
fromString : String -> Result String AUF

Attempts to parse an algorithmic representation of an AUF

fromString "U'" --> Ok CounterClockwise


fromString "" --> Ok None


fromString "U B"
--> Err
-->     ("An AUF must be no move or "
-->         ++ "a single turn of the U layer"
-->     )