haskellscrabble-1.4.3: A scrabble library capturing the core game logic of scrabble.

Safe HaskellSafe
LanguageHaskell98

Wordify.Rules.Board

Synopsis

Documentation

data Board Source

Instances

emptyBoard :: Board Source

Creates an empty board.

allSquares :: Board -> [(Pos, Square)] Source

Returns all the squares on the board, ordered by column then row.

placeTile :: Board -> Tile -> Pos -> Maybe Board Source

Places a tile on a square and yields the new board, if the target square is empty. Otherwise yields Nothing.

occupiedSquareAt :: Board -> Pos -> Maybe Square Source

Returns the square at a given position if it is occupied by a tile. Otherwise returns Nothing.

emptySquaresFrom :: Board -> Pos -> Int -> Direction -> [Pos] Source

Finds the empty square positions horizontally or vertically from a given position, skipping any squares that are occupied by a tile

lettersAbove :: Board -> Pos -> Seq (Pos, Square) Source

All letters immediately above a given square until a non-occupied square

lettersBelow :: Board -> Pos -> Seq (Pos, Square) Source

All letters immediately below a given square until a non-occupied square

lettersLeft :: Board -> Pos -> Seq (Pos, Square) Source

All letters immediately left of a given square until a non-occupied square

lettersRight :: Board -> Pos -> Seq (Pos, Square) Source

All letters immediately right of a given square until a non-occupied square

unoccupiedSquareAt :: Board -> Pos -> Maybe Square Source

Returns the square at a given position if it is not occupied by a tile. Otherwise returns Nothing.

prettyPrint :: Board -> String Source

Pretty prints a board to a human readable string representation. Helpful for development.