| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
BishBosh.Component.Piece
Description
AUTHOR- Dr. Alistair Ward
DESCRIPTION- Defines the data-type which represents any chess-piece.
Synopsis
- type ArrayByPiece = Array Piece
- type LocatedPiece = (Coordinates, Piece)
- data Piece
- range :: [Piece]
- nPiecesPerSide :: NPieces
- epdCharacterSet :: EPD
- findAttackDestinations :: Piece -> Coordinates -> [Coordinates]
- showPieces :: String
- getAttackDirections :: Piece -> [Direction]
- promote :: Rank -> Piece -> Piece
- mkBishop :: LogicalColour -> Piece
- mkKing :: LogicalColour -> Piece
- mkKnight :: LogicalColour -> Piece
- mkPawn :: LogicalColour -> Piece
- mkPiece :: LogicalColour -> Rank -> Piece
- mkQueen :: LogicalColour -> Piece
- mkRook :: LogicalColour -> Piece
- listArrayByPiece :: IArray a e => [e] -> a Piece e
- canAttackAlong :: Coordinates -> Coordinates -> Piece -> Bool
- canMoveBetween :: Piece -> Coordinates -> Coordinates -> Bool
- isBlack :: Piece -> Bool
- isFriend :: Piece -> Piece -> Bool
- isPawn :: Piece -> Bool
- isKnight :: Piece -> Bool
- isQueen :: Piece -> Bool
- isKing :: Piece -> Bool
- isPawnPromotion :: Piece -> Coordinates -> Bool
Types
Type-synonyms
type ArrayByPiece = Array Piece Source #
A boxed array indexed by piece, of unspecified elements.
type LocatedPiece = (Coordinates, Piece) Source #
A piece at specific coordinates.
Data-types
A Chess-piece has a logical colour & a rank.
Instances
| Bounded Piece Source # | |
| Eq Piece Source # | |
| Ord Piece Source # | |
| Read Piece Source # | |
| Show Piece Source # | |
| Ix Piece Source # | |
| NFData Piece Source # | |
Defined in BishBosh.Component.Piece | |
| XmlPickler Piece Source # | |
Defined in BishBosh.Component.Piece | |
| ShowsEPD Piece Source # | |
| ReadsEPD Piece Source # | |
| FixedMembership Piece Source # | |
Defined in BishBosh.Component.Piece | |
| ShowsFEN Piece Source # | |
| ReadsFEN Piece Source # | |
| Opposable Piece Source # | |
Defined in BishBosh.Component.Piece Methods getOpposite :: Piece -> Piece Source # | |
Constants
nPiecesPerSide :: NPieces Source #
The constant number of pieces per side at the conventional opening position; some of which are duplicates.
epdCharacterSet :: EPD Source #
The constant set of permissible characters in an EPD.
Functions
findAttackDestinations Source #
Arguments
| :: Piece | |
| -> Coordinates | The source from which the attack originates. |
| -> [Coordinates] | The destinations which can be attacked. |
Find the destinations which the specified piece can attack from the specified position.
showPieces :: String Source #
Returns a constant string containing all possible pieces.
Accessors
getAttackDirections :: Piece -> [Direction] Source #
- Get the constant directions of the straight lines along which the specified piece can attack.
- CAVEAT: not defined for a
Knight.
Mutators
promote :: Rank -> Piece -> Piece Source #
Changes the specified piece to the specified rank leaving its logical colour unchanged.
Constructors
mkBishop :: LogicalColour -> Piece Source #
Constructor.
mkKing :: LogicalColour -> Piece Source #
Constructor.
mkKnight :: LogicalColour -> Piece Source #
Constructor.
mkPawn :: LogicalColour -> Piece Source #
Constructor.
mkQueen :: LogicalColour -> Piece Source #
Constructor.
mkRook :: LogicalColour -> Piece Source #
Constructor.
listArrayByPiece :: IArray a e => [e] -> a Piece e Source #
Array-constructor.
Predicates
Arguments
| :: Coordinates | Source (attacker's location). |
| -> Coordinates | Destination (victim's location). |
| -> Piece | Attacker. |
| -> Bool |
- Whether a piece at the specified coordinates could attack the target at the specified coordinates.
- N.B.: doesn't require that the specified piece actually exists at the target-location, nor that the victim's logical colour is opposite from the attacker's.
- N.B.: can't detect any blocking pieces which might invalidate the attack.
- CAVEAT: it won't confirm the ability of a
Pawnto advance, since that doesn't constitute an attack.
Arguments
| :: Piece | |
| -> Coordinates | Source. |
| -> Coordinates | Destination. |
| -> Bool |
- Whether the specified piece can move between the specified coordinates.
- N.B.: can't detect any blocking pieces.
isFriend :: Piece -> Piece -> Bool Source #
Whether the specified pieces have the same logical colour.
Arguments
| :: Piece | |
| -> Coordinates | Destination. |
| -> Bool |
Whether a move qualifies for Pawn-promotion.