| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rubik.Cube.Facelet
Contents
Description
Facelet representation
Facelets faces are unfolded and laid out like this:
U
L F R B
D
Faces (or colors) are ordered U, L, F, R, B, D.
A Rubik's cube is a permutation of facelets numbered as follows:
0 1 2
3 4 5
6 7 8
9 10 11 18 19 20 27 28 29 36 37 38
12 13 14 21 22 23 30 31 32 39 40 41
15 16 17 24 25 26 33 34 35 42 43 44
45 46 47
48 49 50
51 52 53- numFacelets :: Int
- data Facelets
- facelets :: Vector Int -> Maybe Facelets
- fromFacelets :: Facelets -> Vector Int
- type Color = Int
- colorOf :: Int -> Color
- colorChar :: Color -> Char
- data ColorFacelets
- colorFacelets :: Vector Color -> Maybe ColorFacelets
- fromColorFacelets :: ColorFacelets -> Vector Color
- colorFaceletsOf :: Facelets -> ColorFacelets
- fromFacelets' :: Facelets -> [Int]
- facelets' :: [Int] -> Maybe Facelets
- fromColorFacelets' :: ColorFacelets -> [Color]
- colorFacelets' :: [Color] -> Maybe ColorFacelets
- colorFacelets'' :: Eq a => [a] -> Maybe ColorFacelets
- stringOfFacelets :: Facelets -> String
- stringOfColorFacelets :: ColorFacelets -> String
- stringOfColorFacelets' :: Facelets -> String
- centerFacelets :: [Int]
- cornerFacelets :: [[Int]]
- ulb :: [Int]
- ufl :: [Int]
- urf :: [Int]
- ubr :: [Int]
- dlf :: [Int]
- dfr :: [Int]
- drb :: [Int]
- dbl :: [Int]
- edgeFacelets :: [[Int]]
- ul :: [Int]
- uf :: [Int]
- ur :: [Int]
- ub :: [Int]
- dl :: [Int]
- df :: [Int]
- dr :: [Int]
- db :: [Int]
- fl :: [Int]
- fr :: [Int]
- bl :: [Int]
- br :: [Int]
Facelet permutation
numFacelets :: Int Source
There are 54 == 6 * 9 facelets.
Cube as a permutation of facelets (replaced-by).
Every facelet is represented as an Int in [0 .. 54].
facelets :: Vector Int -> Maybe Facelets Source
This constructor checks that the input is a permutation of '[0 .. 53]'.
Colors
colorChar :: Color -> Char Source
A color is mapped to a face, indicated by a Char:
map colorChar [0..5] == "ULFRBD"
Color list
colorFacelets :: Vector Color -> Maybe ColorFacelets Source
This constructor checks that only standard colors (in [0 .. 5])
are used, that the argument has length 54 and that the centers
are colored in order.
Note that there may still be more or less than 9 colors of a kind, although that cannot be the case in an actual cube.
colorFaceletsOf :: Facelets -> ColorFacelets Source
Remove permutation information.
If the argument cube can be obtained from the solved cube with the usual moves,
then the original permutation can be recovered with colorFaceletsToCube.
List conversions
fromFacelets' :: Facelets -> [Int] Source
See fromFacelets'
fromColorFacelets' :: ColorFacelets -> [Color] Source
See fromColorFacelets.
colorFacelets' :: [Color] -> Maybe ColorFacelets Source
See colorFacelets.
colorFacelets'' :: Eq a => [a] -> Maybe ColorFacelets Source
Convert a 6-color list of length 54 in any representation which implements Eq
to ColorFacelets.
Pretty conversion
stringOfFacelets :: Facelets -> String Source
String listing the permutation of facelets numbered in base 9.
Base 9 is convenient here because the first digit directly corresponds to a face and the second to the facelet position in that face.
stringOfColorFacelets :: ColorFacelets -> String Source
String listing the facelet colors.
stringOfColorFacelets' :: Facelets -> String Source
Only show the colors of the facelets.
Facelets corresponding to each cubie
The first letter in the name of a cubie is
the color of its reference facelet
(illustrated at http://kociemba.org/math/cubielevel.htm).
Corner colors are given in clockwise order.
Corners are lexicographically ordered
(U>L>F>R>B>D).
Edges are gathered by horizontal slices (U, D, UD).
Centers
centerFacelets :: [Int] Source
centerFacelets
= [ 4, -- U
13, -- L
22, -- F
31, -- R
40, -- B
49] -- D
Corners
cornerFacelets :: [[Int]] Source
cornerFacelets = [ulb, ufl, urf, ubr, dlf, dfr, drb, dbl]
Edges
edgeFacelets :: [[Int]] Source
edgeFacelets = [ul, uf, ur, ub, dl, df, dr, db, fl, fr, bl, br]