Copyright | (c) Mario Lang 2020 |
---|---|
License | BSD3 |
Maintainer | mlang@blind.guru |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Types for representing positions and plies and functions for move generation and application. Internally, quad bitboards are employed and plies are stored as 16 bit values. The move generation is fully compliant to the standard rules of Chess.
This module does deliberately not implement any search or evaluation functionality. It is intended to be used to lay the ground for communicating with other programs or players, hence the package name chessIO.
The following modules implement more specific functionality:
- Game.Chess.Polyglot: Polyglot opening book format
- Game.Chess.SAN: Parse and print Standard Algebraic Notation.
- Game.Chess.PGN: Parse and format Portable Game Notation files.
- Game.Chess.Tree: Functions for converting a position to a tree.
- Game.Chess.UCI: Control external engines using the Universal Chess Interface.
Synopsis
- data Color
- opponent :: Color -> Color
- class IsSquare sq where
- data Sq
- isLight :: IsSquare sq => sq -> Bool
- isDark :: IsSquare sq => sq -> Bool
- data PieceType
- data Castle
- data Position
- startpos :: Position
- color :: Position -> Color
- moveNumber :: Position -> Int
- halfMoveClock :: Position -> Int
- pieceAt :: IsSquare sq => Position -> sq -> Maybe (Color, PieceType)
- inCheck :: Color -> Position -> Bool
- castlingRights :: Position -> [(Color, Castle)]
- canCastleKingside :: Position -> Bool
- canCastleQueenside :: Position -> Bool
- insufficientMaterial :: Position -> Bool
- repetitions :: [Position] -> Maybe (Int, Position)
- fromFEN :: String -> Maybe Position
- toFEN :: Position -> String
- newtype Ply = Ply Word16
- plySource :: Ply -> Int
- plyTarget :: Ply -> Int
- plyPromotion :: Ply -> Maybe PieceType
- fromUCI :: Position -> String -> Maybe Ply
- toUCI :: Ply -> String
- fromPolyglot :: Position -> Ply -> Ply
- toPolyglot :: Position -> Ply -> Ply
- legalPlies :: Position -> [Ply]
- doPly :: Position -> Ply -> Position
- unsafeDoPly :: Position -> Ply -> Position
Chess positions
A1 | |
B1 | |
C1 | |
D1 | |
E1 | |
F1 | |
G1 | |
H1 | |
A2 | |
B2 | |
C2 | |
D2 | |
E2 | |
F2 | |
G2 | |
H2 | |
A3 | |
B3 | |
C3 | |
D3 | |
E3 | |
F3 | |
G3 | |
H3 | |
A4 | |
B4 | |
C4 | |
D4 | |
E4 | |
F4 | |
G4 | |
H4 | |
A5 | |
B5 | |
C5 | |
D5 | |
E5 | |
F5 | |
G5 | |
H5 | |
A6 | |
B6 | |
C6 | |
D6 | |
E6 | |
F6 | |
G6 | |
H6 | |
A7 | |
B7 | |
C7 | |
D7 | |
E7 | |
F7 | |
G7 | |
H7 | |
A8 | |
B8 | |
C8 | |
D8 | |
E8 | |
F8 | |
G8 | |
H8 |
Instances
Eq PieceType Source # | |
Ord PieceType Source # | |
Defined in Game.Chess.Internal | |
Show PieceType Source # | |
Ix PieceType Source # | |
Defined in Game.Chess.Internal range :: (PieceType, PieceType) -> [PieceType] # index :: (PieceType, PieceType) -> PieceType -> Int # unsafeIndex :: (PieceType, PieceType) -> PieceType -> Int # inRange :: (PieceType, PieceType) -> PieceType -> Bool # rangeSize :: (PieceType, PieceType) -> Int # unsafeRangeSize :: (PieceType, PieceType) -> Int # |
The starting position as given by the FEN string "rnbqkbnrpppppppp8888PPPPPPPP/RNBQKBNR w KQkq - 0 1".
moveNumber :: Position -> Int Source #
number of the full move
halfMoveClock :: Position -> Int Source #
canCastleKingside :: Position -> Bool Source #
canCastleQueenside :: Position -> Bool Source #
insufficientMaterial :: Position -> Bool Source #
Converting from/to Forsyth-Edwards-Notation
Chess moves
Convertion
fromUCI :: Position -> String -> Maybe Ply Source #
Parse a move in the format used by the Universal Chess Interface protocol.
toUCI :: Ply -> String Source #
Convert a move to the format used by the Universal Chess Interface protocol.
Move generation
legalPlies :: Position -> [Ply] Source #
Generate a list of possible moves for the given position.