Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Describes a line's magnitude & direction, irrespective of its position; cf.
Move
.
Synopsis
- data Vector
- attackVectorsForKnight :: [Vector]
- attackVectorsForKing :: [Vector]
- attackVectorsForPawn :: LogicalColour -> [Vector]
- translate :: Vector -> Coordinates -> Coordinates
- maybeTranslate :: Vector -> Coordinates -> Maybe Coordinates
- toMaybeDirection :: Vector -> Maybe Direction
- measureDistance :: Coordinates -> Coordinates -> Vector
- isPawnAttack :: Vector -> LogicalColour -> Bool
- isKnightsMove :: Vector -> Bool
- isKingsMove :: Vector -> Bool
- matchesPawnDoubleAdvance :: Vector -> LogicalColour -> Bool
Data-types
The distance between two coordinates.
Instances
Eq Vector Source # | |
Show Vector Source # | |
NFData Vector Source # | |
Defined in BishBosh.Cartesian.Vector | |
Opposable Vector Source # | |
Defined in BishBosh.Cartesian.Vector getOpposite :: Vector -> Vector Source # | |
Orientated Vector Source # | |
Defined in BishBosh.Cartesian.Vector isVertical :: Vector -> Bool Source # isHorizontal :: Vector -> Bool Source # isParallel :: Vector -> Bool Source # isDiagonal :: Vector -> Bool Source # isStraight :: Vector -> Bool Source # |
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 :: Vector -> Coordinates -> Coordinates Source #
Translate the specified coordinates by the specified vector.
maybeTranslate :: Vector -> Coordinates -> 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. aKnight
's move).
Constructor
:: Coordinates | Source. |
-> Coordinates | Destination. |
-> Vector |
Construct a vector by measuring the signed distance between source-coordinates & destination.
Predicates
isPawnAttack :: Vector -> LogicalColour -> 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 :: Vector -> LogicalColour -> 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 aPawn
, or could be invalid.