Liking cljdoc? Tell your friends :D

clj-chess.board


ancestorsclj/s

(ancestors board)

A sequence of all ancestors of the board, ordered from the root board, up to and including the input board.

A sequence of all ancestors of the board, ordered from the root board, up
to and including the input board.
sourceraw docstring

attacked?clj

(attacked? board square color)
source

attacks-fromclj

(attacks-from board square)

The set of squares attacked by the piece on the given square.

The set of squares attacked by the piece on the given square.
sourceraw docstring

attacks-toclj

(attacks-to board square)
(attacks-to board square color)

The set of squares containing pieces that attack the given square. If the third, optional argument 'color' is supplied, only attackers of that color are included.

The set of squares containing pieces that attack the given square.
If the third, optional argument 'color' is supplied, only attackers
of that color are included.
sourceraw docstring

bishopclj/s

source

bishop-attacksclj

(bishop-attacks board square)

The set of squares that would be attacked by a bishop on the given square.

The set of squares that would be attacked by a bishop on the given
square.
sourceraw docstring

bishop-squaresclj

(bishop-squares board color)

The set of squares containing bishops of the given color.

The set of squares containing bishops of the given color.
sourceraw docstring

blackclj/s

source

black-bishopclj/s

source

black-kingclj/s

source

black-knightclj/s

source

black-pawnclj/s

source

black-queenclj/s

source

black-rookclj/s

source

blockerclj/s

source

board-to-mapclj/s

(board-to-map board)

Translates a board and its list of legal moves to a map of the following format (for the initial position):

{:pieces [[:br 56] [:bn 57] [:bb 58] [:bq 59] ... [wr 7]] :moves [{:piece :white-pawn, :from 8, :to 16} ... ] :checks [...]}

Every move map needs at least the keys :piece, :from and :to. In addition, capture moves take a :captured-piece and an optional :capture-square (if omitted, assumed to be equal to the :to square). Promotion moves include a :promote-to key. Castle moves include the :rook-from and :rook-to keys. Some examples:

The white move fxg8=R, where the captured piece is a knight, would be represented by the map

{:piece :wp, :from 53, :to 62, :captured-piece :bn, :promote-to :wr}

Black queenside castling would be represented by the map

{:piece :bk, :from 60, :to 58, :rook-from 56, :rook-to 59}

An en passant capture exd6 would be represented by the map

{:piece :wp, :from 36, :to 43, :captured-piece :bp, :capture-square 35}

No assumptions can be made about the ordering of the lists of pieces and legal moves.

The value attached to the :checks key is a sequence of checking pieces. For each checking piece, the sequence contains a map of the form {:from <sq-1> :to <sq-2>}, where :from is the square of the checking piece, and :to the square of the king.

Translates a board and its list of legal moves to a map of the following
 format (for the initial position):

   {:pieces [[:br 56] [:bn 57] [:bb 58] [:bq 59] ... [wr 7]]
    :moves [{:piece :white-pawn, :from 8, :to 16} ... ]
    :checks [...]}

Every move map needs at least the keys :piece, :from and :to. In addition,
capture moves take a :captured-piece and an optional :capture-square (if
omitted, assumed to be equal to the :to square). Promotion moves include
a :promote-to key. Castle moves include the :rook-from and :rook-to keys.
Some examples:

The white move fxg8=R, where the captured piece is a knight, would be
represented by the map

  {:piece :wp, :from 53, :to 62, :captured-piece :bn, :promote-to :wr}

Black queenside castling would be represented by the map

  {:piece :bk, :from 60, :to 58, :rook-from 56, :rook-to 59}

An en passant capture exd6 would be represented by the map

  {:piece :wp, :from 36, :to 43, :captured-piece :bp, :capture-square 35}

No assumptions can be made about the ordering of the lists of pieces
and legal moves.

The value attached to the :checks key is a sequence of checking pieces.
For each checking piece, the sequence contains a map of the form
{:from <sq-1> :to <sq-2>}, where :from is the square of the checking
piece, and :to the square of the king.
sourceraw docstring

board-to-uciclj/s

(board-to-uci board)

