(add-comment game cmt & {:keys [node-id]})
Adds a comment to the move leading to the node with the given node id. Uses current node if no node id is supplied. Adding a comment at the root of the game has no effect; if you want to add a comment before the first move of the game, use add-pre-comment instead.
Adds a comment to the move leading to the node with the given node id. Uses current node if no node id is supplied. Adding a comment at the root of the game has no effect; if you want to add a comment before the first move of the game, use add-pre-comment instead.
(add-key-value-pair game key value & {:keys [node-id]})
Adds a key value pair to the map at the given node id of the game. If no node id is supplied, the key value pair is added at the current node.
Adds a key value pair to the map at the given node id of the game. If no node id is supplied, the key value pair is added at the current node.
(add-move game move-function move node-id remove-existing-moves?)
Takes a game, a move function (a function that, given a board and some other value, translates that value to a chess move), a a value representing a move, a node id, and a boolean that says whether the existing moves at the current nodes should be removed, and returns an updated game where the move has been added as the last child at the given node. If no node id is supplied, the current node of the game is used.
Takes a game, a move function (a function that, given a board and some other value, translates that value to a chess move), a a value representing a move, a node id, and a boolean that says whether the existing moves at the current nodes should be removed, and returns an updated game where the move has been added as the last child at the given node. If no node id is supplied, the current node of the game is used.
(add-move-sequence game move-function moves node-id remove-existing-moves?)
Like add-move, but adds a sequence of moves rather than a single move. This is faster than calling add-move multiple times, because we don't have to unzip and zip the tree for each added move. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
Like add-move, but adds a sequence of moves rather than a single move. This is faster than calling add-move multiple times, because we don't have to unzip and zip the tree for each added move. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
(add-pre-comment game cmt & {:keys [node-id]})
Adds a pre-comment to the node with the given node-id. Uses the current node if no node id is supplied. When exporting as PGN, the pre-comment is displayed before the move rather than after. It is probably only useful for the first move of the game or the first move of a recursive annotation variation.
Adds a pre-comment to the node with the given node-id. Uses the current node if no node id is supplied. When exporting as PGN, the pre-comment is displayed *before* the move rather than after. It is probably only useful for the first move of the game or the first move of a recursive annotation variation.
(add-san-move game san-move & {:keys [node-id remove-existing-moves?]})
Adds a move in short algebraic notation to a game at a given node id. The move is added as the last child. If no node id is supplied, the current node of the game is used. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
Adds a move in short algebraic notation to a game at a given node id. The move is added as the last child. If no node id is supplied, the current node of the game is used. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
(add-san-move-sequence game
san-moves
&
{:keys [node-id remove-existing-moves?]})
Like add-san-move, but adds a sequence of moves rather than a single move. This is faster than calling add-san-move multiple times, because we don't have to unzip and zip the tree for each added move. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
Like add-san-move, but adds a sequence of moves rather than a single move. This is faster than calling add-san-move multiple times, because we don't have to unzip and zip the tree for each added move. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
(add-uci-move game uci-move & {:keys [node-id remove-existing-moves?]})
Adds a move in UCI notation to a game at a given node id. The move is added as the last child. If no node id is supplied, the current node of the game is used. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
Adds a move in UCI notation to a game at a given node id. The move is added as the last child. If no node id is supplied, the current node of the game is used. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
(add-uci-move-sequence game
uci-moves
&
{:keys [node-id remove-existing-moves?]})
Like add-uci-move, but adds a sequence of moves rather than a single move. This is faster than calling add-uci-move multiple times, because we don't have to unzip and zip the tree for each added move. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
Like add-uci-move, but adds a sequence of moves rather than a single move. This is faster than calling add-uci-move multiple times, because we don't have to unzip and zip the tree for each added move. If remove-existing-moves? is true, any previously existing moves at the point of insertion are removed.
(ancestors board)
A sequence of all ancestors of the board, ordered by the root board, up to and including the input board.
A sequence of all ancestors of the board, ordered by the root board, up to and including the input board.
(at-beginning? game)
Tests whether we are currently at the beginning of the game, i.e. that the current node equals the root node.
Tests whether we are currently at the beginning of the game, i.e. that the current node equals the root node.
(at-end? game)
Tests whether we are currently at the end of the game, i.e. that the current node has no children.
Tests whether we are currently at the end of the game, i.e. that the current node has no children.
(black-elo game)
The Elo of the black player (as an integer), or nil.
The Elo of the black player (as an integer), or nil.
(black-player game)
Name of the black player.
Name of the black player.
(board game)
Returns the current board position of a game.
Returns the current board position of a game.
(board-equal? board-1 board-2 & boards)
Tests whether two or more boards are equal.
Tests whether two or more boards are equal.
(board-side-to-move board)
The current side to move, :white or :black.
The current side to move, :white or :black.
(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.
(boards game)
A sequence of all the board positions along the main line of the game, beginning at the root node.
A sequence of all the board positions along the main line of the game, beginning at the root node.
(boards-with-moves game)
A sequence of two element vectors, one for each board position along the main line, beginning at the root node. Each two-element vector consists of a board along with the move made from that board.
A sequence of two element vectors, one for each board position along the main line, beginning at the root node. Each two-element vector consists of a board along with the move made from that board.
(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.
(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.
(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}
(check? board)
Tests whether the side to move is in check.
Tests whether the side to move is in check.
(checking-pieces board)
Returns a vector of all squares containing checking pieces (always 0, 1 or 2 pieces).
Returns a vector of all squares containing checking pieces (always 0, 1 or 2 pieces).
(checkmate? board)
Tests whether the board position is checkmate.
Tests whether the board position is checkmate.
(current-node-id game)
Returns the node id of the current node.
Returns the node id of the current node.
(date game)
The date the game was played, as a joda.time.DateTime object in Clojure, and a string in ClojureScript.
The date the game was played, as a joda.time.DateTime object in Clojure, and a string in ClojureScript.
(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.
(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.
(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.
(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.
(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.
(en-passant-capture? move)
Tests whether a move is an en passant capture.
Tests whether a move is an en passant capture.
(event game)
The event of the game, as a string.
The event of the game, as a string.
(file-count board)
The number of files on a chess board (usually 8)
The number of files on a chess board (usually 8)
(find-node game node-id)
Returns the node with the given node id, or nil if no such node exists.
Returns the node with the given node id, or nil if no such node exists.
(find-node-matching game predicate & [start-node])
Finds the first (as found by a depth-first search) game tree node matching the given predicate. If no such node is found, returns nil.
Finds the first (as found by a depth-first search) game tree node matching the given predicate. If no such node is found, returns nil.
(flip-board 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.
(game-from-ecn ecn & {:keys [include-annotations?]})
Creates a game from ECN data.
Creates a game from ECN data.
(game-from-pgn pgn & {:keys [include-annotations?]})
Creates a game from a PGN string.
Creates a game from a PGN string.
(game-to-ecn game & rest)
Exports the game as ECN data, optionally including comments and variations.
Exports the game as ECN data, optionally including comments and variations.
(game-to-pgn game)
Creates a PGN string from a game, optionally including comments and variations.
Creates a PGN string from a game, optionally including comments and variations.
(game-to-uci game)
Exports the current game state in a format ready to be sent to a UCI chess engine, i.e. like 'position fen' followed by a sequence of moves.
Exports the current game state in a format ready to be sent to a UCI chess engine, i.e. like 'position fen' followed by a sequence of moves.
(games-in-file file-name & {:keys [format]})
Returns a lazy sequence of all games in an ECN or PGN file. The optional :format keyword parameter can take the values :ecn or :pgn, and is used to specify the file format. If this parameter is ommited, the function tries to guess the file type by inspecting the extension. If the extension is neither ".pgn", ".PGN", ".ecn" nor ".ECN", PGN format is assumed.
Returns a lazy sequence of all games in an ECN or PGN file. The optional :format keyword parameter can take the values :ecn or :pgn, and is used to specify the file format. If this parameter is ommited, the function tries to guess the file type by inspecting the extension. If the extension is neither ".pgn", ".PGN", ".ecn" nor ".ECN", PGN format is assumed.
(goto-node-id game node-id)
Returns a game equal to the input game, except that :current-node is set to the node with the given node id. If no node with the supplied node id exists in the game, returns nil.
Returns a game equal to the input game, except that :current-node is set to the node with the given node id. If no node with the supplied node id exists in the game, returns nil.
(goto-node-matching game predicate)
Returns a game equal to the input game, except that :current-node is set to the first node matching the given predicate. If no such node is found, returns nil.
Returns a game equal to the input game, except that :current-node is set to the first node matching the given predicate. If no such node is found, returns nil.
(immediate-draw? board)
Tests whether the board position is an immediate draw.
Tests whether the board position is an immediate draw.
(kingside-castle? move)
Tests whether a move is a kingside castling move.
Tests whether a move is a kingside castling move.
(last-move board)
The last move played to reach this board position, or nil if we're at the beginning of the game.
The last move played to reach this board position, or nil if we're at the beginning of the game.
(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.
(legal-moves board)
Returns a vector of all legal moves for the given board.
Returns a vector of all legal moves for the given board.
(main-line game)
Returns a vector of all nodes along the main line of the game, beginning with the root and selecting the oldest child until a leaf is reached.
Returns a vector of all nodes along the main line of the game, beginning with the root and selecting the oldest child until a leaf is reached.
(make-board & [fen allow-king-capture?])
Creates a new chess board from a FEN string. If no FEN is supplied, the standard initial position is used.
Creates a new chess board from a FEN string. If no FEN is supplied, the standard initial position is used.
(move-from move)
The source square of a move
The source square of a move
(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.
(move-from-uci board uci-move)
Translates a move string in UCI notation to a move from the given board. If no matching move exists, returns nil.
Translates a move string in UCI notation to a move from the given board. If no matching move exists, returns nil.
(move-number board)
Current full move number for the given board.
Current full move number for the given board.
(move-promotion move)
The piece type the move promotes into, or :none if the move is not a promotion.
The piece type the move promotes into, or :none if the move is not a promotion.
(move-promotion? move)
Tests whether the move is a pawn promotion
Tests whether the move is a pawn promotion
(move-text game & {:keys [include-comments? include-variations?]})
The move text of the game in short algebraic notation, optionally including comments and variations.
The move text of the game in short algebraic notation, optionally including comments and variations.
(move-to move)
The destination square of a move
The destination square of a move
(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.
(move-to-uci move)
Translates a move to a string in UCI notation.
Translates a move to a string in UCI notation.
(moves game)
A sequence of all moves along the main line of the game, beginning at the root.
A sequence of all moves along the main line of the game, beginning at the root.
(new-game &
{:keys [white black event site date round result start-fen
other-tags]})
Creates a new game object with the given PGN tags and start position. The seven standard tags that make up the "Seven Tag Roster" in the PGN standard are supplied by individual keyword parameters, as is the start-fen parameter that is used to specify the initial position of the game. If any further PGN tags are desired, they should be supplied in a sequence of two-element vectors of the form [<tag-name> <tag-value>], assigned to the keyword parameter 'other-tags'.
Creates a new game object with the given PGN tags and start position. The seven standard tags that make up the "Seven Tag Roster" in the PGN standard are supplied by individual keyword parameters, as is the start-fen parameter that is used to specify the initial position of the game. If any further PGN tags are desired, they should be supplied in a sequence of two-element vectors of the form [<tag-name> <tag-value>], assigned to the keyword parameter 'other-tags'.
(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.
(piece-color piece)
The color of a piece, :white or :black.
The color of a piece, :white or :black.
The color of the piece on a given square.
The color of the piece on a given square.
(piece-count board piece)
(piece-count board piece color)
The number of pieces of the given type. You can either supply three arguments representing board, piece color and piece type (e.g (piece-count board :black :rook)) or two arguments representing board and piece with color (e.g. (piece-count board :wb)).
The number of pieces of the given type. You can either supply three arguments representing board, piece color and piece type (e.g (piece-count board :black :rook)) or two arguments representing board and piece with color (e.g. (piece-count board :wb)).
(piece-make color type)
Converts a color keyword and a piece type keyword to the internal iteger representation of a chess piece of the corresponding color and type.
Converts a color keyword and a piece type keyword to the internal iteger representation of a chess piece of the corresponding color and type.
The piece on a given square.
The piece on a given square.
(piece-type piece)
The type of a piece, given by a keyword of the form :pawn, :knight, etc.
The type of a piece, given by a keyword of the form :pawn, :knight, etc.
The piece type on a given square
The piece type on a given square
(print-board board)
Prints the board to the standard output, for debugging.
Prints the board to the standard output, for debugging.
(promote-node game & {:keys [node-id]})
Returns a modified game where the node with the given node id (if no node id is supplied, the current node is used) is moved one place to the left among its siblings. If the node is already the leftmost (oldest) child of its parent node, the game is returned unchanged.
Returns a modified game where the node with the given node id (if no node id is supplied, the current node is used) is moved one place to the left among its siblings. If the node is already the leftmost (oldest) child of its parent node, the game is returned unchanged.
(promote-node-to-main-line game & {:keys [node-id]})
Returns a modified game where the node with the given node id (if no node id is supplied, the current node is used) is made the main line among its siblings, i.e. moved to the front of the list of child nodes. If the node is already the leftmost (oldest) child of its parent node, the game is returned unchanged.
Returns a modified game where the node with the given node id (if no node id is supplied, the current node is used) is made the main line among its siblings, i.e. moved to the front of the list of child nodes. If the node is already the leftmost (oldest) child of its parent node, the game is returned unchanged.
(queenside-castle? move)
Tests whether a move is a queenside castling move.
Tests whether a move is a queenside castling move.
(rank-count board)
The number of ranks on a chess board (usually 8)
The number of ranks on a chess board (usually 8)
(remove-children game & {:keys [node-id]})
Removes all child nodes of a node (by default, the current node), and returns a modified game with the current node set to the node whose children we just removed.
Removes all child nodes of a node (by default, the current node), and returns a modified game with the current node set to the node whose children we just removed.
(remove-node game & {:keys [node-id]})
Removes a node (by default, the current node) from the game, and returns a modified game with the current node set to the parent of the deleted node.
Removes a node (by default, the current node) from the game, and returns a modified game with the current node set to the parent of the deleted node.
(remove-tag game tag-name)
Returns a new game equal to the input game, but with the given tag removed (if it exists).
Returns a new game equal to the input game, but with the given tag removed (if it exists).
(result game)
The result of the game. Should be one of the strings "1-0", "0-1", "1/2-1/2" and "*".
The result of the game. Should be one of the strings "1-0", "0-1", "1/2-1/2" and "*".
(round game)
The tournament round of the game.
The tournament round of the game.
(set-tag game name value)
Returns a new game equal to the input game, but with the given tag set to the given value. If the tag does not exist in the input game, it is added to the end of the tags list.
Returns a new game equal to the input game, but with the given tag set to the given value. If the tag does not exist in the input game, it is added to the end of the tags list.
(side-to-move game)
The side to move at the current position of the game, :white or :black.
The side to move at the current position of the game, :white or :black.
(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.
(square-to-string square)
Converts a square to a string in standard coordinate notation.
Converts a square to a string in standard coordinate notation.
(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.
(step-back game)
Steps one move backward in the game (goes back to the parent node), and returns the resulting game. The retracted move is not deleted from the game, only the :current-node of the game is changed. If we are already at the beginning of the game, the original game is returned unchanged.
Steps one move backward in the game (goes back to the parent node), and returns the resulting game. The retracted move is not deleted from the game, only the :current-node of the game is changed. If we are already at the beginning of the game, the original game is returned unchanged.
(step-forward game)
Steps one step forward in the game (moves down to the first child node), and returns the resulting game. If we are already at the end of the game, the original game is returned unchanged.
Steps one step forward in the game (moves down to the first child node), and returns the resulting game. If we are already at the end of the game, the original game is returned unchanged.
(tag-value game tag-name)
Returns the value of the given PGN tag in the game, or nil if no such tag exists.
Returns the value of the given PGN tag in the game, or nil if no such tag exists.
(take-back game)
Takes back the move that led to the current node, and returns a game tree with the corresponding node removed and the current node set to the parent. Does nothing if we're already at the beginning of the game.
Takes back the move that led to the current node, and returns a game tree with the corresponding node removed and the current node set to the parent. Does nothing if we're already at the beginning of the game.
(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.
(to-beginning game)
Returns a game identical to the input game, except that current-node is set to the root node.
Returns a game identical to the input game, except that current-node is set to the root node.
(to-beginning-of-variation game)
Returns a game identical to the input game, except that we have stepped back until reaching the beginning of the variation containing the previous current node. In other words, we step back until we reach a branch point where the current variation started, or to the root of the game.
Returns a game identical to the input game, except that we have stepped back until reaching the beginning of the variation containing the previous current node. In other words, we step back until we reach a branch point where the current variation started, or to the root of the game.
(to-end game)
Returns a game identical to the input game, except that current-node is set to the leaf node obtained by following the main line from the root, i.e. by following the sequence of first children from the root node until a leaf node is reached.
Returns a game identical to the input game, except that current-node is set to the leaf node obtained by following the main line from the root, i.e. by following the sequence of first children from the root node until a leaf node is reached.
(to-end-of-variation game)
Returns a game identical to the input game, except that current node is set to the leaf node obtained by following the current variation to its end, i.e. by following the sequence of first children from the current node until a leaf node is reached.
Returns a game identical to the input game, except that current node is set to the leaf node obtained by following the current variation to its end, i.e. by following the sequence of first children from the current node until a leaf node is reached.
(to-fen board)
Converts the board to a string in Forsyth-Edwards notation.
Converts the board to a string in Forsyth-Edwards notation.
(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. Used to pretty-print UCI analysis output.
Translates a variation from a sequence of UCI moves to a string in short algebraic notation. Used to pretty-print UCI analysis output.
(white-elo game)
The Elo of the white player (as an integer), or nil.
The Elo of the white player (as an integer), or nil.
(white-player game)
Name of the white player.
Name of the white player.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close