Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- A view of the board from the perspective of its pieces.
- cf. the square-centric model of the board defined in BishBosh.State.MaybePieceByCoordinates.
Synopsis
- type NPiecesByFileByLogicalColour x = ByLogicalColour (Map x NPieces)
- type CoordinatesByLogicalColour x y = ByLogicalColour [Coordinates x y]
- data CoordinatesByRankByLogicalColour x y
- countPawnsByFileByLogicalColour :: Ord x => CoordinatesByRankByLogicalColour x y -> NPiecesByFileByLogicalColour x
- findPassedPawnCoordinatesByLogicalColour :: (Enum x, Ord x, Ord y) => CoordinatesByRankByLogicalColour x y -> CoordinatesByLogicalColour x y
- findPieces :: (Piece -> Bool) -> CoordinatesByRankByLogicalColour x y -> [LocatedPiece x y]
- findPiecesOfColour :: LogicalColour -> CoordinatesByRankByLogicalColour x y -> [LocatedPiece x y]
- findProximateKnights :: (Enum x, Enum y, Ord x, Ord y) => LogicalColour -> Coordinates x y -> CoordinatesByRankByLogicalColour x y -> [Coordinates x y]
- sumPieceSquareValueByLogicalColour :: Num pieceSquareValue => FindPieceSquareValue x y pieceSquareValue -> CoordinatesByRankByLogicalColour x y -> [pieceSquareValue]
- assocs :: CoordinatesByRankByLogicalColour x y -> [(Piece, [Coordinates x y])]
- getKingsCoordinates :: LogicalColour -> CoordinatesByRankByLogicalColour x y -> Coordinates x y
- dereference :: LogicalColour -> Rank -> CoordinatesByRankByLogicalColour x y -> [Coordinates x y]
- elems :: CoordinatesByRankByLogicalColour x y -> [Coordinates x y]
- fromMaybePieceByCoordinates :: (Enum x, Enum y, Ord x, Ord y) => MaybePieceByCoordinates x y -> CoordinatesByRankByLogicalColour x y
- movePiece :: (Eq x, Eq y) => Move x y -> Piece -> Maybe Rank -> Either (Coordinates x y) (Maybe Rank) -> Transformation x y
- sortCoordinates :: (Ord x, Ord y) => Transformation x y
Types
Type-synonyms
type NPiecesByFileByLogicalColour x = ByLogicalColour (Map x NPieces) Source #
The number of pieces in each file, for each logical colour.
type CoordinatesByLogicalColour x y = ByLogicalColour [Coordinates x y] Source #
A list of coordinates for each logical colour.
Data-types
data CoordinatesByRankByLogicalColour x y Source #
- This structure allows one to determine the set of coordinates where a type of piece is located.
- CAVEAT: the list of coordinates is unordered, so test for equality using
deconstruct . sortCoordinates
.
Instances
(Enum x, Enum y, Ord x, Ord y) => Hashable2D CoordinatesByRankByLogicalColour x y Source # | |
Defined in BishBosh.State.CoordinatesByRankByLogicalColour listRandoms2D :: CoordinatesByRankByLogicalColour x y -> Zobrist x y positionHash -> [positionHash] Source # | |
(NFData x, NFData y) => NFData (CoordinatesByRankByLogicalColour x y) Source # | |
Defined in BishBosh.State.CoordinatesByRankByLogicalColour rnf :: CoordinatesByRankByLogicalColour x y -> () # | |
(Enum x, Enum y) => Censor (CoordinatesByRankByLogicalColour x y) Source # | |
Defined in BishBosh.State.CoordinatesByRankByLogicalColour countPiecesByLogicalColour :: CoordinatesByRankByLogicalColour x y -> (NPieces, NPieces) Source # countPieces :: CoordinatesByRankByLogicalColour x y -> NPieces Source # countPieceDifferenceByRank :: CoordinatesByRankByLogicalColour x y -> NPiecesByRank Source # hasInsufficientMaterial :: CoordinatesByRankByLogicalColour x y -> Bool Source # hasBothKings :: CoordinatesByRankByLogicalColour x y -> Bool Source # |
Functions
countPawnsByFileByLogicalColour :: Ord x => CoordinatesByRankByLogicalColour x y -> NPiecesByFileByLogicalColour x Source #
- Counts the number of
Pawn
s of each logical colour with similar x-coordinates; their y-coordinate is irrelevant. - N.B.: files lacking any
Pawn
, don't feature in the results.
findPassedPawnCoordinatesByLogicalColour :: (Enum x, Ord x, Ord y) => CoordinatesByRankByLogicalColour x y -> CoordinatesByLogicalColour x y Source #
For each logical colour, find the coordinates of any passed Pawn
s (https://en.wikipedia.org/wiki/Passed_pawn).
:: (Piece -> Bool) | Predicate. |
-> CoordinatesByRankByLogicalColour x y | |
-> [LocatedPiece x y] |
Locates those pieces which satisfy the specified predicate.
:: LogicalColour | The logical colour of the pieces to find. |
-> CoordinatesByRankByLogicalColour x y | |
-> [LocatedPiece x y] |
Locate all pieces of the specified logical colour.
:: (Enum x, Enum y, Ord x, Ord y) | |
=> LogicalColour | The logical colour of the |
-> Coordinates x y | The destination to which the |
-> CoordinatesByRankByLogicalColour x y | |
-> [Coordinates x y] |
- Find any
Knight
s of the specified logical colour, in attack-range around the specified coordinates. - CAVEAT: nothing is said about whether any piece at the specified coordinates belongs to the opponent, as one might expect.
sumPieceSquareValueByLogicalColour :: Num pieceSquareValue => FindPieceSquareValue x y pieceSquareValue -> CoordinatesByRankByLogicalColour x y -> [pieceSquareValue] Source #
Calculate the total value of the coordinates occupied by the pieces of either side.
assocs :: CoordinatesByRankByLogicalColour x y -> [(Piece, [Coordinates x y])] Source #
Build an association-list.
Accessors
:: LogicalColour | The logical colour of the |
-> CoordinatesByRankByLogicalColour x y | |
-> Coordinates x y |
Get the coordinates of the King
of the specified logical colour.
dereference :: LogicalColour -> Rank -> CoordinatesByRankByLogicalColour x y -> [Coordinates x y] Source #
Dereference the array.
elems :: CoordinatesByRankByLogicalColour x y -> [Coordinates x y] Source #
Access the coordinate-lists.
Constructors,
fromMaybePieceByCoordinates :: (Enum x, Enum y, Ord x, Ord y) => MaybePieceByCoordinates x y -> CoordinatesByRankByLogicalColour x y Source #
Constructor.
Mutators
:: (Eq x, Eq y) | |
=> Move x y | |
-> Piece | The piece which moved. |
-> Maybe Rank | The (possibly promoted) rank to place at the destination. |
-> Either (Coordinates x y) (Maybe Rank) | Either the destination of any passed |
-> Transformation x y |
Adjust the array to reflect a new move.
sortCoordinates :: (Ord x, Ord y) => Transformation x y Source #
Independently sort each list of coordinates.