Skip to content

CNP node: an evaluation's quiet line and piece values (quiet, pieces, searchScore) - #244

Merged
cjus merged 1 commit into
mainfrom
claude/evaluate-pieces
Nov 1, 2026
Merged

cjus merged 1 commit into
mainfrom
claude/evaluate-pieces

Conversation

@cjus

@cjus cjus commented Nov 1, 2026

Copy link
Copy Markdown
Owner

For cjus/chessgui#340, Solrac's Engine Mind ("why this move"), which needs cb2026 to explain the score its search really uses. CNP gained the fields in cjus/chess-node-protocol#21, and this PR pins CNP to its merge, 3791c23.

Why

cb2026 searches with its network, but engine/evaluate breaks down the hand-crafted evaluation. Measured at the ends of 30 reported lines (data in cjus/chessgui#340):

  • The hand-crafted evaluation ordered the three lines as the search did in 0 of 10 positions; the network ordered them right in 5 of 10.
  • 2 of the 30 lines ended mid-exchange, where any static score was 250–550 cp off.

What

  • Engine::quiet_line: the quiescence search alone, from a position, as at a leaf of the main search. With quiet, the node evaluates where its line stops. A capture the side to move needn't make is left alone, as at a leaf.
  • Engine::search_evaluation: the static score the search would use for a position: the network's, or the hand-crafted evaluation's in the endings left to it (lone_king, pawnless_endings) or with nnue off. The node sends it as searchScore when it is the network's.
  • Engine::piece_values: each piece but the kings, valued as that evaluation's score less its score without the piece.
    • Network: through the new Changes::removing, which takes a piece's row off the accumulator. A position no FEN allows (the side not to move left in check) still gets an answer.
    • Hand-crafted: through a position without the piece, leaving out those that can't be built.
    • The idea is the one Stockfish's eval shows (GPL: only the idea, no code).
  • The node answers engine/evaluate with an evaluator engine of its own (1 MB table), cleared before each request. Answers repeat exactly, whether or not a search is running.
  • Mate: with quiet, a side checkmated where the captures stop is {"mate": 0}, with no searchScore or pieces. A plain evaluation stays static, as before.
  • docs/status.md and docs/PRD.md updated.

The spec's example is this node's real answer (after 1.e4 d5 2.exd5): quiet: ["d8d5"], hand-crafted −17, network +34, and the queens on d1 and d5 and the bishop on f1 worth 918, 912 and 338 to the network. A test checks it (an_evaluation_settles_captures_and_values_pieces_by_the_network).

Checked

  • No functional change: bench 767812 on this branch and on main. The search is untouched: Searcher::hand_crafted_ending now calls a shared function with the same test.
  • scripts/check.sh passed on 87e6192 (fmt, clippy with and without gpu, every test, perft, docs, cargo deny, the book). db0c629 is the same tree, with only the Bench: line added to its message.
  • CNP conformance: cb2026 passes evaluate-quiet-pieces and skips evaluate-quiet-pieces-unsupported, which is for nodes without these capabilities (crates/cli/tests/cnp.rs).

🤖 Generated with Claude Code

… searchScore)

cb2026 searches with its network, but engine/evaluate breaks down the
hand-crafted evaluation, which ordered three reported lines as the search did
in 0 of 10 positions (the network: 5 of 10). CNP now lets a node say more
(cjus/chess-node-protocol#21), for Solrac's Engine Mind (cjus/chessgui#340):

- Engine::quiet_line: the quiescence search alone, from a position, as at a
  leaf. A line can end mid-exchange (2 in 30), and its score comes from where
  these captures stop. With quiet, the node evaluates there.
- Engine::search_evaluation: the static score the search would use, the
  network's or, in the endings it leaves to it, the hand-crafted one's.
  Sent as searchScore when it is the network's.
- Engine::piece_values: each piece's value to that evaluation, the score less
  the score without the piece. The network's through Changes::removing, which
  takes a piece's row off the accumulator, so a position no FEN allows (a side
  not to move left in check) still has an answer; the hand-crafted
  evaluation's through a position without the piece, leaving out those.
- The node answers evaluate with an engine of its own (1 MB table), cleared
  before each request, so an answer doesn't depend on a running search.

CNP pinned to 3791c23 (cnp and cnp-conformance), which adds the two sessions:
cb2026 passes evaluate-quiet-pieces and skips the one for nodes without it.

No functional change: the search is untouched (Searcher::hand_crafted_ending
now calls a shared function with the same test), and evaluate changes no
engine state a search uses.

Bench: 767812

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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