hs2048-0.1.0: A 2048 clone in Haskell.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hs2048

Description

Top-level module. Re-exports things from all other modules.

Synopsis

Documentation

data Direction Source #

Represents a direction that the game board can be moved in. The cardinal directions are used to avoid collisions with Left and Right.

Constructors

West 
South 
East 
North 

type Tile = Maybe Int Source #

Represents a tile on the game board. Can be empty (Nothing) or can have a value (Just n). By convention, a tile's value is always a power of 2.

type Vector = [Tile] Source #

Represents a row or column on the game board. By convention, a vector has 4 tiles.

directions :: [Direction] Source #

Returns all of the directions.

>>> directions
[West,South,East,North]

rank :: Tile -> Int Source #

Calculates the rank of a tile.

>>> rank Nothing
0
>>> rank (Just 2)
1
>>> rank (Just 2048)
11

emptyIndexes :: Vector -> [Int] Source #

Returns the indexes that don't contain tiles.

>>> emptyIndexes [Nothing, Just 2, Nothing, Nothing]
[0,2,3]