twentyseven-0.0.0: Rubik's cube solver

Safe HaskellNone
LanguageHaskell2010

Rubik.Cube.Cubie.Internal

Contents

Synopsis

Documentation

newtype CornerPermu Source

Cubie permutation is in replaced-by representation.

Constructors

CornerPermu 

cornerPermu :: Vector Int -> Maybe CornerPermu Source

Check that the argument is a permutation of size 8 and wrap it.

In a solvable Rubik's cube, its parity must be equal to that of the associated EdgePermu.

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

newtype EdgePermu Source

Cubie permutation is in replaced-by representation.

Constructors

EdgePermu 

Instances

Eq EdgePermu Source 
Show EdgePermu Source 
Monoid EdgePermu Source 
Group EdgePermu Source 
CubeAction EdgePermu Source 
FromCube EdgePermu Source 
RawEncodable EdgePermu Source
12! = 479001600

A bit too much to hold in memory.

Holds just right in a Haskell Int (maxInt >= 2^29 - 1).

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.

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.

data Cube 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 Group Cube) is defined "in left to right order", so that the sequence of movements "x then y then z" is represented by x <> y <> z.

Constructors

Cube 

Fields

corner :: Corner
 
edge :: Edge
 

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.

Methods

cubeAction :: a -> Cube -> a Source

cube' :: [Int] -> [Int] -> [Int] -> [Int] -> Maybe Cube Source

unsafeCube' :: [Int] -> [Int] -> [Int] -> [Int] -> Cube Source

numCorners :: Int Source

numCorners = 8

numEdges :: Int Source

numEdges = 12

oPlus :: Integral a => a -> a -> a Source

oInv :: (Num a, Ord a) => a -> a Source

solvable :: Cube -> Bool Source

Tests whether a cube can be solved with the standard set of moves.

symRotate :: Int -> [Int] -> [Int] Source

0 <= o < 6

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.

UDSlice

newtype UDSlicePermu Source

Position of the 4 UDSlice edges (carried-to)

Constructors

UDSlicePermu 

newtype UDSlice Source

Position of the 4 UDSlice edges up to permutation (carried-to). The vector is always sorted.

Constructors

UDSlice 

newtype UDSlicePermu2 Source

Position of the 4 UDSlice edges (replaced-by), assuming they are all in that slice already.

Constructors

UDSlicePermu2 

newtype UDEdgePermu2 Source

Position of the 8 other edges (replaced-by), assuming UDSlice edges are in that slice already.

Constructors

UDEdgePermu2 

numUDSliceEdges :: Int Source

numUDSliceEdges = 4

uDSlice :: Vector Int -> Maybe UDSlice Source

Wrap an increasing list of 4 elements in [0 .. 11].

uDSlicePermu2 :: Vector Int -> Maybe UDSlicePermu2 Source

Wrap a permutation of size 4.

uDEdgePermu2 :: Vector Int -> Maybe UDEdgePermu2 Source

Wrap a permutation of size 8.

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.

conjugateCornerOrien :: Cube -> CornerOrien -> CornerOrien Source

Expects UDSlice-stable symmetry.