Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype CornerPermu = CornerPermu {}
- newtype CornerOrien = CornerOrien {}
- data Corner = Corner {}
- cornerPermu :: Vector Int -> Maybe CornerPermu
- unsafeCornerPermu :: Vector Int -> CornerPermu
- unsafeCornerPermu' :: [Int] -> CornerPermu
- cornerOrien :: Vector Int -> Maybe CornerOrien
- unsafeCornerOrien :: Vector Int -> CornerOrien
- unsafeCornerOrien' :: [Int] -> CornerOrien
- newtype EdgePermu = EdgePermu {}
- newtype EdgeOrien = EdgeOrien {}
- data Edge = Edge {}
- edgePermu :: Vector Int -> Maybe EdgePermu
- unsafeEdgePermu :: Vector Int -> EdgePermu
- unsafeEdgePermu' :: [Int] -> EdgePermu
- edgeOrien :: Vector Int -> Maybe EdgeOrien
- unsafeEdgeOrien :: Vector Int -> EdgeOrien
- unsafeEdgeOrien' :: [Int] -> EdgeOrien
- data Cube = Cube {}
- class FromCube a where
- class CubeAction a where
- cubeAction :: a -> Cube -> a
- cube :: Vector Int -> Vector Int -> Vector Int -> Vector Int -> Maybe Cube
- cube' :: [Int] -> [Int] -> [Int] -> [Int] -> Maybe Cube
- unsafeCube :: Vector Int -> Vector Int -> Vector Int -> Vector Int -> Cube
- unsafeCube' :: [Int] -> [Int] -> [Int] -> [Int] -> Cube
- numCorners :: Int
- numEdges :: Int
- oPlus :: Integral a => a -> a -> a
- oInv :: (Num a, Ord a) => a -> a
- actionCorner :: CornerOrien -> Corner -> CornerOrien
- actionEdge :: EdgeOrien -> Edge -> EdgeOrien
- solvable :: Cube -> Bool
- symRotate :: Int -> [Int] -> [Int]
- toFacelet :: Cube -> Facelets
- colorFaceletsToCube :: ColorFacelets -> Either [Int] (Maybe Cube)
- stringOfCubeColors :: Cube -> String
- newtype UDSlicePermu = UDSlicePermu {}
- newtype UDSlice = UDSlice {
- fromUDSlice :: Vector Int
- newtype UDSlicePermu2 = UDSlicePermu2 {}
- newtype UDEdgePermu2 = UDEdgePermu2 {}
- type FlipUDSlice = (UDSlice, EdgeOrien)
- type FlipUDSlicePermu = (UDSlicePermu, EdgeOrien)
- numUDSliceEdges :: Int
- unsafeUDSlicePermu :: Vector Int -> UDSlicePermu
- unsafeUDSlicePermu' :: [Int] -> UDSlicePermu
- uDSlicePermu :: Vector Int -> Maybe UDSlicePermu
- uDSlice :: Vector Int -> Maybe UDSlice
- unsafeUDSlice :: Vector Int -> UDSlice
- unsafeUDSlice' :: [Int] -> UDSlice
- uDSlicePermu2 :: Vector Int -> Maybe UDSlicePermu2
- unsafeUDSlicePermu2 :: Vector Int -> UDSlicePermu2
- unsafeUDSlicePermu2' :: [Int] -> UDSlicePermu2
- uDEdgePermu2 :: Vector Int -> Maybe UDEdgePermu2
- unsafeUDEdgePermu2 :: Vector Int -> UDEdgePermu2
- unsafeUDEdgePermu2' :: [Int] -> UDEdgePermu2
- vSort :: Vector Int -> Vector Int
- unpermuUDSlice :: UDSlicePermu -> UDSlice
- edgePermu2 :: UDSlicePermu2 -> UDEdgePermu2 -> EdgePermu
- neutralUDSlicePermu :: UDSlicePermu
- neutralUDSlice :: UDSlice
- neutralUDSlicePermu2 :: UDSlicePermu2
- neutralUDEdgePermu2 :: UDEdgePermu2
- actionUDSlicePermu' :: EdgePermu -> Vector Int -> Vector Int
- actionUDSlicePermu :: UDSlicePermu -> EdgePermu -> UDSlicePermu
- actionUDSlice :: UDSlice -> EdgePermu -> UDSlice
- actionUDSlicePermu2 :: UDSlicePermu2 -> EdgePermu -> UDSlicePermu2
- actionUDEdgePermu2 :: UDEdgePermu2 -> EdgePermu -> UDEdgePermu2
- conjugateFlipUDSlice :: Cube -> FlipUDSlice -> FlipUDSlice
- conjugateFlipUDSlicePermu :: Cube -> FlipUDSlicePermu -> FlipUDSlicePermu
- conjugateEdgeOrien' :: Cube -> FlipUDSlicePermu -> EdgeOrien
- conjugateUDSlicePermu :: Cube -> UDSlicePermu -> UDSlicePermu
- conjugateCornerOrien :: Cube -> CornerOrien -> CornerOrien
Documentation
newtype CornerPermu Source
Cubie permutation is in replaced-by representation.
Eq CornerPermu Source | |
Show CornerPermu Source | |
Monoid CornerPermu Source | |
Group CornerPermu Source | |
CubeAction CornerPermu Source | |
FromCube CornerPermu Source | |
RawEncodable CornerPermu Source | The number of elements of every set is given. 8! = 40320 |
newtype CornerOrien Source
Corner | |
|
cornerPermu :: Vector Int -> Maybe CornerPermu Source
unsafeCornerPermu' :: [Int] -> CornerPermu Source
cornerOrien :: Vector Int -> Maybe CornerOrien Source
Check that the argument is a vector of senary (6) values of size 8 and wrap it.
In a solvable
Rubik's cube,
only ternary values are possible;
i.e., all elements must be between 0 and 2.
Their sum must also be a multiple of 3.
Orientation encoding
Corner orientations are permutations of 3 facelets.
They are mapped to integers in [0 .. 5]
such that [0, 1, 2]
are rotations (even permutations)
and [3, 4, 5]
are transpositions (although impossible in a Rubik's cube).
- 0. identity
- 1. counter-clockwise
- 2. clockwise
- 3. left facelet fixed
- 4. right facelet fixed
- 5. top (reference) facelet fixed
unsafeCornerOrien' :: [Int] -> CornerOrien Source
Cubie permutation is in replaced-by representation.
edgePermu :: Vector Int -> Maybe EdgePermu Source
Check that the argument is a permutation of size 12 and wrap it.
In a solvable
Rubik's cube,
its parity must be equal to that of the associated CornerPermu
.
unsafeEdgePermu :: Vector Int -> EdgePermu Source
unsafeEdgePermu' :: [Int] -> EdgePermu Source
edgeOrien :: Vector Int -> Maybe EdgeOrien Source
Check that the argument is a vector of binary values of size 12 and wrap it.
In a solvable
Rubik's cube, their sum must be even.
unsafeEdgeOrien :: Vector Int -> EdgeOrien Source
unsafeEdgeOrien' :: [Int] -> EdgeOrien Source
A cube is given by the positions of its corners and edges.
Cubes are identified with the permutations that produce them starting from the solved cube.
The cube permutation composition (class
) is defined
"in left to right order", so that the sequence of movements
"Group
Cube
x
then y
then z
" is represented by x <> y <> z
.
class CubeAction a where Source
Group action of Cube
on type a
x `cubeAction` iden == x (x `cubeAction` a) `cubeAction` b == x `cubeAction (a <> b)
It seems that with proper additional laws
between FromCube
and Group
instances,
it may be possible to automatically deduce a default CubeAction
instance.
cubeAction a = (a <>) . fromCube
This module defines representations of right cosets (Hg where g :: Cube
)
of certain subgroups H of the Rubik group Cube
, which acts on the right of
the set of cosets.
cubeAction :: a -> Cube -> a Source
numCorners :: Int Source
numCorners = 8
actionCorner :: CornerOrien -> Corner -> CornerOrien Source
actionEdge :: EdgeOrien -> Edge -> EdgeOrien Source
colorFaceletsToCube :: ColorFacelets -> Either [Int] (Maybe Cube) Source
Convert from facelet to cubie permutation.
Evaluates to a Left
error if a combination of colors does not correspond to
a regular cubie from the solved cube: the colors of the facelets on one
cubie must be unique, and must not contain facelets of opposite faces.
The error is the list of indices of facelets of such an invalid cubie.
Another possible error is that the resulting configuration is not a
permutation of cubies (at least one cubie is absent, and one is duplicated).
In that case, the result is Right
Nothing
.
stringOfCubeColors :: Cube -> String Source
UDSlice
newtype UDSlicePermu Source
Position of the 4 UDSlice edges (carried-to)
Position of the 4 UDSlice edges up to permutation (carried-to). The vector is always sorted.
newtype UDSlicePermu2 Source
Position of the 4 UDSlice edges (replaced-by), assuming they are all in that slice already.
newtype UDEdgePermu2 Source
Position of the 8 other edges (replaced-by), assuming UDSlice edges are in that slice already.
type FlipUDSlice = (UDSlice, EdgeOrien) Source
type FlipUDSlicePermu = (UDSlicePermu, EdgeOrien) Source
numUDSliceEdges = 4
unsafeUDSlicePermu' :: [Int] -> UDSlicePermu Source
uDSlicePermu :: Vector Int -> Maybe UDSlicePermu Source
unsafeUDSlice :: Vector Int -> UDSlice Source
unsafeUDSlice' :: [Int] -> UDSlice Source
uDSlicePermu2 :: Vector Int -> Maybe UDSlicePermu2 Source
Wrap a permutation of size 4.
unsafeUDSlicePermu2' :: [Int] -> UDSlicePermu2 Source
uDEdgePermu2 :: Vector Int -> Maybe UDEdgePermu2 Source
Wrap a permutation of size 8.
unsafeUDEdgePermu2' :: [Int] -> UDEdgePermu2 Source
edgePermu2 :: UDSlicePermu2 -> UDEdgePermu2 -> EdgePermu Source
actionUDSlice :: UDSlice -> EdgePermu -> UDSlice Source
conjugateFlipUDSlice :: Cube -> FlipUDSlice -> FlipUDSlice Source
The conjugation is only compatible when the Cube
symmetry
leaves UDSlice edges stable, and either flips them all or none of them,
and either flips all 8 non-UDSlice edges or none of them.
conjugateFlipUDSlicePermu :: Cube -> FlipUDSlicePermu -> FlipUDSlicePermu Source
Expects UDSlice-stable symmetry
conjugateCornerOrien :: Cube -> CornerOrien -> CornerOrien Source
Expects UDSlice-stable symmetry.