Skip to content

Tuning #8

Merged
winapiadmin merged 16 commits into
HandcraftedEnginefrom
tuning_exp1
Jul 10, 2026
Merged

Tuning #8
winapiadmin merged 16 commits into
HandcraftedEnginefrom
tuning_exp1

Conversation

@winapiadmin

Copy link
Copy Markdown
Owner

No description provided.

@winapiadmin
winapiadmin merged commit 03b7ebf into HandcraftedEngine Jul 10, 2026
2 checks passed
@winapiadmin
winapiadmin deleted the tuning_exp1 branch July 10, 2026 13:56
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 231de9c4-6157-4bb6-81c3-9cd5c5299595

📥 Commits

Reviewing files that changed from the base of the PR and between 0ee5318 and 06a2a9e.

📒 Files selected for processing (7)
  • eval.cpp
  • main.cpp
  • search.cpp
  • search.h
  • timeman.cpp
  • timeman.h
  • uci.cpp

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a configurable Threads engine option.
    • Added the UCI bench command to benchmark engine performance and report nodes and NPS.
  • Performance Improvements

    • Enabled additional evaluation tuning parameters.
    • Improved move ordering and search heuristics.
    • Updated capture-extension behavior to improve search effectiveness.
  • Bug Fixes

    • Improved time-management initialization and handling for searches without time controls.

Walkthrough

The change activates evaluation tuning registrations, adds a Threads option, updates search heuristics and timing state, changes search to return node counts, and introduces a fixed-position bench UCI command reporting nodes and NPS.

Changes

Search engine updates

Layer / File(s) Summary
Engine configuration activation
eval.cpp, main.cpp
Evaluation tuning registrations are enabled, and a Threads UCI option is registered.
Search heuristic and extension changes
search.cpp
Quiet moves are tracked for cutoff history bonuses and maluses, and capture extensions apply whenever no other extension is active.
Time-management state changes
timeman.h, timeman.cpp, uci.cpp
LimitsType no longer stores startTime; timing initialization uses the current time and the revised time-management guard.
Search result API and benchmark command
search.h, search.cpp, uci.cpp
Search returns its node count, and bench searches fixed-depth FEN positions before printing aggregate nodes and NPS.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant UCI
  participant execCmd
  participant search
  participant Position
  UCI->>execCmd: bench
  execCmd->>Position: load benchmark FEN
  execCmd->>search: search(position, depth=10)
  search-->>execCmd: session.nodes
  execCmd-->>UCI: nodes and nps
Loading

Poem

A rabbit hops through search’s bright maze,
Quiet moves earn history’s praise.
Time starts fresh, nodes count high,
Bench runs beneath the chessboard sky.
“Threads!” I cheer—and nibble a tie.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tuning_exp1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06a2a9ead6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread timeman.h
@@ -25,7 +25,7 @@ struct LimitsType {
bool use_time_management() const { return time[chess::WHITE] || time[chess::BLACK]; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check the moving side's clock before time-managing

When only the opponent's clock is provided/nonzero, e.g. go btime 30000 while White is to move, this now enables time management even though limits.time[us] is zero. TimeManagement::init() then computes scales from a zero clock (log10(time / 1000.0)), which can produce non-finite or effectively immediate/huge time limits; the previous side-specific guard avoided that path. Base the predicate on the side to move's clock instead of either clock.

Useful? React with 👍 / 👎.

Comment thread uci.cpp
score = -score;
std::cout << score << std::endl;
break;
} else if (token == "bench") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop any active search before benching

If bench is entered while a previous go search is still running, this branch starts repeated synchronous search::search() calls without first joining searchThread. Since search::search() resets the shared stop flag and uses the global transposition table, the benchmark and background search can run concurrently and interleave/corrupt engine state and output; other search-affecting commands call stop() before proceeding.

Useful? React with 👍 / 👎.

Comment thread uci.cpp
auto start = std::chrono::high_resolution_clock::now();
for (auto &fen : Defaults) {
std::cerr << fen << '\n';
chess::Position pos(fen);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse bench move suffixes before searching

Several benchmark entries above include a UCI-style moves ... suffix, but constructing chess::Position directly from the whole string does not replay those moves, so those cases are searched from the base FEN instead of the intended post-move position (or may be rejected by strict FEN parsing). Reuse the same FEN-plus-moves parsing logic as handlePosition() for each bench entry.

Useful? React with 👍 / 👎.

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.

2 participants