Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Permits a board to be mutated.
Synopsis
- class Mutator mutator where
- defineCoordinates :: Maybe Piece -> Coordinates -> mutator -> mutator
- movePiece :: Move -> Piece -> Maybe Rank -> Either Coordinates (Maybe Rank) -> mutator -> mutator
- placePiece :: Mutator mutator => Piece -> Coordinates -> mutator -> mutator
- placeFirstPiece :: (Empty mutator, Mutator mutator) => Piece -> Coordinates -> mutator
- placeAllPieces :: (Empty mutator, Mutator mutator) => [(Piece, Coordinates)] -> mutator
- removePiece :: Mutator mutator => Coordinates -> mutator -> mutator
Type-classes
class Mutator mutator where Source #
- An interface which may be implemented by data which can mutate the board.
- CAVEAT: doesn't validate requests, so
King
s can be placed in check &Pawn
s can be placed behind their starting rank or unpromoted on their last rank.
:: Maybe Piece | The optional piece to place (or remove if |
-> Coordinates | The coordinates to define. |
-> mutator | |
-> mutator |
- Defines the specified coordinates, by either placing or removing a piece.
- CAVEAT: this function should only be used to construct custom scenarios, since pieces don't normally spring into existence.
- CAVEAT: this function isn't called during normal play.
:: Move | The source & destination coordinates. |
-> Piece | The piece which moved. |
-> Maybe Rank | The (possibly promoted) rank to place at the destination. |
-> Either Coordinates (Maybe Rank) | Either the coordinates of any |
-> mutator | |
-> mutator |
Move the specified piece, accounting for promotions & casualties.
Instances
Functions
Mutators
placePiece :: Mutator mutator => Piece -> Coordinates -> mutator -> mutator Source #
- Place a piece at the specified coordinates.
- CAVEAT: any piece previously at the specified coordinates will be obliterated.
placeFirstPiece :: (Empty mutator, Mutator mutator) => Piece -> Coordinates -> mutator Source #
Place the first piece.
placeAllPieces :: (Empty mutator, Mutator mutator) => [(Piece, Coordinates)] -> mutator Source #
Place pieces from scratch.
removePiece :: Mutator mutator => Coordinates -> mutator -> mutator Source #
Remove a piece from the board.