| Safe Haskell | Safe-Inferred | 
|---|---|
| Language | Haskell2010 | 
Hs2048.Board
Description
Types and functions for manipulating boards.
- type Board = [Vector]
- canMove :: Board -> Direction -> Bool
- canShift :: Board -> Bool
- empty :: Int -> Int -> Board
- emptyPoints :: Board -> [Point]
- move :: Board -> Direction -> Board
- parse :: String -> Board
- render :: Board -> String
- rotate :: Board -> Board
- rotateFrom :: Board -> Direction -> Board
- rotateTo :: Board -> Direction -> Board
- score :: Board -> Int
- set :: Board -> Tile -> Point -> Board
- shift :: Board -> Board
Documentation
canMove :: Board -> Direction -> Bool Source
Determines if the board can be moved in the given direction. See move.
>>>canMove [[Nothing, Just 2]] D.WestTrue
canShift :: Board -> Bool Source
Determines if the board can be shifted. See shift.
>>>canShift [[Nothing, Just 2]]True
Returns an empty board of the given size.
>>>empty 2 1[[Nothing,Nothing]]
emptyPoints :: Board -> [Point] Source
Returns the points that don't contain tiles.
>>>emptyPoints [[Nothing, Just 2]][(0,0)]
move :: Board -> Direction -> Board Source
Moves the board in the given direction.
>>>move [[Nothing, Just 2]] D.West[[Just 2,Nothing]]
parse :: String -> Board Source
Parses a string as a board. This is the inverse of render.
>>>parse "- 2\n4 -\n"[[Nothing,Just 2],[Just 4,Nothing]]
render :: Board -> String Source
Renders a board as a string. This is the inverse of parse.
>>>render [[Nothing, Just 2], [Just 4, Nothing]]"- 2\n4 -\n"
rotate :: Board -> Board Source
Rotate the board 90 degrees clockwise.
>>>rotate [[Nothing, Just 2], [Just 4, Nothing]][[Just 4,Nothing],[Nothing,Just 2]]
rotateFrom :: Board -> Direction -> Board Source
rotateTo :: Board -> Direction -> Board Source
Rotates the board so that the given direction is at the left. This is the
    inverse of rotateFrom
>>>rotateTo [[Nothing, Just 2], [Just 4, Nothing]] D.South[[Just 4,Nothing],[Nothing,Just 2]]
Calculates the score of a board.
>>>score [[Nothing, Just 2], [Just 4, Just 8]]20