chessica-0.1.0.0: A Library for Chess Game Logic
Copyright(c) Michael Szvetits 2023
LicenseBSD-3-Clause (see the file LICENSE)
Maintainertypedbyte@qualified.name
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageGHC2021

Chess.Board

Description

Types and functions to create, manipulate and query chess boards.

Synopsis

Representing Boards

data Board Source #

Represents a chess board.

empty :: Board Source #

An empty chess board, i.e. a board with no placed pieces.

Manipulating Boards

place Source #

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.

replace Source #

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.

remove Source #

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

lookup Source #

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.

isOccupied Source #

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