Copyright | (c) Mario Lang 2019 |
---|---|
License | BSD3 |
Maintainer | mlang@blind.guru |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A small collection of data types and functions to represent Chess positions and moves including move generation and parsing from external sources.
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.
Synopsis
- data Color
- opponent :: Color -> Color
- 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
- fromFEN :: String -> Maybe Position
- toFEN :: Position -> String
- newtype Ply = Ply Word16
- strictSAN :: forall s. (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> Parser s Ply
- relaxedSAN :: (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> Parser s Ply
- fromSAN :: (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> s -> Either String Ply
- toSAN :: Position -> Ply -> String
- unsafeToSAN :: Position -> Ply -> String
- fromUCI :: Position -> String -> Maybe Ply
- toUCI :: Ply -> String
- fromPolyglot :: 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 | |
Show PieceType Source # | |
Ix PieceType Source # | |
Defined in Game.Chess 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 #
Converting from/to Forsyth-Edwards-Notation
Chess moves
Converting from/to algebraic notation
strictSAN :: forall s. (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> Parser s Ply Source #
relaxedSAN :: (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> Parser s Ply Source #
fromSAN :: (Stream s, SANToken (Token s), IsString (Tokens s)) => Position -> s -> Either String Ply Source #
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.