Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Side a = Side {
- _topLeft :: a
- _topCenter :: a
- _topRight :: a
- _middleLeft :: a
- _middleCenter :: a
- _middleRight :: a
- _bottomLeft :: a
- _bottomCenter :: a
- _bottomRight :: a
- topLeft :: forall a. Lens' (Side a) a
- topCenter :: forall a. Lens' (Side a) a
- topRight :: forall a. Lens' (Side a) a
- middleLeft :: forall a. Lens' (Side a) a
- middleCenter :: forall a. Lens' (Side a) a
- middleRight :: forall a. Lens' (Side a) a
- bottomLeft :: forall a. Lens' (Side a) a
- bottomCenter :: forall a. Lens' (Side a) a
- bottomRight :: forall a. Lens' (Side a) a
- rotateSideCW :: Aut (Side a)
- rotateSideCCW :: Aut (Side a)
- data Cube a = Cube {
- _frontSide :: a
- _backSide :: a
- _leftSide :: a
- _rightSide :: a
- _upSide :: a
- _downSide :: a
- frontSide :: forall a. Lens' (Cube a) a
- backSide :: forall a. Lens' (Cube a) a
- leftSide :: forall a. Lens' (Cube a) a
- rightSide :: forall a. Lens' (Cube a) a
- upSide :: forall a. Lens' (Cube a) a
- downSide :: forall a. Lens' (Cube a) a
- newtype RubiksCube a = RubiksCube {}
- cube :: forall a a. Iso (RubiksCube a) (RubiksCube a) (Cube (Side a)) (Cube (Side a))
- data Vec3 a = Vec3 a a a
- topRow :: Lens' (Side a) (Vec3 a)
- middleRow :: Lens' (Side a) (Vec3 a)
- bottomRow :: Lens' (Side a) (Vec3 a)
- leftCol :: Lens' (Side a) (Vec3 a)
- centerCol :: Lens' (Side a) (Vec3 a)
- rightCol :: Lens' (Side a) (Vec3 a)
- topLayerFacets :: Traversal' (RubiksCube a) a
- middleLayerFacets :: Traversal' (RubiksCube a) a
- bottomLayerFacets :: Traversal' (RubiksCube a) a
- centerFacets :: Traversal' (RubiksCube a) a
- cornerFacets :: Traversal' (RubiksCube a) a
- edgeFacets :: Traversal' (RubiksCube a) a
- type Aut a = Iso' a a
- rotateLeft :: Aut (RubiksCube a)
- rotateRight :: Aut (RubiksCube a)
- rotateDown :: Aut (RubiksCube a)
- rotateUp :: Aut (RubiksCube a)
- rotateCW :: Aut (RubiksCube a)
- rotateCCW :: Aut (RubiksCube a)
- move :: Move -> Aut (RubiksCube a)
- doMoves :: [Move] -> Aut (RubiksCube a)
- undoMoves :: [Move] -> Aut (RubiksCube a)
Constructing cubes
One side of the Rubik's Cube with 3*3 facets.
Side | |
|
middleLeft :: forall a. Lens' (Side a) a Source
middleCenter :: forall a. Lens' (Side a) a Source
middleRight :: forall a. Lens' (Side a) a Source
bottomLeft :: forall a. Lens' (Side a) a Source
bottomCenter :: forall a. Lens' (Side a) a Source
bottomRight :: forall a. Lens' (Side a) a Source
rotateSideCW :: Aut (Side a) Source
Rotate the side clockwise.
rotateSideCCW :: Aut (Side a) Source
Rotate the side counter-clockwise.
A cube with six sides.
+---+ | u | +---+---+---+---+ | l | f | r | b | +---+---+---+---+ | d | +---+
Cube | |
|
newtype RubiksCube a Source
A normal Rubik's cube with 6 sides with 9 facets each.
Functor RubiksCube Source | |
Applicative RubiksCube Source | |
Eq a => Eq (RubiksCube a) Source | |
Show a => Show (RubiksCube a) Source |
cube :: forall a a. Iso (RubiksCube a) (RubiksCube a) (Cube (Side a)) (Cube (Side a)) Source
Selecting rows and columns
A list of fixed length 3.
Vec3 a a a |
Traversing facets
By layer
topLayerFacets :: Traversal' (RubiksCube a) a Source
The 21=4*3+9 facets in the top layer.
middleLayerFacets :: Traversal' (RubiksCube a) a Source
The 12=4*3 facets in the middle layer.
bottomLayerFacets :: Traversal' (RubiksCube a) a Source
The 21=4*3+9 facets in the bottom layer.
By position
centerFacets :: Traversal' (RubiksCube a) a Source
The six facets that are the center of their side.
cornerFacets :: Traversal' (RubiksCube a) a Source
The 24=6*4=8*3 corner facets.
edgeFacets :: Traversal' (RubiksCube a) a Source
The 24=6*4=12*2 edge facets.
Rotating the whole cube
rotateLeft :: Aut (RubiksCube a) Source
Rotate the whole Rubik's Cube such that the front side becomes the new left side and the top and bottom sides stay fixed.
rotateRight :: Aut (RubiksCube a) Source
Rotate the whole Rubik's Cube such that the front side becomes the new right side and the top and bottom sides stay fixed.
rotateDown :: Aut (RubiksCube a) Source
Rotate the whole Rubik's Cube such that the front side becomes the new bottom side and the left and right sides stay fixed.
rotateUp :: Aut (RubiksCube a) Source
Rotate the whole Rubik's Cube such that the front side becomes the new top side and the left and right sides stay fixed.
rotateCW :: Aut (RubiksCube a) Source
Rotate the whole Rubik's Cube such that the top side becomes the new right side and the front and back sides stay fixed.
rotateCCW :: Aut (RubiksCube a) Source
Rotate the whole Rubik's Cube such that the top side becomes the new left side and the front and back sides stay fixed.
Moving layers of the cube
move :: Move -> Aut (RubiksCube a) Source
Perform a move.
doMoves :: [Move] -> Aut (RubiksCube a) Source
Perform a list of moves.
undoMoves :: [Move] -> Aut (RubiksCube a) Source
Undo the actions of a list of moves.