bishbosh-0.0.0.2: Plays chess.

Safe HaskellNone
LanguageHaskell2010

BishBosh.Attribute.Direction

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
  • Describes a direction in two parts; the sense of change in the x coordinate & the sense of change in the y coordinate.
  • The IO-format uses a more concise & familiar format based on 8 points of the compass.
  • CAVEAT: this separation of direction into orthogonal components is driven by the typical use-case, but requires that one guards against accidental construction of a degenerate 9th direction which defines neither a change in the x coordinate nor the y coordinate.

Synopsis

Types

Type-synonyms

type NDirections = Int Source #

A number of directions.

type ByDirection = Array Direction Source #

A boxed array indexed by direction, of arbitrary elements.

Data-types

data Direction Source #

Define a direction by the sense of change to x & y coordinates.

Instances

Bounded Direction Source # 
Eq Direction Source # 
Ord Direction Source # 
Read Direction Source # 
Show Direction Source # 
Ix Direction Source # 
XmlPickler Direction Source # 

Methods

xpickle :: PU Direction #

Opposable Direction Source # 
Orientated Direction Source # 
ReflectableOnY Direction Source # 
ReflectableOnX Direction Source # 

Constants

nw :: Direction Source #

Constant direction.

n :: Direction Source #

Constant direction.

ne :: Direction Source #

Constant direction.

w :: Direction Source #

Constant direction.

e :: Direction Source #

Constant direction.

sw :: Direction Source #

Constant direction.

s :: Direction Source #

Constant direction.

se :: Direction Source #

Constant direction.

tag :: String Source #

Used to qualify XML.

nDistinctDirections :: NDirections Source #

The constant number of distinct directions.

parallels :: [Direction] Source #

The ordered directions in which a Rook can move.

diagonals :: [Direction] Source #

The ordered directions in which a Bishop can move.

range :: [Direction] Source #

The ordered directions in which royalty can move.

opposites :: [(Direction, Direction)] Source #

  • Returns a list of directions, each paired with its anti-parallel.
  • CAVEAT: each direction only appears once in the list, on an arbitrary side of a pair.

Functions

advanceDirection :: LogicalColour -> Ordering Source #

The y-direction in which a Pawn of the specified logical colour advances.

attackDirectionsForPawn :: LogicalColour -> [Direction] Source #

The directions in which a Pawn can attack.

listArrayByDirection :: IArray a e => [e] -> a Direction e Source #

Array-constructor.

Constructor

mkDirection Source #

Arguments

:: Ordering

The sense of the change in the x-coordinate.

-> Ordering

The sense of the change in the y-coordinate.

-> Direction 

Smart-constructor.

Predicates

areAligned :: Direction -> Direction -> Bool Source #

Whether the two directions specified, are either parallel or anti-parallel.