]> git.sesse.net Git - stockfish/commitdiff
Allow UCI parameters to be double
authorStéphane Nicolet <cassio@free.fr>
Thu, 19 Apr 2018 02:16:19 +0000 (04:16 +0200)
committerStéphane Nicolet <cassio@free.fr>
Mon, 23 Apr 2018 06:08:27 +0000 (08:08 +0200)
Change the operators of the Option type in uci.h to accept floating
point numbers in double precision on input as the numerical type for
the "spin" values of the UCI protocol.

The output of Stockfish after the "uci" command is unaffected.

This change is compatible with all the existing GUI (as they will
continue sending integers that we can interpret as doubles in SF),
and allows us to pass double parameters to Stockfish in the console
via the "setoption" command. This will be useful if we implement
another tuner as an alternative for SPSA.

Closes https://github.com/official-stockfish/Stockfish/pull/1556

No functional change.

---------------------

A example of the new functionality in action in the branch `tune_float2'`:
https://github.com/snicolet/Stockfish/commit/876c322d0f20ee232da977b4d3489c4cc929765e

I have added the following lines in ucioptions.cpp:

```C++

void on_pi(const Option& o)
{
      double x = Options["PI"];  // or double x = o;
      std::cerr << "received value is x = " << x << std::endl;
}

...

o["PI"]   << Option(3.1415926, -1000000010000000, on_pi);
```

Then I can change the value of Pi in Stockfish via the command line, and
check that Stockfish understands a floating point:

````
> ./stockfish
> setoption name PI value 2.7182818284

received value is x = 2.71828
````

On output, the default value of Pi is truncated to 3 (to remain compatible
with the UCI protocol and GUIs):

````
> uci

[...]
option name SyzygyProbeLimit type spin default 6 min 0 max 6
option name PI type spin default 3 min -10000000 max 10000000
uciok
````


No differences found