Skip to content

[search-material] The Material page of the search dialog - #16

Open
tuliovianna-lab wants to merge 2 commits into
itshak:mainfrom
tuliovianna-lab:feat/search-material
Open

tuliovianna-lab wants to merge 2 commits into
itshak:mainfrom
tuliovianna-lab:feat/search-material

Conversation

@tuliovianna-lab

Copy link
Copy Markdown
Contributor

Adds the "Material" page of ChessBase's search dialog, following the architecture of the "Position" page (#11/#12).

What it does

  • GameDataQuery::material takes a MaterialQuery:
    • per-side min/max for Q, R, B, N, P, minor pieces and total (king + pieces);
    • the pawn boxes Doubled, Passed, Connected, Isolated, Backward and their ! forms;
    • Ignore colours, Difference, Total;
    • opposite/even bishops, good/bad bishop;
    • symmetric / not symmetric, both wings / one wing;
    • Length / Last (defaults 1 / 999).
  • It runs on the main line, in the same replay pass as the "Position" page:
    • Tracker is now generic over a small Predicate trait (Pattern and the new Material implement it); the position search's behaviour is unchanged;
    • a game is dropped early once a minimum can no longer be reached (men never come back, pawns only promote).
  • Refused as Unsupported, like "Sacrifice":
    • "Tablebases" (undefined in the help);
    • "Not blocked" (the help's two descriptions disagree);
    • "Blocked" (no reading matched ChessBase; see below).
  • CLI: --white-material "Q0 R1 P0..8", --black-material, --white-pawns "isolated,!passed", --black-pawns, --material-flags …, --material-length, --material-last, --material-from-fen ("Position Setup"). --move-numbering now applies to both pages.

Semantics and evidence

The meaning of each box comes from ChessBase's public help. Where the help is silent, counts were measured with ChessBase on Mega Database 2026 (Length 1, Last 999):

Search ChessBase cbvault
Q 0, R 1, B 0, N 0, P 0-8 on both sides 1,141,586 1,141,583
"No pieces", Total 1-1 on both sides 536,372 536,372
Difference + Ignore colours (dialog defaults, White R 2) 1,316,196 1,316,191
Same, Black R -1, Ignore colours off (sign of Difference) 531,997 531,995
"Reset" (pawn endings), White Backward 297,740 298,254
"Reset" (pawn endings), Blocked 92,722 refused

What the measurements settled:

  • Total counts the king and the pieces, not the pawns.
  • Difference is Black minus White.
  • Backward is the closest of seven readings measured (+0.17%).
  • Blocked: the closest reading was 7% off, so it is refused rather than guessed.

Details are in docs/search.md.

Performance (Mega Database 2026, release)

Query 1 thread 10 threads
material: rook vs rook, moves 1-999 94.2 s 12.0 s
material: pawn endings, white backward pawn 173.1 s 23.2 s
position: Bh7, moves 1-40 (this branch vs v0.4.0, 10 threads, mean of 5 alternating runs) 8.46 s vs 8.34 s, same 211,902 matches

Checks

  • cargo fmt --check, cargo clippy --all-targets --all-features -D warnings and cargo test --workspace --all-features pass.
  • Tests added:
    • unit tests per box;
    • classic + 2CBH integration tests (tests/query_material.rs);
    • a CLI test;
    • benchmark entries.
  • Also included: the OpenSpec change search-material, CHANGELOG and provenance.

🤖 Generated with Claude Code

tuliovianna-lab and others added 2 commits December 4, 2026 09:11
Counts per side (Q, R, B, N, P, minor pieces, total), the pawn boxes and
their negations, ignore colours, difference, total, the bishop and pawn
structure boxes, and Length / Last, replayed on the main line through a
Tracker now generic over the page it follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Total counts the king and the pieces, not the pawns; Backward includes
isolated pawns; Blocked is refused (no reading matched ChessBase). The
replay sink keeps its verdict in two flags so the per-token poll stays as
cheap as before. Adds the OpenSpec change, the search guide section with
the ChessBase counts, provenance, changelog and benchmark entries.

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