Liking cljdoc? Tell your friends :D

clj-chess.game

Tree data structure for representing an annotated game with variations. Work in progress, use at your own risk.

Tree data structure for representing an annotated game with variations.
Work in progress, use at your own risk.
raw docstring

add-byte-moveclj/s

(add-byte-move game byte-move & {:keys [node-id remove-existing-moves?]})

Adds a move in byte notation to the game at the 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 byte notation to the game at the 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.
sourceraw docstring

add-byte-move-sequenceclj/s

(add-byte-move-sequence game
                        byte-moves
                        &
                        {:keys [node-id remove-existing-moves?]})

Like add-byte-move, but adds a sequence of moves rather than a single move. This is faster than calling add-byte-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-byte-move, but adds a sequence of moves rather than a single move.
This is faster than calling add-byte-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.
sourceraw docstring

add-commentclj/s

(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.
sourceraw docstring

add-key-value-pairclj/s

(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.
sourceraw docstring

add-map-moveclj/s

(add-map-move game map-move & {:keys [node-id remove-existing-moves?]})

Adds a map move (see documentation for clj-chess.board/board-to-map) 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 map move (see documentation for clj-chess.board/board-to-map) 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.
sourceraw docstring

add-moveclj/s

(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.
sourceraw docstring

add-move-sequenceclj/s

(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.
sourceraw docstring

add-pre-commentclj/s

(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.
sourceraw docstring

add-san-moveclj/s

(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.
sourceraw docstring

add-san-move-sequenceclj/s

(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.
sourceraw docstring

add-uci-moveclj/s

(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.
sourceraw docstring

add-uci-move-sequenceclj/s

(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.
sourceraw docstring

at-beginning?clj/s

(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.
sourceraw docstring

at-end?clj/s

(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.
sourceraw docstring

black-eloclj/s

(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.
sourceraw docstring

black-playerclj/s

(black-player game)

Name of the black player.

Name of the black player.
sourceraw docstring

boardclj/s

(board game)

Returns the current board position of a game.

Returns the current board position of a game.
sourceraw docstring

boardsclj/s

(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.
sourceraw docstring

boards-with-movesclj/s

(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.
sourceraw docstring

current-node-idclj/s

(current-node-id game)

Returns the node id of the current node.

Returns the node id of the current node.
sourceraw docstring

dateclj/s

(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.
sourceraw docstring

eventclj/s

(event game)

The event of the game, as a string.

The event of the game, as a string.
sourceraw docstring

find-nodeclj/s

(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.
sourceraw docstring

find-node-matchingclj/s

(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.
sourceraw docstring

from-ecnclj/s

(from-ecn ecn
          &
          {:keys [include-annotations? san]
           :or {include-annotations? true san false}})

Creates a game from ECN data, or from parsed PGN.

Creates a game from ECN data, or from parsed PGN.
sourceraw docstring

from-pgnclj/s

(from-pgn pgn-string
          &
          {:keys [include-annotations?] :or {include-annotations? true}})

Creates a game from a PGN string.

Creates a game from a PGN string.
sourceraw docstring

games-in-fileclj

(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.
sourceraw docstring

goto-node-idclj/s

(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.
sourceraw docstring

goto-node-matchingclj/s

(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.
sourceraw docstring

main-lineclj/s

(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.
sourceraw docstring

move-textclj/s

(move-text game
           &
           {:keys [include-comments? include-variations?]
            :or {include-comments? true include-variations? true}})

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.
sourceraw docstring

move-treeclj/s

(move-tree game)

Returns a tree of UCI move strings for the given game. Mostly useful for inspecting and debugging the tree structure.

Returns a tree of UCI move strings for the given game. Mostly useful for
inspecting and debugging the tree structure.
sourceraw docstring

movesclj/s

(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.
sourceraw docstring

new-gameclj/s

(new-game &
          {:keys [white black event site date round result start-fen other-tags]
           :or {white "?"
                black "?"
                event "?"
                site "?"
                date "?"
                round "?"
                result "*"
                start-fen board/start-fen}})

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>].

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>].
sourceraw docstring

promote-nodeclj/s

(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.
sourceraw docstring

promote-node-to-main-lineclj/s

(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.
sourceraw docstring

remove-childrenclj/s

(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.
sourceraw docstring

remove-nodeclj/s

(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.
sourceraw docstring

remove-tagclj/s

(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).
sourceraw docstring

resultclj/s

(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 "*".
sourceraw docstring

roundclj/s

(round game)

The tournament round of the game.

The tournament round of the game.
sourceraw docstring

set-tagclj/s

(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.
sourceraw docstring

side-to-moveclj/s

(side-to-move game)

The side to move at the current game position, :white or :black.

The side to move at the current game position, :white or :black.
sourceraw docstring

siteclj/s

(site game)

The site of the game.

The site of the game.
sourceraw docstring

step-backclj/s

(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.
sourceraw docstring

step-forwardclj/s

(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.
sourceraw docstring

tag-valueclj/s

(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.
sourceraw docstring

take-backclj/s

(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.
sourceraw docstring

to-beginningclj/s

(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.
sourceraw docstring

to-beginning-of-variationclj/s

(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.
sourceraw docstring

to-ecnclj/s

(to-ecn game
        &
        {:keys [include-comments? include-variations? binary?]
         :or {include-comments? true include-variations? true}})

Exports the game as ECN data, optionally including comments and variations.

Exports the game as ECN data, optionally including comments and
variations.
sourceraw docstring

to-endclj/s

(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.
sourceraw docstring

to-end-of-variationclj/s

(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.
sourceraw docstring

to-pgnclj/s

(to-pgn game
        &
        {:keys [include-comments? include-variations?]
         :or {include-comments? true include-variations? true}})

Creates a PGN string from a game, optionally including comments and variations.

Creates a PGN string from a game, optionally including comments and
variations.
sourceraw docstring

to-uciclj/s

(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.
sourceraw docstring

white-eloclj/s

(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.
sourceraw docstring

white-playerclj/s

(white-player game)

Name of the white player.

Name of the white player.
sourceraw docstring

zip-promote-nodeclj/s

(zip-promote-node zipper)

Takes a game tree zipper and returns a zipper for a modified game tree where the current node is promoted one rank among its sibling. If the current node is already the oldest child, returns the original zipper.

Takes a game tree zipper and returns a zipper for a modified game tree
where the current node is promoted one rank among its sibling. If the
current node is already the oldest child, returns the original zipper.
sourceraw docstring

zip-promote-node-to-frontclj/s

(zip-promote-node-to-front zipper)

Takes a game tree zipper and returns a zipper for a modified game tree where the current node is promoted to the oldest among its siblings (i.e. made the main line). If the current node is already the oldest child, returns the original zipper.

Takes a game tree zipper and returns a zipper for a modified game tree
where the current node is promoted to the oldest among its siblings (i.e.
made the main line). If the current node is already the oldest child,
returns the original zipper.
sourceraw docstring

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

× close