-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Basic chess library
--
-- A simple and fast library for generating legal chess moves. Also
-- includes a module for communication with external processes that speak
-- the UCI (Universal Chess Interface) protocol, a PGN parser/pretty
-- printer, and Polyglot opening book support. On top of that, provides a
-- console frontend program (cboard) that can be used to interactively
-- play against UCI engines, and a terminal program (cbookview) to
-- explore commonly played chess openings.
@package chessIO
@version 0.6.0.0
-- | 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:
--
--
module Game.Chess
data Color
Black :: Color
White :: Color
opponent :: Color -> Color
class IsSquare sq
toIndex :: IsSquare sq => sq -> Int
toRF :: IsSquare sq => sq -> (Int, Int)
data Sq
A1 :: Sq
B1 :: Sq
C1 :: Sq
D1 :: Sq
E1 :: Sq
F1 :: Sq
G1 :: Sq
H1 :: Sq
A2 :: Sq
B2 :: Sq
C2 :: Sq
D2 :: Sq
E2 :: Sq
F2 :: Sq
G2 :: Sq
H2 :: Sq
A3 :: Sq
B3 :: Sq
C3 :: Sq
D3 :: Sq
E3 :: Sq
F3 :: Sq
G3 :: Sq
H3 :: Sq
A4 :: Sq
B4 :: Sq
C4 :: Sq
D4 :: Sq
E4 :: Sq
F4 :: Sq
G4 :: Sq
H4 :: Sq
A5 :: Sq
B5 :: Sq
C5 :: Sq
D5 :: Sq
E5 :: Sq
F5 :: Sq
G5 :: Sq
H5 :: Sq
A6 :: Sq
B6 :: Sq
C6 :: Sq
D6 :: Sq
E6 :: Sq
F6 :: Sq
G6 :: Sq
H6 :: Sq
A7 :: Sq
B7 :: Sq
C7 :: Sq
D7 :: Sq
E7 :: Sq
F7 :: Sq
G7 :: Sq
H7 :: Sq
A8 :: Sq
B8 :: Sq
C8 :: Sq
D8 :: Sq
E8 :: Sq
F8 :: Sq
G8 :: Sq
H8 :: Sq
isLight :: IsSquare sq => sq -> Bool
isDark :: IsSquare sq => sq -> Bool
data PieceType
Pawn :: PieceType
Knight :: PieceType
Bishop :: PieceType
Rook :: PieceType
Queen :: PieceType
King :: PieceType
data Castle
Kingside :: Castle
Queenside :: Castle
data Position
-- | The starting position as given by the FEN string
-- "rnbqkbnrpppppppp8888PPPPPPPP/RNBQKBNR w KQkq - 0
-- 1".
startpos :: Position
-- | active color
color :: Position -> Color
-- | number of the full move
moveNumber :: Position -> Int
halfMoveClock :: Position -> Int
pieceAt :: IsSquare sq => Position -> sq -> Maybe (Color, PieceType)
-- | Returns True if Color is in check in the given position.
inCheck :: Color -> Position -> Bool
castlingRights :: Position -> [(Color, Castle)]
canCastleKingside :: Position -> Bool
canCastleQueenside :: Position -> Bool
insufficientMaterial :: Position -> Bool
repetitions :: [Position] -> Maybe (Int, Position)
-- | Construct a position from Forsyth-Edwards-Notation.
fromFEN :: String -> Maybe Position
-- | Convert a position to Forsyth-Edwards-Notation.
toFEN :: Position -> String
newtype Ply
Ply :: Word16 -> Ply
plySource :: Ply -> Int
plyTarget :: Ply -> Int
plyPromotion :: Ply -> Maybe PieceType
-- | Parse a move in the format used by the Universal Chess Interface
-- protocol.
fromUCI :: Position -> String -> Maybe Ply
-- | Convert a move to the format used by the Universal Chess Interface
-- protocol.
toUCI :: Ply -> String
fromPolyglot :: Position -> Ply -> Ply
toPolyglot :: Position -> Ply -> Ply
-- | Generate a list of possible moves for the given position.
legalPlies :: Position -> [Ply]
-- | Apply a move to the given position.
--
-- This function checks if the move is actually legal and throws and
-- error if it isn't. See unsafeDoPly for a version that omits the
-- legality check.
doPly :: Position -> Ply -> Position
-- | An unsafe version of doPly. Only use this if you are sure the
-- given move can be applied to the position. This is useful if the move
-- has been generated by the moves function.
unsafeDoPly :: Position -> Ply -> Position
module Game.Chess.SAN
fromSAN :: (VisualStream s, TraversableStream s, SANToken (Token s), IsString (Tokens s)) => Position -> s -> Either String Ply
toSAN :: IsString s => Position -> Ply -> s
unsafeToSAN :: Position -> Ply -> String
class SANToken a
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
varToSAN :: IsString s => Position -> [Ply] -> s
instance GHC.Show.Show Game.Chess.SAN.From
instance GHC.Classes.Eq Game.Chess.SAN.From
instance GHC.Show.Show Game.Chess.SAN.SANStatus
instance GHC.Read.Read Game.Chess.SAN.SANStatus
instance GHC.Classes.Eq Game.Chess.SAN.SANStatus
instance Game.Chess.SAN.SANToken GHC.Types.Char
instance Game.Chess.SAN.SANToken GHC.Word.Word8
module Game.Chess.PGN
readPGNFile :: FilePath -> IO (Either String PGN)
gameFromForest :: [(ByteString, Text)] -> Forest Ply -> Outcome -> Game
pgnForest :: PGN -> Forest Ply
newtype PGN
PGN :: [Game] -> PGN
type Game = ([(ByteString, Text)], (Outcome, Forest PlyData))
data Outcome
Win :: Color -> Outcome
Draw :: Outcome
Undecided :: Outcome
hPutPGN :: Handle -> RAVOrder (Doc ann) -> PGN -> IO ()
pgnDoc :: RAVOrder (Doc ann) -> PGN -> Doc ann
type RAVOrder a = (Forest PlyData -> a) -> Forest PlyData -> [a]
breadthFirst :: RAVOrder a
depthFirst :: RAVOrder a
gameDoc :: RAVOrder (Doc ann) -> Game -> Doc ann
weightedForest :: PGN -> Forest (Rational, Ply)
instance GHC.Show.Show Game.Chess.PGN.Outcome
instance GHC.Classes.Eq Game.Chess.PGN.Outcome
instance GHC.Show.Show Game.Chess.PGN.PlyData
instance GHC.Classes.Eq Game.Chess.PGN.PlyData
instance GHC.Base.Semigroup Game.Chess.PGN.PGN
instance GHC.Base.Monoid Game.Chess.PGN.PGN
instance GHC.Classes.Eq Game.Chess.PGN.PGN
instance GHC.Classes.Ord Game.Chess.PGN.Outcome
instance Prettyprinter.Internal.Pretty Game.Chess.PGN.Outcome
module Game.Chess.Polyglot
-- | A Polyglot opening book.
data PolyglotBook
defaultBook :: PolyglotBook
twic :: PolyglotBook
-- | Create a PolyglotBook from a ByteString.
fromByteString :: ByteString -> PolyglotBook
toByteString :: PolyglotBook -> ByteString
readPolyglotFile :: FilePath -> IO PolyglotBook
writePolyglotFile :: FilePath -> PolyglotBook -> IO ()
makeBook :: PGN -> PolyglotBook
toPGN :: PolyglotBook -> Position -> PGN
-- | Pick a random ply from the book.
bookPly :: RandomGen g => PolyglotBook -> Position -> Maybe (Rand g Ply)
-- | Probe the book for all plies known for the given position.
bookPlies :: PolyglotBook -> Position -> [Ply]
bookForest :: PolyglotBook -> Position -> Forest Ply
-- | Predicted Variations. Return the most popular game.
variations :: PolyglotBook -> Position -> [[Ply]]
findPosition :: PolyglotBook -> Position -> [BookEntry]
instance GHC.Show.Show Game.Chess.Polyglot.BookEntry
instance GHC.Classes.Eq Game.Chess.Polyglot.BookEntry
instance GHC.Classes.Eq Game.Chess.Polyglot.PolyglotBook
instance GHC.Classes.Ord Game.Chess.Polyglot.BookEntry
instance Foreign.Storable.Storable Game.Chess.Polyglot.BookEntry
module Game.Chess.Tree
positionTree :: Position -> Tree Position
positionForest :: Position -> Forest Position
plyTree :: Position -> Ply -> Tree Ply
plyForest :: Position -> Forest Ply
pathTree :: Tree a -> Tree (NonEmpty a)
module Game.Chess.UCI
data UCIException
IllegalMove :: Ply -> UCIException
data Engine
type BestMove = Maybe (Ply, Maybe Ply)
name :: Engine -> Maybe ByteString
author :: Engine -> Maybe ByteString
-- | Start a UCI engine with the given executable name and command line
-- arguments.
start :: String -> [String] -> IO (Maybe Engine)
-- | Start a UCI engine with the given timeout for initialisation.
--
-- If the engine takes more then the given microseconds to answer to the
-- initialisation request, Nothing is returned and the external
-- process will be terminated.
start' :: KnownDivRat unit Microsecond => Time unit -> (String -> IO ()) -> String -> [String] -> IO (Maybe Engine)
data Option
CheckBox :: Bool -> Option
ComboBox :: ByteString -> [ByteString] -> Option
[comboBoxValue] :: Option -> ByteString
[comboBoxValues] :: Option -> [ByteString]
SpinButton :: Int -> Option
[spinButtonValue, spinButtonMinBound, spinButtonMaxBound] :: Option -> Int
OString :: ByteString -> Option
Button :: Option
options :: Engine -> HashMap ByteString Option
getOption :: ByteString -> Engine -> Maybe Option
-- | Set a spin option to a particular value.
--
-- Bounds are validated. Make sure you don't set a value which is out of
-- range.
setOptionSpinButton :: MonadIO m => ByteString -> Int -> Engine -> m Engine
setOptionString :: MonadIO m => ByteString -> ByteString -> Engine -> m Engine
-- | Wait until the engine is ready to take more commands.
isready :: Engine -> IO ()
-- | Return the final position of the currently active game.
currentPosition :: MonadIO m => Engine -> m Position
-- | Set the starting position of the current game, also clearing any
-- pre-existing history.
setPosition :: MonadIO m => Engine -> Position -> m (Position, [Ply])
-- | Add a Move to the game history.
--
-- This function checks if the move is actually legal, and throws a
-- UCIException if it isn't.
addPly :: MonadIO m => Engine -> Ply -> m ()
replacePly :: MonadIO m => Engine -> Ply -> m ()
data Info
PV :: [Ply] -> Info
Depth :: Int -> Info
SelDepth :: Int -> Info
Elapsed :: Time Millisecond -> Info
MultiPV :: Int -> Info
Score :: Score -> Maybe Bounds -> Info
Nodes :: Int -> Info
NPS :: Int -> Info
TBHits :: Int -> Info
HashFull :: Int -> Info
CurrMove :: Ply -> Info
CurrMoveNumber :: Int -> Info
String :: ByteString -> Info
data Score
CentiPawns :: Int -> Score
MateIn :: Int -> Score
data Bounds
UpperBound :: Bounds
LowerBound :: Bounds
-- | Instruct the engine to begin searching.
search :: MonadIO m => Engine -> [SearchParam] -> m (TChan BestMove, TChan [Info])
searching :: MonadIO m => Engine -> m Bool
data SearchParam
searchmoves :: [Ply] -> SearchParam
ponder :: SearchParam
timeleft :: KnownDivRat unit Millisecond => Color -> Time unit -> SearchParam
timeincrement :: KnownDivRat unit Millisecond => Color -> Time unit -> SearchParam
movestogo :: Natural -> SearchParam
movetime :: KnownDivRat unit Millisecond => Time unit -> SearchParam
nodes :: Natural -> SearchParam
depth :: Natural -> SearchParam
infinite :: SearchParam
-- | Switch a ponder search to normal search when the pondered move was
-- played.
ponderhit :: MonadIO m => Engine -> m ()
-- | Stop a search in progress.
stop :: MonadIO m => Engine -> m ()
-- | Quit the engine.
quit :: MonadIO m => Engine -> m (Maybe ExitCode)
quit' :: (KnownDivRat unit Microsecond, MonadIO m) => Time unit -> Engine -> m (Maybe ExitCode)
instance GHC.Show.Show Game.Chess.UCI.UCIException
instance GHC.Show.Show Game.Chess.UCI.Score
instance GHC.Classes.Ord Game.Chess.UCI.Score
instance GHC.Classes.Eq Game.Chess.UCI.Score
instance GHC.Show.Show Game.Chess.UCI.Bounds
instance GHC.Classes.Eq Game.Chess.UCI.Bounds
instance GHC.Show.Show Game.Chess.UCI.Info
instance GHC.Classes.Eq Game.Chess.UCI.Info
instance GHC.Show.Show Game.Chess.UCI.Option
instance GHC.Classes.Eq Game.Chess.UCI.Option
instance GHC.Show.Show Game.Chess.UCI.Command
instance GHC.Show.Show Game.Chess.UCI.SearchParam
instance GHC.Classes.Eq Game.Chess.UCI.SearchParam
instance Data.String.IsString Game.Chess.UCI.Option
instance GHC.Exception.Type.Exception Game.Chess.UCI.UCIException