Translates the board state (including as much of the move history as necessary) to a format ready to be sent to a UCI chess engine, i.e. like 'position fen' followed by a sequence of moves.

Translates the board state (including as much of the move history as
necessary) to a format ready to be sent to a UCI chess engine, i.e.
like 'position fen' followed by a sequence of moves.
sourceraw docstring

can-castle-kingside?clj/s

(can-castle-kingside? board side)

Tests whether the given side still has the right to castle kingside.

Tests whether the given side still has the right to castle kingside.
sourceraw docstring

can-castle-queenside?clj/s

(can-castle-queenside? board side)

Tests whether the given side still has the right to castle queenside.

Tests whether the given side still has the right to castle queenside.
sourceraw docstring

castle-rightsclj/s

(castle-rights board)

Castle rights, a subset of #{:white-oo :white-ooo :black-oo :black-ooo}

Castle rights, a subset of #{:white-oo :white-ooo :black-oo :black-ooo}
sourceraw docstring

check?clj/s

(check? board)

Tests whether the side to move is in check.

Tests whether the side to move is in check.
sourceraw docstring

checking-piecesclj/s

(checking-pieces board)

Returns a vector of all squares containing checking pieces (0, 1 or 2).

Returns a vector of all squares containing checking pieces (0, 1 or 2).
sourceraw docstring

checkmate?clj/s

(checkmate? board)

Tests whether the board position is checkmate.

Tests whether the board position is checkmate.
sourceraw docstring

disable-king-captureclj

(disable-king-capture board)

Returns an identical board, except that king captures are not allowed.

Returns an identical board, except that king captures are not allowed.
sourceraw docstring

divideclj

(divide board depth)

divide function for testing move generator, see https://chessprogramming.wikispaces.com/Perft

divide function for testing move generator, see
https://chessprogramming.wikispaces.com/Perft
sourceraw docstring

do-map-moveclj/s

(do-map-move board move-map)

Execute the move given by the provided move map. For the format of this map, see the documentation of board-to-map.

Execute the move given by the provided move map. For the format of this
map, see the documentation of board-to-map.
sourceraw docstring

do-moveclj/s

(do-move board move)

Do a move (encoded as an integer) from the current board, and returns the new board. The move is assumed to be legal.

Do a move (encoded as an integer) from the current board, and returns the
new board. The move is assumed to be legal.
sourceraw docstring

do-null-moveclj

(do-null-move board)

Do a null move, i.e. just change the side to move without making a move. This will only work if the side to move is not in check, or if the board is a pseudo-chess board where king captures are allowed.

Do a null move, i.e. just change the side to move without making a
move. This will only work if the side to move is not in check, or if
the board is a pseudo-chess board where king captures are allowed.
sourceraw docstring

do-san-moveclj/s

(do-san-move board san-move)

Do the move represented by a SAN string, and return the new board. If no matching move exists, returns nil.

Do the move represented by a SAN string, and return the new board. If no
matching move exists, returns nil.
sourceraw docstring

do-san-move-sequenceclj/s

(do-san-move-sequence board san-move-sequence)

Executes a sequence of moves in short algebraic notation, and returns the new board, assuming that all moves in the sequence are valid, legal moves. Returns nil if the sequence contains an invalid move.

Executes a sequence of moves in short algebraic notation, and returns the
new board, assuming that all moves in the sequence are valid, legal moves.
Returns nil if the sequence contains an invalid move.
sourceraw docstring

do-uci-moveclj/s

(do-uci-move board uci-move)

Do the move represented by a UCI string, and return the new board. If no matching move exists, returns nil.

Do the move represented by a UCI string, and return the new board. If no
matching move exists, returns nil.
sourceraw docstring

do-uci-move-sequenceclj/s

(do-uci-move-sequence board uci-move-sequence)

Executes a sequence of moves in UCI notation, and returns the new board, assuming that all moves in the sequence are valid, legal moves. Returns nil if the sequence contains an invalid move.

Executes a sequence of moves in UCI notation, and returns the new board,
assuming that all moves in the sequence are valid, legal moves. Returns
nil if the sequence contains an invalid move.
sourceraw docstring

