| Copyright | (c) Michael Szvetits 2023 |
|---|---|
| License | BSD-3-Clause (see the file LICENSE) |
| Maintainer | typedbyte@qualified.name |
| Stability | stable |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Chess.Board
Description
Types and functions to create, manipulate and query chess boards.
Synopsis
- data Board
- empty :: Board
- place :: Position -> Piece t -> Board -> Either ChessException Board
- replace :: Position -> Piece t -> Board -> Board
- remove :: PlacedPiece t -> Board -> Either ChessException Board
- lookup :: Alternative f => Position -> Board -> f (Some PlacedPiece)
- isOccupied :: Position -> Board -> Bool
- pieces :: Board -> [Some PlacedPiece]
- piecesOf :: Color -> Board -> [Some PlacedPiece]
- module Chess.Board.Direction
- module Chess.Board.PlacedPiece
- module Chess.Board.Position
Representing Boards
Manipulating Boards
Arguments
| :: Position | The position of the newly introduced chess piece. |
| -> Piece t | The newly introduced chess piece. |
| -> Board | The original chess board. |
| -> Either ChessException Board | The new chess board, if the specified position has not been occupied. |
Introduces a new chess piece to the chess board at a specific position.
Arguments
| :: Position | The position of the newly introduced chess piece. |
| -> Piece t | The newly introduced chess piece. |
| -> Board | The original chess board. |
| -> Board | The new chess board. If the specified position has been occupied, the piece is replaced. |
Introduces a new chess piece to the chess board at a specific position.
Arguments
| :: PlacedPiece t | The position of the chess piece to be removed. |
| -> Board | The original chess board. |
| -> Either ChessException Board | The new chess board, if the specified position was indeed occupied by the piece. |
Removes a chess piece from the chess board at a given position.
Querying Boards
Arguments
| :: Alternative f | |
| => Position | The position to look for a chess piece. |
| -> Board | The board used for the lookup. |
| -> f (Some PlacedPiece) | The chess piece, if the specified position was indeed occupied by it. |
Gets a chess piece at a specific position of the chess board.
Arguments
| :: Position | The position to be checked for occupation. |
| -> Board | The board whose position is checked for occupation. |
| -> Bool | True if the specified position is occupied, or else false. |
Checks if a specified position of the chess board is occupied by a chess piece.
pieces :: Board -> [Some PlacedPiece] Source #
Gets all chess pieces that are currently on the chess board.
piecesOf :: Color -> Board -> [Some PlacedPiece] Source #
Gets all chess pieces of a given color that are currently on the chess board.
Re-exports
module Chess.Board.Direction
module Chess.Board.PlacedPiece
module Chess.Board.Position