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
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 : List.Nonempty.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
-- 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
)
toAlgorithm : AUF -> Algorithm
Get the algorithm that corresponds to the AUF
import Algorithm
toAlgorithm Halfway
--> Algorithm.fromTurnList
--> [ Algorithm.Turn
--> Algorithm.U
--> Algorithm.Halfway
--> Algorithm.Clockwise
--> ]
toAlgorithmWithCustomTurnable : Algorithm.Turnable -> AUF -> Algorithm
Get the algorithm that corresponds to the AUF, but be able to specify which turnable to use to do the AUF. This is especially relevant for usecases such as an algorithm does an x or z rotation (or wide move) in the algorithm so the AUF is actually executed on a non-U face
import Algorithm
toAlgorithmWithCustomTurnable Algorithm.B Halfway
--> Algorithm.fromTurnList
--> [ Algorithm.Turn
--> Algorithm.B
--> Algorithm.Halfway
--> Algorithm.Clockwise
--> ]
toString : AUF -> String
Get an algorithm string representation of the AUF
toString Halfway --> "U2"
Explains an issue that occurred while parsing an AUF
InvalidAUFAlgorithm: The algorithm was parsed correctly but was not either an empty move or a turn of the U face
AlgorithmParsingProblem: The string was not a valid algorithm string and the contained Algorithm.FromStringError has the problem with the string
debugFromStringError : FromStringError -> String
Describes the error as a string, and is not recommended to be displayed to end-users, but rather to be used in error mesages logged for developer's eyes etc.
case fromString aufString of
Ok _ ->
doSomethingOnSuccess
Err error ->
logError (debugFromStringError error)
fromString : String -> Result FromStringError AUF
Attempts to parse an algorithmic representation of an AUF
fromString "U'" --> Ok CounterClockwise
fromString "" --> Ok None
fromString "U B"
--> Err (InvalidAUFAlgorithm "U B")
fromAlgorithm : Algorithm -> Maybe AUF
Parses an algorithm to see if it matches a single AUF. Note that it does not extract the AUFs used in a longer algorithm, it is instead meant to be the inverse of toAlgorithm. As a consequence of that any algorithm with length larger than 1 will return Nothing. It also only accepts AUFs that use U as the turnable
add : AUF -> AUF -> AUF
Adds together two AUFs, returning the AUF that would be the result of applying the two AUFs consecutively