empty-boardclj

(empty-board file-count rank-count & [allow-king-capture?])

Creates an empty board with the given number of files and ranks, optionally allowing king captures.

Creates an empty board with the given number of files and ranks,
optionally allowing king captures.
sourceraw docstring

empty-squareclj/s

source

empty-square?clj/s

(empty-square? board square)

Tests whether the given square is empty.

Tests whether the given square is empty.
sourceraw docstring

empty-squaresclj

(empty-squares board)

The set of all empty squares on the board.

The set of all empty squares on the board.
sourceraw docstring

enable-king-captureclj

(enable-king-capture board)

Returns an identical board, except that king captures are allowed.

Returns an identical board, except that king captures are allowed.
sourceraw docstring

equal?clj/s

(equal? board-1 board-2)
(equal? board-1 board-2 & rest)

Tests whether two or more boards are equal.

Tests whether two or more boards are equal.
sourceraw docstring

file-countclj/s

(file-count board)

Number of files on the board.

Number of files on the board.
sourceraw docstring

flipclj

(flip board)

Returns a flipped copy of a board, with the black and white pieces, the side to move, the castle rights and the en passant capture square flipped.

Returns a flipped copy of a board, with the black and white pieces,
the side to move, the castle rights and the en passant capture square
flipped.
sourceraw docstring

immediate-draw?clj/s

(immediate-draw? board)

Tests whether the board position is an immediate draw.

Tests whether the board position is an immediate draw.
sourceraw docstring

is-kingside-castle?clj/s

(is-kingside-castle? move)
source

is-queenside-castle?clj/s

(is-queenside-castle? move)
source

kingclj/s

source

king-attacksclj

(king-attacks board square)

The set of squares that would be attacked by a king on the given square.

The set of squares that would be attacked by a king on the given
square.
sourceraw docstring

king-capture-allowed?clj

(king-capture-allowed? board)
source

king-squareclj/s

(king-square board color)

The square of the king for the given color.

The square of the king for the given color.
sourceraw docstring

king-squaresclj

(king-squares board color)

The set of squares containing kings of the given color.

The set of squares containing kings of the given color.
sourceraw docstring

knightclj/s

source

knight-attacksclj

(knight-attacks board square)

The set of squares that would be attacked by a knight on the given square.

The set of squares that would be attacked by a knight on the given
square.
sourceraw docstring

knight-squaresclj

(knight-squares board color)

The set of squares containing knights of the given color.

The set of squares containing knights of the given color.
sourceraw docstring

last-moveclj/s

(last-move board)

The last move played to reach this board position, or nil if we are at the beginning of the game.

The last move played to reach this board position, or nil if we are at
the beginning of the game.
sourceraw docstring

last-move-to-sanclj/s

(last-move-to-san board)

Translate the last move played to reach this board position to short algebraic notation.

Translate the last move played to reach this board position to short
algebraic notation.
sourceraw docstring

make-boardclj/s

(make-board & [fen allow-king-capture?])

Creates a new chess board from a FEN string. If no string is supplied, the standard initial position is used.

Creates a new chess board from a FEN string. If no string is supplied, the
standard initial position is used.
sourceraw docstring

move-fromclj/s

(move-from move)
source

move-from-byteclj/s

(move-from-byte board byte-move)

Converts a move in byte format, i.e. an integer representing the index of the move among the legal moves sorted alphabetically in UCI notation, to an actual move.

Converts a move in byte format, i.e. an integer representing the index
of the move among the legal moves sorted alphabetically in UCI notation,
to an actual move.
sourceraw docstring

move-from-mapclj/s

(move-from-map board move-map)

Translate a move in map notation to a move from the given board. If no maching move is found, returns nil.

Translate a move in map notation to a move from the given board. If no
maching move is found, returns nil.
sourceraw docstring

move-from-sanclj/s

(move-from-san board san-move)

Translate a move string in short algebraic notation to a move from the given board. If no matching move is found, returns nil.

Translate a move string in short algebraic notation to a move from the given
board. If no matching move is found, returns nil.
sourceraw docstring

move-from-uciclj/s

(move-from-uci board uci-move)
source

