Portability | unknown |
---|---|
Stability | experimental |
Maintainer | miikapetteri@gmail.com |
Safe Haskell | None |
Simple chess library for implementing chess games.
- type Board = Array Coordinates Square
- type Coordinates = (Int, Int)
- data Square
- data GameState
- currentPlayer :: GameState -> Color
- data Color
- data Piece = Piece Color PieceType
- data PieceType
- board :: GameState -> Board
- fullMoveNumber :: GameState -> Integer
- isCheckmate :: GameState -> Bool
- isDraw :: GameState -> Bool
- isLegalMove :: GameState -> String -> Bool
- isStalemate :: GameState -> Bool
- move :: GameState -> String -> Maybe GameState
- newGame :: GameState
- pieceAt :: Board -> String -> Maybe Piece
- winner :: GameState -> Maybe Color
Documentation
type Board = Array Coordinates SquareSource
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
fullMoveNumber :: GameState -> IntegerSource
Full move number. Incremented after black's move.
isCheckmate :: GameState -> BoolSource
Has the game ended in checkmate
isDraw :: GameState -> BoolSource
Is the game draw? I.e. is the game stalemate or is the game draw by insufficient material.
Is the given move legal. The only supported move format at the moment is coordinate notation.
isStalemate :: GameState -> BoolSource
Has the game ended in stalemate
Make a move. The only supported move format at the moment is coordinate notation.
Get the piece at the given coordinate