hchesslib-0.1.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

data Color Source

Constructors

White 
Black 

Instances

data Piece Source

Constructors

Piece Color PieceType 

Instances

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