Skip to content

CNP: search trees (engine/tree, engine/treeNode, capability tree) - #249

Merged
cjus merged 4 commits into
mainfrom
claude/cnp-search-tree
Nov 1, 2026
Merged

cjus merged 4 commits into
mainfrom
claude/cnp-search-tree

Conversation

@cjus

@cjus cjus commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

For cjus/chessgui#350, the search-tree panel of Solrac's Engine Mind ("why not that move?"). CNP defines the requests in cjus/chess-node-protocol#22, merged, and this PR pins cnp and cnp-conformance to its merge commit, deeab77.

What

  • engine/tree and engine/treeNode (capability tree, spec 7.8). A tree is recorded by Engine::search_tree on a fresh engine and a thread of its own: its own 16 MB table, one thread, the switches at their defaults, the main engine's evaluation, network and tablebases. So it is answered while a search runs, and the same request gives the same tree (a test checks both). One tree at a time (maxConcurrentTrees 1). $/cancelRequest stops it and it keeps nothing; the next tree isn't Busy. maxTimeMs bounds it (LimitExceeded). engine/treeNode is answered in the command loop, at once.
  • cb2026_engine::tree::FoldedTree folds the event log into nodes:
    • Each node is its last search, the one whose score counted: its window, score, children and decisions are that search's. Mixed together, a reduced search, its re-search and an aspiration re-search would repeat decisions and keep replies the deciding search never looked at. The earlier searches show as the decisions that led to the last.
    • Each decision goes to the node it is about. A reduction and its re-searches are noted at the child's path; the singular, double and negative extensions are noted at the parent, naming the hash move. All of them move to the child they describe. A decision's move is always a move from its own node (a test checks this on a real depth-8 tree).
    • Left out: verification searches (a null move's, and the singular extension's, which enters the open node again) and attempts that decided nothing (TtHit, NullMove, ProbCut, SingularSearch).
  • Notes in alpha-beta's terms, each with the switch behind it as technique:
Note Decision Technique
BetaCutoff(m, i) cutoff move m order i alphabeta
TtCutoff table tt
Tablebase tablebase
NullMoveCutoff nullMove nullmove
ReverseFutility, Razoring, MultiCut nodePruned rfp, razoring, multicut
ProbCutCutoff(m) nodePruned move m probcut
LateMovePruning, HistoryPruning, Futility, SeePruning, DeltaPruning (m) movePruned move m lmp, histprune, futility, seeprune, delta
Reduced(_, n) reduced plies n lmr
NegativeExtension reduced plies negative_extension_plies negext
SingularExtension, DoubleExtension extended plies 1 singular, doubleext
ReductionResearch research reason depth lmr
PvsResearch research reason window pvs
each root search before the last research reason window, at the root aspiration
  • Scores: mates are counted from the node (search::to_score_at), and a score's bound is read against the window of its last search.
  • Limits and memory: depth up to 24 (11–15 s on the M1 Max), up to six plies (6,300–9,300 nodes at depth 16), 500,000 events a recording. Trees are kept five minutes after their last use, eight trees and 2,000,000 nodes and decisions at most, the one unused longest dropped first.
  • Engine: search_tree takes a stop flag, so a tree can be cancelled. A recorded tree brackets the root's searches with Enter and Exit, so an aspiration re-search shows. These go to the tree only, never the statistics, so nothing changes outside a recording.
  • docs/status.md and docs/PRD.md updated.

Checked

  • No functional change: bench 767812, the same as main.
  • scripts/check.sh passed on 3e0432b, this PR's latest commit (fmt, clippy with and without gpu, every test, perft, docs, cargo deny, the book), and GitHub's CI passed on it. The release node passes the six tree sessions of the protocol at deeab77 with cnp-conformance (tree-unsupported skipped).
  • CNP conformance: cb2026 passes the six new tree sessions and skips tree-unsupported, which is for nodes without trees (crates/cli/tests/cnp.rs).

🤖 Generated with Claude Code

cjus and others added 4 commits November 1, 2026 16:33
cb2026's node keeps search trees for Solrac's Engine Mind (Solrac Chess AI
#350), as the Chess Node Protocol's new section 7.8 defines them.

- A tree is recorded by Engine::search_tree on a fresh engine and a thread of
  its own (its own table, one thread, the switches at their defaults), so it
  is answered while a search runs and is the same tree every time. One at a
  time; a cancel stops it and keeps nothing; the node's maxTimeMs bounds it.
- cb2026_engine::tree folds the log into nodes. Each node is its last search
  (window, score, children, decisions), after the decisions that say how it
  came to be searched that way; verification searches (null move, singular)
  and attempts that decided nothing are left out; each decision goes to the
  node it is about, so the singular, double and negative extensions move from
  the parent to the child.
- The node says each note in alpha-beta's terms (cutoff, table, tablebase,
  nullMove, nodePruned, movePruned, reduced, extended, research), naming the
  switch behind it, with mates counted from the node and each score's bound
  read against the window of its last search.
- Trees are kept five minutes after their last use, eight and 2,000,000
  nodes and decisions at most, the one unused longest dropped first; up to
  depth 24 and six plies, 500,000 events a recording.
- search_tree takes a stop flag, and a recorded tree brackets the root's
  searches (not counted in the statistics), so an aspiration re-search shows.
- The cnp pin moves to cjus/chess-node-protocol#22's branch (68cf80d), whose
  six new sessions cb2026 passes.

No functional change.

Bench: 767812

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No functional change.

Bench: 767812

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No functional change.

Bench: 767812

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
@cjus
cjus marked this pull request as ready for review November 1, 2026 23:43
@cjus
cjus merged commit 6a0038f into main Nov 1, 2026
1 check passed
@cjus
cjus deleted the claude/cnp-search-tree branch November 1, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant