pilatch / elm-chess / Move

The Move and Variation data types, and miscellaneus functions operating on moves.

Types


type alias Move =
Internal.Move

Type representing a chess move. The move contains information about the from and to square, and whether the move is a castle, an en passant capture, or a pawn promotion.


type alias Variation =
List Move

Type representing a variation, i.e. a sequence of moves.

Extracting Properties of Moves

from : Move -> Square

The source square of a move.

to : Move -> Square

The destination square of a move.

promotion : Move -> Maybe PieceType

The piece type to which the move promotes, or Nothing if the move is not a promotion move.

isPromotion : Move -> Basics.Bool

Whether the move is a pawn promotion

isCastle : Move -> Basics.Bool

Whether the move is a castling move.

isKingsideCastle : Move -> Basics.Bool

Whether the move is a kingside castling move.

isQueensideCastle : Move -> Basics.Bool

Whether the move is a queenside castling move.

isEp : Move -> Basics.Bool

Whether the move is an en passant capture.

Converting Moves to UCI Notation

toUci : Move -> String

Translate a move to UCI notation. Translating from UCI cannot be done by inspecting the move a lone, since it also requires a board.