Skip to content

Add search command (bestmove plus root score) - #13

Open
abstratovcm wants to merge 1 commit into
edre:masterfrom
tocandira:search-command
Open

abstratovcm wants to merge 1 commit into
edre:masterfrom
tocandira:search-command

Conversation

@abstratovcm

Copy link
Copy Markdown

Adds a search command, same args as bestmove, output move;score;pvlen.

What changed:

  • uhp_server.rs: limit parsing moved out of best_move into configure_search, shared by both commands. bestmove output unchanged.
  • player.rs: ScoredStrategy trait (Strategy + root_value()), implemented for IterativeSearch and ParallelSearch, None for random/mcts. Player::root_value() returns None when the last move came from RandomOpening instead of a search.
  • test next to the existing bestmove one: checks the 3 fields and the empty score after a RandomOpening move.

Use case: self play → one score per position → training data for a learned eval. Needed the root value, bestmove only gives the move.

Checked: cargo test (both feature sets), uhp-debug self test, clippy, fmt, wasm lib check.

Prints `move;score;pvlen`, where score is the root value from the side to
move's perspective (empty for strategies without one, e.g. random/mcts, and
after a RandomOpening move) and pvlen the length of the principal variation.
Accepts the same limits as bestmove (depth, time, seconds, depthorseconds).

Motivation: generating training positions for a learned evaluation needs the
search score, and bestmove only returns the move.
@edre

edre commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Is this something that needs to go in the UHP extension, or can this just be a command line subcommand that does a search from a position and outputs the score?

@abstratovcm

Copy link
Copy Markdown
Author

Thanks for taking a look! I went with UHP because I use it while playing out whole games: one engine process stays open, and at every move I get both the move and the score, with the options set once.

A subcommand would also work, it would just mean starting a new process for every position, which would make my runs around 33% slower.

I can change it to a subcommand if you prefer though.

@edre

edre commented Oct 15, 2026

Copy link
Copy Markdown
Owner

That seems like a reasonable reason to put this in a uhp extension over a command line subcommand. Since this seems a little duplicative of the various bestmove options, maybe we could make this a separate command that returns the score of the last bestmove, similar to how pv works?

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