move-is-checkmate?clj/s

(move-is-checkmate? board move)

Tests whether the move is a mate in one.

Tests whether the move is a mate in one.
sourceraw docstring

move-is-ep?clj/s

(move-is-ep? move)
source

move-is-promotion?clj/s

(move-is-promotion? move)
source

move-noneclj/s

source

move-numberclj/s

(move-number board)

Current full move number.

Current full move number.
sourceraw docstring

move-promotionclj/s

(move-promotion move)
source

move-toclj/s

(move-to move)
source

move-to-byteclj/s

(move-to-byte board move)

Converts a move to a byte by sorting all moves alphabetically in UCI notation and finding the index of the move in the list.

Converts a move to a byte by sorting all moves alphabetically in UCI
notation and finding the index of the move in the list.
sourceraw docstring

move-to-mapclj/s

(move-to-map board move)

Translate a move to a map of the format described in the documentation of the board-to-map function, e.g.

{:piece :wp, :from 53, :to 62, :captured-piece :bn, :promote-to :wr}

for the move fxg8=R.

Translate a move to a map of the format described in the documentation of
the board-to-map function, e.g.

  {:piece :wp, :from 53, :to 62, :captured-piece :bn, :promote-to :wr}

for the move fxg8=R.
sourceraw docstring

move-to-sanclj/s

(move-to-san board move & {:keys [include-move-number?]})

Translates a move to a string in short algebraic notation, optionally including a preceding move number.

Translates a move to a string in short algebraic notation, optionally
including a preceding move number.
sourceraw docstring

move-to-uciclj/s

(move-to-uci move)

Translates a move to a string in UCI notation.

Translates a move to a string in UCI notation.
sourceraw docstring

movesclj/s

(moves board)

Returns the legal moves for the current board.

Returns the legal moves for the current board.
sourceraw docstring

moves-fromclj/s

(moves-from board square)

Returns the legal moves from the given square.

Returns the legal moves from the given square.
sourceraw docstring

moves-toclj/s

(moves-to board square)

Returns the legal moves to the given square.

Returns the legal moves to the given square.
sourceraw docstring

occupied-square?clj/s

(occupied-square? board square)

Tests whether the given square is occupied.

Tests whether the given square is occupied.
sourceraw docstring

occupied-squaresclj

(occupied-squares board)
(occupied-squares board color)

The set of occupied squares on the board, including blockers. Supplying the optional 'color' parameter will result in only squares occupied by pieces of that color (and no blockers) to be returned.

The set of occupied squares on the board, including blockers. Supplying
the optional 'color' parameter will result in only squares occupied by
pieces of that color (and no blockers) to be returned.
sourceraw docstring

parentclj/s

(parent board)

The parent board of the current board (i.e. the board as it was before the last move was played), or nil if we're at the beginning of the game.

The parent board of the current board (i.e. the board as it was before the
last move was played), or nil if we're at the beginning of the game.
sourceraw docstring

pattern-keyclj

(pattern-key board file-min file-max rank-min rank-max & [color])

Creates a hash key for a given rectangular area of the board, either for both colors (if the optional 'color' parameter is ommited) or just for one color, ignoring the pieces of the other color, if the 'color' parameter is supplied.

Creates a hash key for a given rectangular area of the board, either
for both colors (if the optional 'color' parameter is ommited) or just
for one color, ignoring the pieces of the other color, if the 'color'
parameter is supplied.
sourceraw docstring

pawnclj/s

source

pawn-attacksclj

(pawn-attacks board color square)

The set of squares that would be attacked by a pawn of the given color from the given square.

The set of squares that would be attacked by a pawn of the given color
from the given square.
sourceraw docstring

pawn-squaresclj

(pawn-squares board color)

The set of squares containing pawns of the given color.

The set of squares containing pawns of the given color.
sourceraw docstring

perftclj/s

(perft board depth & [no-pmap])

perft function for testing move generator, see https://chessprogramming.wikispaces.com/Perft

perft function for testing move generator, see
https://chessprogramming.wikispaces.com/Perft
sourceraw docstring

piece-colorclj/s

(piece-color piece)

