Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Board = Board {
- board :: Vector Cell
- sideToMove :: Color
- castleAbility :: [CastleAbility]
- enPassant :: Maybe String
- halfmoves :: Integer
- fullmoves :: Integer
- data CastleAbility
- data MovingVector a
- = NormalMove a a
- | PawnCaptureMove a a
- data Piece
- data Color
- data Cell
- data File
- data Rank
- pattern PRank :: Int -> Rank
- pattern PFile :: Int -> File
- data Position = Position !File !Rank
- getFile :: File -> Int
- getRank :: Rank -> Int
- data GameTree = GameTree {}
- data MoveValidity
- parsePosition :: String -> Maybe Position
- mkFile :: Int -> Maybe File
- mkRank :: Int -> Maybe Rank
- mkPosition :: Maybe File -> Maybe Rank -> Maybe Position
- mkMovingVector :: (a -> a -> MovingVector a) -> (a, a) -> MovingVector a
- mkTuple :: MovingVector a -> (a, a)
Documentation
Board
represents the current state of the game at any given moment.
Board | |
|
data CastleAbility #
Who can castle and on which side(s)?
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 Pawn
s. Pawns capture diagonally, so we need a way to denote
"this vector only applies when capturing."
NormalMove a a | |
PawnCaptureMove a a |
Functor MovingVector # | |
Eq a => Eq (MovingVector a) # | |
Ord a => Ord (MovingVector a) # | |
Show a => Show (MovingVector a) # | |
There are 6 different kinds of chess pieces.
GameTree
represents a tree of game states. Typically it is constructed
around the same time move generation happens.
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.
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 |
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. |
Smart constructors
A smart constructor for File
that ensures that the file is between
0
and 7
inclusive.
A smart constructor for Rank
that ensures that the rank is between
0
and 7
inclusive.
Utility functions
mkMovingVector :: (a -> a -> MovingVector a) -> (a, a) -> MovingVector a #
A helper function for converting from regular 2-tuples to MovingVector
s.
Should be called with something like
.mkMovingVector
(1, 1) NormalMove
mkTuple :: MovingVector a -> (a, a) #
This goes the other way, converting a
to MovingVector
a(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.