bishbosh-0.0.0.3: Plays chess.

Safe HaskellNone
LanguageHaskell2010

BishBosh.State.CoordinatesByRankByLogicalColour

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION

Synopsis

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 .

Functions

countPawnsByFileByLogicalColour :: Ord x => CoordinatesByRankByLogicalColour x y -> NPiecesByFileByLogicalColour x Source #

  • Counts the number of Pawns 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.

findPieces Source #

Arguments

:: (Piece -> Bool)

Predicate.

-> CoordinatesByRankByLogicalColour x y 
-> [LocatedPiece x y] 

Locates those pieces which satisfy the specified predicate.

findPiecesOfColour Source #

Arguments

:: LogicalColour

The logical colour of the pieces to find.

-> CoordinatesByRankByLogicalColour x y 
-> [LocatedPiece x y] 

Locate all pieces of the specified logical colour.

findProximateKnights Source #

Arguments

:: (Enum x, Enum y, Ord x, Ord y) 
=> LogicalColour

The logical colour of the Knight for which to search.

-> Coordinates x y

The destination to which the Knight is required to be capable of jumping.

-> CoordinatesByRankByLogicalColour x y 
-> [Coordinates x y] 
  • Find any Knights 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

getKingsCoordinates Source #

Arguments

:: LogicalColour

The logical colour of the King to find.

-> CoordinatesByRankByLogicalColour x y 
-> Coordinates x y 

Get the coordinates of the King of the specified logical colour.

elems :: CoordinatesByRankByLogicalColour x y -> [Coordinates x y] Source #

Access the coordinate-lists.

Constructors,

Mutators

movePiece Source #

Arguments

:: (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 Pawn, or the rank of any piece taken.

-> 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.