cx-0.1.0.0: Chess eXperiment

Safe HaskellNone
LanguageHaskell2010

Game.Chess.Types

Contents

Synopsis

Documentation

data Board #

Board represents the current state of the game at any given moment.

Instances

Eq Board # 

Methods

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

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

Ord Board # 

Methods

compare :: Board -> Board -> Ordering #

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

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

(>) :: Board -> Board -> Bool #

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

max :: Board -> Board -> Board #

min :: Board -> Board -> Board #

Show Board # 

Methods

showsPrec :: Int -> Board -> ShowS #

show :: Board -> String #

showList :: [Board] -> ShowS #

data MovingVector a #

There are certain cases where a moving vector for a piece is more than just a 2-tuple position vector. The most obvious case is the set of moving vectors for Pawns. Pawns capture diagonally, so we need a way to denote "this vector only applies when capturing."

Constructors

NormalMove a a 
PawnCaptureMove a a 

data Piece #

There are 6 different kinds of chess pieces.

Constructors

Pawn 
Knight 
Bishop 
King 
Queen 
Rook 

Instances

Enum Piece # 
Eq Piece # 

Methods

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

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

Ord 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 #

Show Piece # 

Methods

showsPrec :: Int -> Piece -> ShowS #

show :: Piece -> String #

showList :: [Piece] -> ShowS #

data Color #

Each piece is White or Black.

Constructors

White 
Black 

Instances

Enum Color # 
Eq Color # 

Methods

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

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

Ord Color # 

Methods

compare :: Color -> Color -> Ordering #

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

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

(>) :: Color -> Color -> Bool #

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

max :: Color -> Color -> Color #

min :: Color -> Color -> Color #

Show Color # 

Methods

showsPrec :: Int -> Color -> ShowS #

show :: Color -> String #

showList :: [Color] -> ShowS #

data Cell #

A Cell represents a square on the board. It is either Empty or a Cell containing a particular Piece which belongs to a Color.

This is isomorphic to Maybe (Piece, Color).

Constructors

Empty 
Cell 

Fields

Instances

Eq Cell # 

Methods

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

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

Ord Cell # 

Methods

compare :: Cell -> Cell -> Ordering #

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

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

(>) :: Cell -> Cell -> Bool #

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

max :: Cell -> Cell -> Cell #

min :: Cell -> Cell -> Cell #

Show Cell # 

Methods

showsPrec :: Int -> Cell -> ShowS #

show :: Cell -> String #

showList :: [Cell] -> ShowS #

data File #

Describes a File on the board.

Instances

Eq File # 

Methods

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

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

Ord File # 

Methods

compare :: File -> File -> Ordering #

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

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

(>) :: File -> File -> Bool #

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

max :: File -> File -> File #

min :: File -> File -> File #

Show File # 

Methods

showsPrec :: Int -> File -> ShowS #

show :: File -> String #

showList :: [File] -> ShowS #

data Rank #

Describes a Rank on the board.

Instances

Eq Rank # 

Methods

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

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

Ord Rank # 

Methods

compare :: Rank -> Rank -> Ordering #

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

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

(>) :: Rank -> Rank -> Bool #

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

max :: Rank -> Rank -> Rank #

min :: Rank -> Rank -> Rank #

Show Rank # 

Methods

showsPrec :: Int -> Rank -> ShowS #

show :: Rank -> String #

showList :: [Rank] -> ShowS #

pattern PRank :: Int -> Rank #

pattern PFile :: Int -> File #

data Position #

Position allows us to discuss a position on the board, given its appropriate File and Rank. We define an Enum instance for easily converting to and from the 0x88 Vector position of a 'Board'\'s board representation.

Constructors

Position !File !Rank 

data GameTree #

GameTree represents a tree of game states. Typically it is constructed around the same time move generation happens.

Constructors

GameTree 

Fields

data MoveValidity #

During move generation, we need a way to describe the validity of moves.

Eventually we will need a SameSideCheck constructor to indicate that the given move would cause the current side's king to be placed in check.

Constructors

EmptySquare

We are moving to an empty cell.

Take

We are moving to a cell that has an opposite-color piece.

Occupied

We are moving to a cell that has a same-color piece.

InvalidPawnCapture

We are a Pawn wanting to capture what we cannot.

StartFromEmptySquare

We tried to move a piece from an empty square.

KingCapture

We tried to capture a king.

WrongColorMove

We tried to move a piece that is not ours.

parsePosition :: String -> Maybe Position #

A helper to parse positions from a String.

Smart constructors

mkFile :: Int -> Maybe File #

A smart constructor for File that ensures that the file is between 0 and 7 inclusive.

mkRank :: Int -> Maybe Rank #

A smart constructor for Rank that ensures that the rank is between 0 and 7 inclusive.

mkPosition :: Maybe File -> Maybe Rank -> Maybe Position #

A helper for constructing Position, useful in conjunction with the smart constructors mkFile and mkRank.

Utility functions

mkMovingVector :: (a -> a -> MovingVector a) -> (a, a) -> MovingVector a #

A helper function for converting from regular 2-tuples to MovingVectors.

Should be called with something like mkMovingVector (1, 1) NormalMove.

mkTuple :: MovingVector a -> (a, a) #

This goes the other way, converting a MovingVector a to (a, a).

It is only here until the Position module gets updated to account for the addition of the MovingVector type. Do not rely on it.