Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow UCI parameters to be double #1556

Closed
wants to merge 1 commit into from

Conversation

snicolet
Copy link
Member

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.

No functional change.

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.

No functional change.
@snicolet
Copy link
Member Author

snicolet commented Apr 19, 2018

A example of the new functionality in action in the branch tune_float2' : snicolet/Stockfish@876c322

I have added the following lines in ucioptions.cpp:

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, -10000000, 10000000, 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

@snicolet
Copy link
Member Author

Discussion thread on the forum for this subject:
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/XnLmUP_78iw

@snicolet snicolet closed this in 82f7d50 Apr 23, 2018
@snicolet
Copy link
Member Author

Merged via 82f7d50

@mstembera
Copy link
Contributor

This introduced the below warnings under MSVC:
\src\main.cpp(47): warning C4244: 'argument': conversion from 'double' to '::size_t', possible loss of data
\src\main.cpp(48): warning C4244: 'argument': conversion from 'double' to '::size_t', possible loss of data
\src\timeman.cpp(86): warning C4244: 'initializing': conversion from 'double' to 'TimePoint', possible loss of data
\src\timeman.cpp(87): warning C4244: 'initializing': conversion from 'double' to 'TimePoint', possible loss of data
\src\timeman.cpp(88): warning C4244: 'initializing': conversion from 'double' to 'TimePoint', possible loss of data
\src\timeman.cpp(89): warning C4244: 'initializing': conversion from 'double' to 'TimePoint', possible loss of data
\src\ucioption.cpp(40): warning C4244: 'argument': conversion from 'double' to '::size_t', possible loss of data
\src\ucioption.cpp(42): warning C4244: 'argument': conversion from 'double' to '::size_t', possible loss of data
\src\search.cpp(256): warning C4244: 'argument': conversion from 'double' to 'int', possible loss of data
\src\search.cpp(310): warning C4244: 'initializing': conversion from 'double' to '::size_t', possible loss of data
\src\search.cpp(311): warning C4244: 'argument': conversion from 'double' to 'int', possible loss of data

goodkov pushed a commit to goodkov/Stockfish that referenced this pull request Jul 21, 2018
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 official-stockfish#1556

No functional change.

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

A example of the new functionality in action in the branch `tune_float2'`:
snicolet/Stockfish@876c322

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, -10000000, 10000000, 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
````
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.

None yet

2 participants