ContentsIndex
Board
Description
The Board module represents the game board and provides types for board elements.
Synopsis
data Cell
= Plain
| Water
| Wall
| Base
data Board = Board (Array Point Cell)
readBoard :: String -> Board
parseBoardLns :: [String] -> (Board, [String])
drawBoard :: Board -> String
showBoard :: Board -> String
boardSize :: Board -> Point
Documentation
data Cell
A cell on the board may be plain, water, a wall, or a base
Constructors
Plain
Water
Wall
Base
data Board
The game board is an NxM array of cells
Constructors
Board (Array Point Cell)
readBoard :: String -> Board
Reads a string representing a board and returns a Board
parseBoardLns
:: [String]input lines
-> (Board, [String])output: board and unused lines
Reads a series of lines, creates a Board from the leading lines, and returns the Board and any unused lines
drawBoard :: Board -> String
Renders a boards as a string.
showBoard :: Board -> String
Shows a Board. Note that (readBoard . showBoard) is an identity function for values of type Board. Also note that the board represention that showBoard uses is upside down when viewed. This is according to the challenge task specification. Use drawBoard for a visually correct rendering.
boardSize :: Board -> Point
Returns the size of the game board.
Produced by Haddock version 0.4