Returns the color of a piece (white or black).

Returns the color of a piece (white or black).
sourceraw docstring

piece-countclj

(piece-count board piece)
(piece-count board color type)

The number of pieces of a given type. There is a two-argument version taking a board and a piece as input, and a three-argument version taking a board, a color and a piece type.

The number of pieces of a given type. There is a two-argument version taking
a board and a piece as input, and a three-argument version taking a board,
a color and a piece type.
sourceraw docstring

piece-makeclj/s

(piece-make color type)

Returns a piece with a given color and type.

Returns a piece with a given color and type.
sourceraw docstring

piece-onclj/s

(piece-on board square)

The piece on a given square.

The piece on a given square.
sourceraw docstring

piece-typeclj/s

(piece-type piece)

Returns the type of a piece (pawn, knight, bishop, etc.).

Returns the type of a piece (pawn, knight, bishop, etc.).
sourceraw docstring

(print-board board)

Prints a board to the console, for debugging.

Prints a board to the console, for debugging.
sourceraw docstring

put-piececlj

(put-piece board piece square)

Puts a piece or a blocker on a given square.

Puts a piece or a blocker on a given square.
sourceraw docstring

queenclj/s

source

queen-attacksclj

(queen-attacks board square)

The set of squares that would be attacked by a queen on the given square.

The set of squares that would be attacked by a queen on the given
square.
sourceraw docstring

queen-squaresclj

(queen-squares board color)

The set of squares containing queens of the given color.

The set of squares containing queens of the given color.
sourceraw docstring

rank-countclj/s

(rank-count board)

Number of ranks on the board.

Number of ranks on the board.
sourceraw docstring

remove-piececlj

(remove-piece board square)

Removes the piece or blocker on the given square.

Removes the piece or blocker on the given square.
sourceraw docstring

rookclj/s

source

rook-attacksclj

(rook-attacks board square)

The set of squares that would be attacked by a rook on the given square.

The set of squares that would be attacked by a rook on the given
square.
sourceraw docstring

rook-squaresclj

(rook-squares board color)

The set of squares containing rooks of the given color.

The set of squares containing rooks of the given color.
sourceraw docstring

side-to-moveclj/s

(side-to-move board)

The current side to move, :white or :black.

The current side to move, :white or :black.
sourceraw docstring

square-fileclj/s

(square-file square)
source

square-from-stringclj/s

(square-from-string sq-str)

Converts a string in standard coordinate notation to a square.

Converts a string in standard coordinate notation to a square.
sourceraw docstring

square-makeclj/s

(square-make file rank)
source

square-rankclj/s

(square-rank square)
source

square-to-stringclj/s

(square-to-string square)

Converts a square to a string in standard coordinate notation.

Converts a square to a string in standard coordinate notation.
sourceraw docstring

start-fenclj/s

source

static-exchange-evaluationclj

(static-exchange-evaluation board move)

Statically evaluates the material gain or loss of a move. The return value is a number of pawns, using a material scale of pawn = 1, knight = 3, bishop = 3, rook = 5, queen = 9.

Statically evaluates the material gain or loss of a move. The return
value is a number of pawns, using a material scale of pawn = 1,
knight = 3, bishop = 3, rook = 5, queen = 9.
sourceraw docstring

terminal?clj/s

(terminal? board)

Tests whether the board position is terminal, i.e. checkmate or an immediate draw.

Tests whether the board position is terminal, i.e. checkmate or an
immediate draw.
sourceraw docstring

to-fenclj/s

(to-fen board)

Converts the board to a string in Forsyth-Edwards notation.

Converts the board to a string in Forsyth-Edwards notation.
sourceraw docstring

variation-to-sanclj/s

(variation-to-san board uci-moves & {:keys [include-move-numbers]})

Translates a variation from a sequence of UCI moves to a string in short algebraic notation.

Translates a variation from a sequence of UCI moves to a string in
short algebraic notation.
sourceraw docstring

whiteclj/s

source

white-bishopclj/s

source

white-kingclj/s

source

white-knightclj/s

source

white-pawnclj/s

source

white-queenclj/s

source

white-rookclj/s

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close