bishbosh-0.1.3.0: Plays chess.
Safe HaskellNone
LanguageHaskell2010

BishBosh.Component.Piece

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Defines the data-type which represents any chess-piece.
Synopsis

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

data Piece Source #

A Chess-piece has a logical colour & a rank.

Instances

Instances details
Bounded Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Eq Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

(==) :: Piece -> Piece -> Bool #

(/=) :: Piece -> Piece -> Bool #

Ord Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

compare :: Piece -> Piece -> Ordering #

(<) :: Piece -> Piece -> Bool #

(<=) :: Piece -> Piece -> Bool #

(>) :: Piece -> Piece -> Bool #

(>=) :: Piece -> Piece -> Bool #

max :: Piece -> Piece -> Piece #

min :: Piece -> Piece -> Piece #

Read Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Show Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

showsPrec :: Int -> Piece -> ShowS #

show :: Piece -> String #

showList :: [Piece] -> ShowS #

Ix Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

NFData Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

rnf :: Piece -> () #

XmlPickler Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

xpickle :: PU Piece #

ShowsEPD Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

showsEPD :: Piece -> ShowS Source #

ReadsEPD Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

FixedMembership Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

members :: [Piece] Source #

ShowsFEN Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Methods

showsFEN :: Piece -> ShowS Source #

ReadsFEN Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Opposable Piece Source # 
Instance details

Defined in BishBosh.Component.Piece

Constants

range :: [Piece] Source #

The constant ascending range of pieces.

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.

mkPiece :: LogicalColour -> Rank -> 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

canAttackAlong Source #

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 Pawn to advance, since that doesn't constitute an attack.

canMoveBetween Source #

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.

isBlack :: Piece -> Bool Source #

Whether the specified piece is Black.

isFriend :: Piece -> Piece -> Bool Source #

Whether the specified pieces have the same logical colour.

isPawn :: Piece -> Bool Source #

Whether the specified piece is a Pawn.

isKnight :: Piece -> Bool Source #

Whether the specified piece is a Knight.

isQueen :: Piece -> Bool Source #

Whether the specified piece is a Queen.

isKing :: Piece -> Bool Source #

Whether the specified piece is a King.

isPawnPromotion Source #

Arguments

:: Piece 
-> Coordinates

Destination.

-> Bool 

Whether a move qualifies for Pawn-promotion.