hchesslib-0.2.0.0: Chess library
CopyrightMiika-Petteri Matikainen 2014
LicenseGPL-2
Maintainermiikapetteri@gmail.com
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe-Inferred
LanguageHaskell2010

Chess

Description

Simple chess library for implementing chess games.

Synopsis

Documentation

type Coordinates = (Int, Int) Source #

Coordinate format:

(rank, file)
(0,0)          (0,7)
   +---> file
   |
   |
   v
  rank
 (7,0)         (7,7)
-
  +-------+-------+-------+-------+-------+-------+-------+-------+
8 | (0,0) | (0,1) | (0,2) | (0,3) | (0,4) | (0,5) | (0,6) | (0,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
7 | (1,0) | (1,1) | (1,2) | (1,3) | (1,4) | (1,5) | (1,6) | (1,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
6 | (2,0) | (2,1) | (2,2) | (2,3) | (2,4) | (2,5) | (2,6) | (2,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
5 | (3,0) | (3,1) | (3,2) | (3,3) | (3,4) | (3,5) | (3,6) | (3,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
4 | (4,0) | (4,1) | (4,2) | (4,3) | (4,4) | (4,5) | (4,6) | (4,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
3 | (5,0) | (5,1) | (5,2) | (5,3) | (5,4) | (5,5) | (5,6) | (5,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
2 | (6,0) | (6,1) | (6,2) | (6,3) | (6,4) | (6,5) | (6,6) | (6,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
1 | (7,0) | (7,1) | (7,2) | (7,3) | (7,4) | (7,5) | (7,6) | (7,7) |
  +-------+-------+-------+-------+-------+-------+-------+-------+
      a       b       c       d       e       f       g       h
 

data Square Source #

Constructors

Square Piece 
Empty 

Instances

Instances details
Eq Square Source # 
Instance details

Defined in Chess.Internal.Board

Methods

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

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

Show Square Source # 
Instance details

Defined in Chess.Internal.Board

data GameState Source #

Instances

Instances details
Eq GameState Source # 
Instance details

Defined in Chess.Internal.Move

Show GameState Source # 
Instance details

Defined in Chess.Internal.Move

data Color Source #

Constructors

White 
Black 

Instances

Instances details
Eq Color Source # 
Instance details

Defined in Chess.Internal.Piece

Methods

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

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

Show Color Source # 
Instance details

Defined in Chess.Internal.Piece

Methods

showsPrec :: Int -> Color -> ShowS #

show :: Color -> String #

showList :: [Color] -> ShowS #

data Piece Source #

Constructors

Piece Color PieceType 

Instances

Instances details
Eq Piece Source # 
Instance details

Defined in Chess.Internal.Piece

Methods

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

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

Show Piece Source # 
Instance details

Defined in Chess.Internal.Piece

Methods

showsPrec :: Int -> Piece -> ShowS #

show :: Piece -> String #

showList :: [Piece] -> ShowS #

data PieceType Source #

Constructors

Pawn 
Knight 
Bishop 
Rook 
Queen 
King 

Instances

Instances details
Eq PieceType Source # 
Instance details

Defined in Chess.Internal.Piece

Show PieceType Source # 
Instance details

Defined in Chess.Internal.Piece

data Move Source #

Instances

Instances details
Eq Move Source # 
Instance details

Defined in Chess.Internal.Move

Methods

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

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

Show Move Source # 
Instance details

Defined in Chess.Internal.Move

Methods

showsPrec :: Int -> Move -> ShowS #

show :: Move -> String #

showList :: [Move] -> ShowS #

board :: GameState -> Board Source #

Current board state in the game

fullMoveNumber :: GameState -> Integer Source #

Full move number. Incremented after black's move.

isCheckmate :: GameState -> Bool Source #

Has the game ended in checkmate

isDraw :: GameState -> Bool Source #

Is the game draw? I.e. is the game stalemate or is the game draw by insufficient material.

isLegalMove Source #

Arguments

:: GameState 
-> String

Move in coordinate notation. E.g. "e2-e4" or "b1-c3"

-> Bool 

Is the given move legal. The only supported move format at the moment is coordinate notation.

isStalemate :: GameState -> Bool Source #

Has the game ended in stalemate

move Source #

Arguments

:: GameState 
-> String

Move in coordinate notation. E.g. "e2-e4" or "b1-c3"

-> Maybe GameState 

Make a move. The only supported move format at the moment is coordinate notation.

newGame :: GameState Source #

Get initial game state

pieceAt Source #

Arguments

:: Board 
-> String

Square coordinate. E.g. "e4"

-> Maybe Piece 

Get the piece at the given coordinate

winner :: GameState -> Maybe Color Source #

Returns the winner of the game if any

legalMoves :: GameState -> [Move] Source #

Get all legal moves in the position