bishbosh-0.1.2.0: Plays chess.
Safe HaskellNone
LanguageHaskell2010

BishBosh.Cartesian.Vector

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Describes a line's magnitude & direction, irrespective of its position; cf. Move.
Synopsis

Data-types

data Vector Source #

The distance between two coordinates.

Instances

Instances details
Eq Vector Source # 
Instance details

Defined in BishBosh.Cartesian.Vector

Methods

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

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

Show Vector Source # 
Instance details

Defined in BishBosh.Cartesian.Vector

NFData Vector Source # 
Instance details

Defined in BishBosh.Cartesian.Vector

Methods

rnf :: Vector -> () #

Opposable Vector Source # 
Instance details

Defined in BishBosh.Cartesian.Vector

Orientated Vector Source # 
Instance details

Defined in BishBosh.Cartesian.Vector

Constants

attackVectorsForKnight :: [Vector] Source #

The constant list of attack-vectors for a Knight.

attackVectorsForKing :: [Vector] Source #

The constant list of attack-vectors for a King.

Functions

attackVectorsForPawn :: LogicalColour -> [Vector] Source #

  • The list of attack-vectors for a Pawn.
  • N.B.: the Pawn's ability to advance without taking, isn't dealt with here.

translate :: Coordinates -> Vector -> Coordinates Source #

Translate the specified coordinates by the specified vector.

maybeTranslate :: Coordinates -> Vector -> Maybe Coordinates Source #

Where legal, translate the specified coordinates by the specified vector.

toMaybeDirection :: Vector -> Maybe Direction Source #

  • Where possible, converts the specified vector into a direction.
  • Nothing is returned for those vectors which don't translate into a legal direction (e.g. a Knight's move).

Constructor

measureDistance Source #

Arguments

:: Coordinates

Source.

-> Coordinates

Destination.

-> Vector 

Construct a vector by measuring the signed distance between source-coordinates & destination.

Predicates

isDiagonal :: Vector -> Bool Source #

Whether the specified vector is at 45 degrees to an edge of the board, i.e. any move a Bishop could make.

isParallel :: Vector -> Bool Source #

Whether the specified vector is parallel to an edge of the board, i.e. any move a Rook could make.

isStraight :: Vector -> Bool Source #

Whether the specified vector is either parallel or at 45 degrees to an edge of the board, i.e. any move a Queen could make.

isPawnAttack :: LogicalColour -> Vector -> Bool Source #

  • Whether the specified vector might represent an attack (rather than an advance) by a Pawn.
  • CAVEAT: if the move started at the first rank, then it can't be a Pawn, but that's beyond the scope of this module (since a Vector doesn't define absolute coordinates).

isKnightsMove :: Vector -> Bool Source #

Whether the specified vector represents a move a Knight could make.

isKingsMove :: Vector -> Bool Source #

Whether the specified vector represents a move a King could make.

matchesPawnDoubleAdvance :: LogicalColour -> Vector -> Bool Source #

  • Whether the specified vector matches a Pawn's initial double-advance move.
  • CAVEAT: passing this test doesn't guarantee that it is a Pawn's double-advance move, since the move may not relate to a Pawn, or could be invalid.