bishbosh-0.0.0.5: Plays chess.

BishBosh.Cartesian.Vector

Description

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

# Types

## Type-synonyms

A suitable concrete type.

## Data-types

data Vector distance Source #

The distance between two coordinates.

Instances
 Eq distance => Eq (Vector distance) Source # Instance detailsDefined in BishBosh.Cartesian.Vector Methods(==) :: Vector distance -> Vector distance -> Bool #(/=) :: Vector distance -> Vector distance -> Bool # Show distance => Show (Vector distance) Source # Instance detailsDefined in BishBosh.Cartesian.Vector MethodsshowsPrec :: Int -> Vector distance -> ShowS #show :: Vector distance -> String #showList :: [Vector distance] -> ShowS # Num distance => Opposable (Vector distance) Source # Instance detailsDefined in BishBosh.Cartesian.Vector MethodsgetOpposite :: Vector distance -> Vector distance Source # (Eq distance, Num distance) => Orientated (Vector distance) Source # Instance detailsDefined in BishBosh.Cartesian.Vector MethodsisDiagonal :: Vector distance -> Bool Source #isParallel :: Vector distance -> Bool Source #isStraight :: Vector distance -> Bool Source #

# Constants

attackVectorsForKnight :: Num distance => [Vector distance] Source #

The constant list of attack-vectors for a Knight.

attackVectorsForKing :: (Eq distance, Num distance) => [Vector distance] Source #

The constant list of attack-vectors for a King.

# Functions

attackVectorsForPawn :: Num distance => LogicalColour -> [Vector distance] 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 :: (Enum x, Enum y, Integral distance, Ord x, Ord y) => Coordinates x y -> Vector distance -> Coordinates x y Source #

Translate the specified coordinates by the specified vector.

maybeTranslate :: (Enum x, Enum y, Integral distance, Ord x, Ord y) => Coordinates x y -> Vector distance -> Maybe (Coordinates x y) Source #

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

toMaybeDirection :: (Num distance, Ord distance) => Vector distance -> 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

mkVector :: (Num distance, Ord distance) => distance -> distance -> Vector distance Source #

Smart constructor.

Arguments

 :: (Enum x, Enum y, Num distance, Ord distance) => Coordinates x y Source. -> Coordinates x y Destination. -> Vector distance

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

## Predicates

isDiagonal :: (Eq distance, Num distance) => Vector distance -> 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 :: (Eq distance, Num distance) => Vector distance -> Bool Source #

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

isStraight :: (Eq distance, Num distance) => Vector distance -> 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 :: (Eq distance, Num distance) => LogicalColour -> Vector distance -> 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 unknown.

isKnightsMove :: (Eq distance, Num distance) => Vector distance -> Bool Source #

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

isKingsMove :: (Num distance, Ord distance) => Vector distance -> Bool Source #

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

matchesPawnDoubleAdvance :: (Eq distance, Num distance) => LogicalColour -> Vector distance -> 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.