Safe Haskell | Safe |
---|
BoardUntrusted
Description
This untrusted module implements the abstract type of shooting-phase boards. It also defines functions for describing boards as strings and lists of strings.
- data Board
- completeToBoard :: Complete -> Board
- allSunk :: Board -> Bool
- data ShotResult
- shoot :: Board -> Pos -> (Board, ShotResult)
- placingToStrs :: Placing -> [String]
- completeToStrs :: Complete -> [String]
- boardToStrs :: Board -> [String]
Shooting-phase Boards
data Board
Abstract type of shooting phase boards.
completeToBoard :: Complete -> Board
Turns a complete placing into a board on which no shooting has occurred.
data ShotResult
Result of shooting at a board.
shoot :: Board -> Pos -> (Board, ShotResult)
Shoot a given position of a board, yielding a new board and a shot result. The shot result indicates the result of the shooting.
String Descriptions of Boards
placingToStrs :: Placing -> [String]
Convert a placing to a list of strings describing it.
See MatrixUntrusted for the general format. Each cell of a ship is
presented as the ship's first letter, in lowercase; vacant cells
are presented as " "
.
completeToStrs :: Complete -> [String]
Convert a complete placing to a list of strings describing it --
works identically to placingToStrs
.
boardToStrs :: Board -> [String]
Convert a board to a list of strings describing it. See MatrixUntrusted for the general format.
- Each vacant cell (not part of a ship) that's not been shot at is
presented as
" "
. - Each vacant cell that's been shot at is labeled
"*"
. - Each cell of a ship is presented as the ship's first letter: in lowercase, if that cell's not been hit; and in uppercase, if that cell has been hit.