Repository navigation
Engine: the search tree (engine/tree, engine/treeNode, capability tree) - #22
Merged
Merged
Conversation
…lity tree) The tree's request and result, its nodes and their decisions in alpha-beta's terms, the tree limits (maxTreeDepth, maxTreePlies, maxConcurrentTrees) and the error Expired. The spec and the conformance sessions follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engine/tree searches a position and keeps its tree under a handle that expires; engine/treeNode reads a node and a page of its children by its path. A node is its last search: its window, its score bounded by that window, its children and its decisions, which are alpha-beta's (cutoff, table, tablebase, nullMove, nodePruned, movePruned, reduced, extended, research), each naming the engine/techniques id behind it. The capability tree, the limits maxTreeDepth, maxTreePlies and maxConcurrentTrees, and the error Expired (-32018), recorded in 1.0's changes and taken off the reserved names. The examples are cb2026's tree of 7.1's position. Seven sessions: reading a tree, its errors, its limits, a tree during a search, a cancelled one, a checkmated position, and a node without tree (cjus/chessgui#350). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xample's prose Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cjus
marked this pull request as ready for review
November 1, 2026 23:32
cjus
added a commit
to cjus/chessengine
that referenced
this pull request
Nov 1, 2026
The same tree as the branch's 68cf80d, now on the protocol's main. No functional change. Bench: 767812 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For cjus/chessgui#350 (Engine Mind's search-tree panel: "why not that move?"). Defines the names §13 reserved:
engine/treeandengine/treeNode, behind the capabilitytree, added to the 1.0 draft. Not to merge yet (the owner reviews first).Why
A search tree answers "why not that move?": for each root move, how the search settled it (the best, refuted by a reply, dismissed at once, pruned, reduced), and each move's replies the same way. A tree is large (with cb2026 at depth 16: 560–900 nodes at three plies, 6,300–9,300 nodes and 16,000–23,000 decisions at six), so the node keeps it under a handle and the client reads it a node and a page of children at a time.
What
engine/tree {position, depth, plies?, limit?}searches and answers with the handle,expiresMs(idle expiry, renewed by each read), the search's result (depth,selDepth,nodes,timeMs,bestMove,score,pv),recorded(plies,nodes,decisions,truncated), the root, and its firstlimitchildren.engine/treeNode {tree, path, offset?, limit?}answers with the node (childCountis the total) and a page of its children.depth, its window (alpha,beta, CNP scores, an edge left out when there is none), itsscorewith its bound read against that window,childCount,subtree, anddecisions. The searches before the last show as the decisions that led to it.cutoff(move,order),table,tablebase,nullMove,nodePruned(move, optional: ProbCut's capture),movePruned(move),reduced(plies),extended(plies),research(reason:depthorwindow). Each may name theengine/techniquesid behind it intechnique. A decision'smoveis always a move from its own node. A client ignores a kind or reason it doesn't know; the crate reads them asUnknown.maxTreeDepth(defaultmaxDepth),maxTreePlies,maxConcurrentTrees(default 1). A tree counts towardmaxConcurrentTrees, notmaxConcurrentSearches, so a client can ask for one while the engine plays.Expired(-32018): a handle the node no longer keeps, or never gave. A path to no node of the tree isInvalidParams.$/cancelRequestdrops a tree (Cancelled, nothing kept), and doesn't make the next treeBusy.engine/stopdoesn't apply: a tree is wanted whole.maxTimeMsbounds a tree's search (LimitExceeded).Tree,TreeNodePage,TreeParams,TreeResult,Recorded,TreeNode,Decision,DecisionKind,ResearchReason,TreeNodeParams,TreeNodeResult,EngineCapabilities::tree, the threeLimitsfields withtree_depth()andconcurrent_trees(),code::EXPIRED, with tests. The spec's examples are cb2026's real tree of §7.1's position (its PV shortened).tree,tree-errors,tree-limits,tree-while-searching,tree-cancel,tree-checkmated,tree-unsupported.Checked
cargo fmt --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test,RUSTDOCFLAGS=-D\ warnings cargo doc --workspace --no-depsandcargo deny checkpass locally.Breaking for struct literals:
EngineCapabilitiesandLimitsliterals need the new fields, as withponderandquiet. cb2026's and Solrac's pin bumps make those changes.🤖 Generated with Claude Code