2008-08-31 23:59:13 -06:00
|
|
|
/*
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
|
|
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
2016-01-02 02:43:25 -07:00
|
|
|
Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
|
2018-11-19 03:18:21 -07:00
|
|
|
Copyright (C) 2015-2019 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is free software: you can redistribute it and/or modify
|
2008-08-31 23:59:13 -06:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2008-09-01 06:05:02 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is distributed in the hope that it will be useful,
|
2008-08-31 23:59:13 -06:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2008-09-01 06:05:02 -06:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
#include <cassert>
|
2015-04-10 00:57:35 -06:00
|
|
|
#include <ostream>
|
2019-02-08 02:36:03 -07:00
|
|
|
#include <sstream>
|
2008-08-31 23:59:13 -06:00
|
|
|
|
|
|
|
#include "misc.h"
|
2015-05-06 05:24:00 -06:00
|
|
|
#include "search.h"
|
2008-08-31 23:59:13 -06:00
|
|
|
#include "thread.h"
|
2012-03-04 09:57:01 -07:00
|
|
|
#include "tt.h"
|
2014-10-26 00:09:19 -06:00
|
|
|
#include "uci.h"
|
2015-01-18 00:05:05 -07:00
|
|
|
#include "syzygy/tbprobe.h"
|
2014-11-25 16:45:28 -07:00
|
|
|
|
2009-05-10 10:58:53 -06:00
|
|
|
using std::string;
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
UCI::OptionsMap Options; // Global object
|
2010-11-21 15:28:17 -07:00
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
namespace UCI {
|
2010-11-21 15:28:17 -07:00
|
|
|
|
2012-03-05 11:24:59 -07:00
|
|
|
/// 'On change' actions, triggered by an option's value change
|
2015-10-25 01:30:07 -06:00
|
|
|
void on_clear_hash(const Option&) { Search::clear(); }
|
2014-11-29 01:22:25 -07:00
|
|
|
void on_hash_size(const Option& o) { TT.resize(o); }
|
2012-08-18 04:50:43 -06:00
|
|
|
void on_logger(const Option& o) { start_logger(o); }
|
2017-08-13 00:58:31 -06:00
|
|
|
void on_threads(const Option& o) { Threads.set(o); }
|
2015-01-18 00:05:05 -07:00
|
|
|
void on_tb_path(const Option& o) { Tablebases::init(o); }
|
2012-08-18 04:50:43 -06:00
|
|
|
|
2012-03-04 09:57:01 -07:00
|
|
|
|
2011-12-26 08:21:13 -07:00
|
|
|
/// Our case insensitive less() function as required by UCI protocol
|
2011-08-03 07:24:55 -06:00
|
|
|
bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const {
|
2015-01-18 00:00:50 -07:00
|
|
|
|
|
|
|
return std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(),
|
|
|
|
[](char c1, char c2) { return tolower(c1) < tolower(c2); });
|
2010-11-21 15:28:17 -07:00
|
|
|
}
|
2009-11-28 09:31:56 -07:00
|
|
|
|
2010-11-20 06:23:28 -07:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
/// init() initializes the UCI options to their hard-coded default values
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
void init(OptionsMap& o) {
|
2011-04-14 07:59:49 -06:00
|
|
|
|
Allow for general transposition table sizes. (#1341)
For efficiency reasons current master only allows for transposition table sizes that are N = 2^k in size, the index computation can be done efficiently as (hash % N) can be written instead as (hash & 2^k - 1). On a typical computer (with 4, 8... etc Gb of RAM), this implies roughly half the RAM is left unused in analysis.
This issue was mentioned on fishcooking by Mindbreaker:
http://tests.stockfishchess.org/tests/view/5a3587de0ebc590ccbb8be04
Recently a neat trick was proposed to map a hash into the range [0,N[ more efficiently than (hash % N) for general N, nearly as efficiently as (hash % 2^k):
https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
namely computing (hash * N / 2^32) for 32 bit hashes. This patch implements this trick and now allows for general hash sizes. Note that for N = 2^k this just amounts to using a different subset of bits from the hash. Master will use the lower k bits, this trick will use the upper k bits (of the 32 bit hash).
There is no slowdown as measured with [-3, 1] test:
http://tests.stockfishchess.org/tests/view/5a3587de0ebc590ccbb8be04
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 128498 W: 23332 L: 23395 D: 81771
There are two (smaller) caveats:
1) the patch is implemented for a 32 bit hash (so that a 64 bit multiply can be used), this effectively limits the number of clusters that can be used to 2^32 or to 128Gb of transpostion table. That's a change in the maximum allowed TT size, which could bother those using 256Gb or more regularly.
2) Already in master, an excluded move is hashed into the position key in rather simple way, essentially only affecting the lower 16 bits of the key. This is OK in master, since bits 0-15 end up in the index, but not in the new scheme, which picks the higher bits. This is 'fixed' by shifting the excluded move a few bits up. Eventually a better hashing scheme seems wise.
Despite these two caveats, I think this is a nice improvement in usability.
Bench: 5346341
2017-12-18 08:32:21 -07:00
|
|
|
// at most 2^32 clusters.
|
2018-03-18 16:38:58 -06:00
|
|
|
constexpr int MaxHashMB = Is64Bit ? 131072 : 2048;
|
2015-01-17 01:04:25 -07:00
|
|
|
|
2016-06-12 17:12:24 -06:00
|
|
|
o["Debug Log File"] << Option("", on_logger);
|
2018-11-08 18:02:24 -07:00
|
|
|
o["Contempt"] << Option(24, -100, 100);
|
Analysis Contempt combo box
This patch introduces an Analysis Contempt UCI combo box to control
the behaviour of contempt during analysis. The possible values are
Both, Off, White, Black. Technically, the engine is supposed to be in
analysis mode if UCI_AnalyseMode is set by the graphical user interface
or if the user has chosen infinite analysis mode ("go infinite").
Credits: the idea for the combo box is due to Michel Van den Bergh.
No functional change (outside analysis mode).
-----------------------------------------------------
The so-called "contempt" is an optimism value that the engine adds
to one color to avoid simplifications and keep tension in the position
during its search. It was introduced in Stockfish 9 and seemed to give
good results during the TCEC 11 tournament (Stockfish seemed to play a
little bit more actively than in previous seasons).
The patch does not change the play during match or blitz play, but gives
more options for correspondance players to decide for which color(s) they
would like to use contempt in analysis mode (infinite time). Here is a
description of the various options:
* Both : in analysis mode, use the contempt for both players (alternating)
* Off : in analysis mode, use the contempt for none of the players
* White : in analysis mode, White will play actively, Black will play passively
* Black : in analysis mode, Black will play actively, White will play passively
2018-04-18 09:30:00 -06:00
|
|
|
o["Analysis Contempt"] << Option("Both var Off var White var Black var Both", "Both");
|
2017-03-25 11:34:10 -06:00
|
|
|
o["Threads"] << Option(1, 1, 512, on_threads);
|
2015-01-17 01:04:25 -07:00
|
|
|
o["Hash"] << Option(16, 1, MaxHashMB, on_hash_size);
|
2014-09-08 07:44:25 -06:00
|
|
|
o["Clear Hash"] << Option(on_clear_hash);
|
2015-12-09 00:07:34 -07:00
|
|
|
o["Ponder"] << Option(false);
|
2014-09-08 07:44:25 -06:00
|
|
|
o["MultiPV"] << Option(1, 1, 500);
|
|
|
|
o["Skill Level"] << Option(20, 0, 20);
|
2018-01-13 00:59:20 -07:00
|
|
|
o["Move Overhead"] << Option(30, 0, 5000);
|
|
|
|
o["Minimum Thinking Time"] << Option(20, 0, 5000);
|
Tweak time management
Using a SPSA tuning session to optimize the time management
parameters.
With SPSA tuning it is not always possible to say where improvements
came from. Maybe some variables changed randomly or because result
was not sensitive enough to them. So my explanation of changes will
not be necessarily correct, but here it is.
• When decrease of thinking time was added by Joost a few months ago
if best move has not changed for several plies, one more competing
indicator was introduced for the same purpose along with increase
in score and absence of fail low at root. It seems that tuning put
relatively more importance on that new indicator what allowed to save
time.
• Some of this saved time is distributed proportionally between all
moves and some more time were given to moves when score dropped a lot
or best move changed.
• It looks also that SPSA redistributed more time from the beginning to
later stages of game via other changes in variables - maybe because
contempt made game to last longer or for whatever reason.
All of this is just small tweaks here and there (a few percentages changes).
STC (10+0.1):
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 18970 W: 4268 L: 4029 D: 10673
http://tests.stockfishchess.org/tests/view/5a9291a40ebc590297cc8881
LTC (60+0.6):
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 72027 W: 12263 L: 11878 D: 47886
http://tests.stockfishchess.org/tests/view/5a92d7510ebc590297cc88ef
Additional non-regression tests at other time controls
Sudden death 60s:
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 14444 W: 2715 L: 2608 D: 9121
http://tests.stockfishchess.org/tests/view/5a9445850ebc590297cc8a65
40 moves repeating at LTC:
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 10309 W: 1880 L: 1759 D: 6670
http://tests.stockfishchess.org/tests/view/5a9566ec0ebc590297cc8be1
This is a functional patch only for time management, but the bench
does not reflect this because it uses fixed depth search, so the number
of nodes does not change during bench.
No functional change.
2018-02-28 04:36:36 -07:00
|
|
|
o["Slow Mover"] << Option(84, 10, 1000);
|
Add support for playing in 'nodes as time' mode
When running more games in parallel, or simply when running a game
with a background process, due to how OS scheduling works, there is no
guarantee that the CPU resources allocated evenly between the two
players. This introduces noise in the result that leads to unreliable
result and in the worst cases can even invalidate the result. For
instance in SF test framework we avoid running from clouds virtual
machines because are a known source of very unstable CPU speed.
To overcome this issue, without requiring changes to the GUI, the idea
is to use searched nodes instead of time, and to convert time to
available nodes upfront, at the beginning of the game.
When nodestime UCI option is set at a given nodes per milliseconds
(npmsec), at the beginning of the game (and only once), the engine
reads the available time to think, sent by the GUI with 'go wtime x'
UCI command. Then it translates time in available nodes (nodes =
npmsec * x), then feeds available nodes instead of time to the time
management logic and starts the search. During the search the engine
checks the searched nodes against the available ones in such a way
that all the time management logic still fully applies, and the game
mimics a real one played on real time. When the search finishes,
before returning best move, the total available nodes are updated,
subtracting the real searched nodes. After the first move, the time
information sent by the GUI is ignored, and the engine fully relies on
the updated total available nodes to feed time management.
To avoid time losses, the speed of the engine (npms) must be set to a
value lower than real speed so that if the real TC is for instance 30
secs, and npms is half of the real speed, the game will last on
average 15 secs, so much less than the TC limit, providing for a
safety 'time buffer'.
There are 2 main limitations with this mode.
1. Engine speed should be the same for both players, and this limits
the approach to mainly parameter tuning patches.
2. Because npms is fixed while, in real engines, the speed increases
toward endgame, this introduces an artifact that is equivalent to an
altered time management. Namely it is like the time management gives
less available time than what should be in standard case.
May be the second limitation could be mitigated in a future with a
smarter 'dynamic npms' approach.
Tests shows that the standard deviation of the results with 'nodestime'
is lower than in standard TC, as is expected because now all the introduced
noise due the random speed variability of the engines during the game is
fully removed.
Original NIT idea by Michael Hoffman that shows how to play in NIT mode
without requiring changes to the GUI. This implementation goes a bit
further, the key difference is that we read TC from GUI only once upfront
instead of re-reading after every move as in Michael's implementation.
No functional change.
2015-03-22 14:15:44 -06:00
|
|
|
o["nodestime"] << Option(0, 0, 10000);
|
2014-09-08 07:44:25 -06:00
|
|
|
o["UCI_Chess960"] << Option(false);
|
Analysis Contempt combo box
This patch introduces an Analysis Contempt UCI combo box to control
the behaviour of contempt during analysis. The possible values are
Both, Off, White, Black. Technically, the engine is supposed to be in
analysis mode if UCI_AnalyseMode is set by the graphical user interface
or if the user has chosen infinite analysis mode ("go infinite").
Credits: the idea for the combo box is due to Michel Van den Bergh.
No functional change (outside analysis mode).
-----------------------------------------------------
The so-called "contempt" is an optimism value that the engine adds
to one color to avoid simplifications and keep tension in the position
during its search. It was introduced in Stockfish 9 and seemed to give
good results during the TCEC 11 tournament (Stockfish seemed to play a
little bit more actively than in previous seasons).
The patch does not change the play during match or blitz play, but gives
more options for correspondance players to decide for which color(s) they
would like to use contempt in analysis mode (infinite time). Here is a
description of the various options:
* Both : in analysis mode, use the contempt for both players (alternating)
* Off : in analysis mode, use the contempt for none of the players
* White : in analysis mode, White will play actively, Black will play passively
* Black : in analysis mode, Black will play actively, White will play passively
2018-04-18 09:30:00 -06:00
|
|
|
o["UCI_AnalyseMode"] << Option(false);
|
2015-01-18 00:05:05 -07:00
|
|
|
o["SyzygyPath"] << Option("<empty>", on_tb_path);
|
|
|
|
o["SyzygyProbeDepth"] << Option(1, 1, 100);
|
|
|
|
o["Syzygy50MoveRule"] << Option(true);
|
7-pieces Syzygy tablebase support
This is the first patch teaching Stockfish how to use the 7-pieces
Syzygy tablebase currently calculated by Bujun Guo (@noobpwnftw) and
Ronald de Man (@syzygy1). The 7-pieces database are so big that they
required a change in the internal format of the files (technically,
some DTZ values are 16 bits long, so this had to be stored as wide
integers in the Huffman tree).
Here are the estimated file size for the 7-pieces Syzygy files,
compared to the 151G of the 6-pieces Syzygy:
```
7.1T ./7men_testing/4v3_pawnful (ongoing, 120 of 325 sets remaining)
2.4T ./7men_testing/4v3_pawnless
2.3T ./7men_testing/5v2_pawnful
660G ./7men_testing/5v2_pawnless
117G ./7men_testing/6v1_pawnful
87G ./7men_testing/6v1_pawnless
```
Some pointers to download or recalculate the tables:
Location of original files, by Bujun Guo:
ftp://ftp.chessdb.cn/pub/syzygy/
Mirrors:
http://tablebase.sesse.net/ (partial)
http://tablebase.lichess.ovh/tables/standard/7/
Generator code:
https://github.com/syzygy1/tb/
Closes https://github.com/official-stockfish/Stockfish/pull/1707
Bench: 5591925 (No functional change if SyzygyTB is not used)
----------------------
Comment by Leonardo Ljubičić (@DragonMist)
This is an amazing achievement, generating and being able to use 7 men syzygy
on the fly. Thank you for your efforts @noobpwnftw !! Looking forward how this
will work in real life, and expecting some trade off between gaining perfect
play and slow disc Access, but once the disc speed and space is not a problem,
I expect 7 men to yield something like 30 elo at least.
-----------------------
Comment by Michael Byrne (@MichaelB7)
This definitely has a bright future. I turned off the 50 move rule (ala ICCF
new rules) for the following position: `[d]8/8/1b6/8/4N2r/1k6/7B/R1K5 w - - 0 1`
This position is a 451 ply win for white (sans the 50 move rule, this position
was identified by the generator as the longest cursed win for white in KRBN v KRB).
Now Stockfish finds it instantly (as it should), nice work 👊👍 .
```
dep score nodes time
7 +132.79 4339 0:00.00 Rb1+ Kc4 Nd6+ Kc5 Bg1+ Kxd6 Rxb6+ Kc7 Be3 Rh2 Bd4
6 +132.79 1652 0:00.00 Rb1+ Kc4 Nd2+ Kd5 Rxb6 Rxh2 Nf3 Rf2
5 +132.79 589 0:00.00 Rb1+ Kc4 Rxb6 Rxh2 Nf6 Rh1+ Kb2
4 +132.79 308 0:00.00 Rb1+ Kc4 Nd6+ Kc3 Rxb6 Rxh2
3 +132.79 88 0:00.00 Rb1+ Ka4 Nc3+ Ka5 Ra1+ Kb4 Ra4+ Kxc3 Rxh4
2 +132.79 54 0:00.00 Rb1+ Ka4 Nc3+ Ka5 Ra1+ Kb4
1 +132.7
```
2018-07-26 13:18:04 -06:00
|
|
|
o["SyzygyProbeLimit"] << Option(7, 0, 7);
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
/// operator<<() is used to print all the options default values in chronological
|
|
|
|
/// insertion order (the idx field) and in the format defined by the UCI protocol.
|
2012-03-05 11:24:59 -07:00
|
|
|
|
2011-12-26 08:21:13 -07:00
|
|
|
std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {
|
2011-01-09 07:57:18 -07:00
|
|
|
|
2014-04-01 01:39:41 -06:00
|
|
|
for (size_t idx = 0; idx < om.size(); ++idx)
|
2015-01-31 10:39:51 -07:00
|
|
|
for (const auto& it : om)
|
2015-01-18 00:00:50 -07:00
|
|
|
if (it.second.idx == idx)
|
2010-11-04 01:03:27 -06:00
|
|
|
{
|
2015-01-18 00:00:50 -07:00
|
|
|
const Option& o = it.second;
|
|
|
|
os << "\noption name " << it.first << " type " << o.type;
|
2010-11-04 01:03:27 -06:00
|
|
|
|
2018-04-18 20:16:19 -06:00
|
|
|
if (o.type == "string" || o.type == "check" || o.type == "combo")
|
2011-12-26 08:21:13 -07:00
|
|
|
os << " default " << o.defaultValue;
|
2010-11-20 06:23:28 -07:00
|
|
|
|
|
|
|
if (o.type == "spin")
|
2018-04-18 20:16:19 -06:00
|
|
|
os << " default " << int(stof(o.defaultValue))
|
|
|
|
<< " min " << o.min
|
|
|
|
<< " max " << o.max;
|
2010-11-04 01:03:27 -06:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2015-01-18 00:00:50 -07:00
|
|
|
|
2011-12-26 08:21:13 -07:00
|
|
|
return os;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2009-04-11 04:46:47 -06:00
|
|
|
|
2014-01-06 22:25:35 -07:00
|
|
|
/// Option class constructors and conversion operators
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-04-01 01:39:41 -06:00
|
|
|
Option::Option(const char* v, OnChange f) : type("string"), min(0), max(0), on_change(f)
|
2011-12-26 08:21:13 -07:00
|
|
|
{ defaultValue = currentValue = v; }
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-04-01 01:39:41 -06:00
|
|
|
Option::Option(bool v, OnChange f) : type("check"), min(0), max(0), on_change(f)
|
2011-12-26 08:21:13 -07:00
|
|
|
{ defaultValue = currentValue = (v ? "true" : "false"); }
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-04-01 01:39:41 -06:00
|
|
|
Option::Option(OnChange f) : type("button"), min(0), max(0), on_change(f)
|
2012-03-17 14:18:02 -06:00
|
|
|
{}
|
2012-03-17 03:29:33 -06:00
|
|
|
|
2018-04-18 20:16:19 -06:00
|
|
|
Option::Option(double v, int minv, int maxv, OnChange f) : type("spin"), min(minv), max(maxv), on_change(f)
|
2015-01-18 00:00:50 -07:00
|
|
|
{ defaultValue = currentValue = std::to_string(v); }
|
2008-08-31 23:59:13 -06:00
|
|
|
|
Analysis Contempt combo box
This patch introduces an Analysis Contempt UCI combo box to control
the behaviour of contempt during analysis. The possible values are
Both, Off, White, Black. Technically, the engine is supposed to be in
analysis mode if UCI_AnalyseMode is set by the graphical user interface
or if the user has chosen infinite analysis mode ("go infinite").
Credits: the idea for the combo box is due to Michel Van den Bergh.
No functional change (outside analysis mode).
-----------------------------------------------------
The so-called "contempt" is an optimism value that the engine adds
to one color to avoid simplifications and keep tension in the position
during its search. It was introduced in Stockfish 9 and seemed to give
good results during the TCEC 11 tournament (Stockfish seemed to play a
little bit more actively than in previous seasons).
The patch does not change the play during match or blitz play, but gives
more options for correspondance players to decide for which color(s) they
would like to use contempt in analysis mode (infinite time). Here is a
description of the various options:
* Both : in analysis mode, use the contempt for both players (alternating)
* Off : in analysis mode, use the contempt for none of the players
* White : in analysis mode, White will play actively, Black will play passively
* Black : in analysis mode, Black will play actively, White will play passively
2018-04-18 09:30:00 -06:00
|
|
|
Option::Option(const char* v, const char* cur, OnChange f) : type("combo"), min(0), max(0), on_change(f)
|
|
|
|
{ defaultValue = v; currentValue = cur; }
|
|
|
|
|
2018-04-18 20:16:19 -06:00
|
|
|
Option::operator double() const {
|
2012-08-18 04:50:43 -06:00
|
|
|
assert(type == "check" || type == "spin");
|
2018-04-18 20:16:19 -06:00
|
|
|
return (type == "spin" ? stof(currentValue) : currentValue == "true");
|
2012-08-18 04:50:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
Option::operator std::string() const {
|
|
|
|
assert(type == "string");
|
|
|
|
return currentValue;
|
|
|
|
}
|
|
|
|
|
2018-07-16 14:53:50 -06:00
|
|
|
bool Option::operator==(const char* s) const {
|
Analysis Contempt combo box
This patch introduces an Analysis Contempt UCI combo box to control
the behaviour of contempt during analysis. The possible values are
Both, Off, White, Black. Technically, the engine is supposed to be in
analysis mode if UCI_AnalyseMode is set by the graphical user interface
or if the user has chosen infinite analysis mode ("go infinite").
Credits: the idea for the combo box is due to Michel Van den Bergh.
No functional change (outside analysis mode).
-----------------------------------------------------
The so-called "contempt" is an optimism value that the engine adds
to one color to avoid simplifications and keep tension in the position
during its search. It was introduced in Stockfish 9 and seemed to give
good results during the TCEC 11 tournament (Stockfish seemed to play a
little bit more actively than in previous seasons).
The patch does not change the play during match or blitz play, but gives
more options for correspondance players to decide for which color(s) they
would like to use contempt in analysis mode (infinite time). Here is a
description of the various options:
* Both : in analysis mode, use the contempt for both players (alternating)
* Off : in analysis mode, use the contempt for none of the players
* White : in analysis mode, White will play actively, Black will play passively
* Black : in analysis mode, Black will play actively, White will play passively
2018-04-18 09:30:00 -06:00
|
|
|
assert(type == "combo");
|
2019-02-08 02:36:03 -07:00
|
|
|
return !CaseInsensitiveLess()(currentValue, s)
|
|
|
|
&& !CaseInsensitiveLess()(s, currentValue);
|
Analysis Contempt combo box
This patch introduces an Analysis Contempt UCI combo box to control
the behaviour of contempt during analysis. The possible values are
Both, Off, White, Black. Technically, the engine is supposed to be in
analysis mode if UCI_AnalyseMode is set by the graphical user interface
or if the user has chosen infinite analysis mode ("go infinite").
Credits: the idea for the combo box is due to Michel Van den Bergh.
No functional change (outside analysis mode).
-----------------------------------------------------
The so-called "contempt" is an optimism value that the engine adds
to one color to avoid simplifications and keep tension in the position
during its search. It was introduced in Stockfish 9 and seemed to give
good results during the TCEC 11 tournament (Stockfish seemed to play a
little bit more actively than in previous seasons).
The patch does not change the play during match or blitz play, but gives
more options for correspondance players to decide for which color(s) they
would like to use contempt in analysis mode (infinite time). Here is a
description of the various options:
* Both : in analysis mode, use the contempt for both players (alternating)
* Off : in analysis mode, use the contempt for none of the players
* White : in analysis mode, White will play actively, Black will play passively
* Black : in analysis mode, Black will play actively, White will play passively
2018-04-18 09:30:00 -06:00
|
|
|
}
|
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
|
2014-04-01 01:39:41 -06:00
|
|
|
/// operator<<() inits options and assigns idx in the correct printing order
|
|
|
|
|
2014-04-03 02:34:25 -06:00
|
|
|
void Option::operator<<(const Option& o) {
|
2014-04-01 01:39:41 -06:00
|
|
|
|
2014-04-06 02:50:27 -06:00
|
|
|
static size_t insert_order = 0;
|
2014-04-01 01:39:41 -06:00
|
|
|
|
|
|
|
*this = o;
|
2014-04-06 02:50:27 -06:00
|
|
|
idx = insert_order++;
|
2014-04-01 01:39:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
/// operator=() updates currentValue and triggers on_change() action. It's up to
|
2019-02-08 02:36:03 -07:00
|
|
|
/// the GUI to check for option's limits, but we could receive the new value
|
|
|
|
/// from the user by console window, so let's check the bounds anyway.
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2012-08-18 04:50:43 -06:00
|
|
|
Option& Option::operator=(const string& v) {
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2010-11-20 06:23:28 -07:00
|
|
|
assert(!type.empty());
|
2010-07-14 07:12:09 -06:00
|
|
|
|
2012-06-24 17:14:42 -06:00
|
|
|
if ( (type != "button" && v.empty())
|
|
|
|
|| (type == "check" && v != "true" && v != "false")
|
2018-04-18 20:16:19 -06:00
|
|
|
|| (type == "spin" && (stof(v) < min || stof(v) > max)))
|
2012-07-05 04:52:11 -06:00
|
|
|
return *this;
|
2012-06-24 17:14:42 -06:00
|
|
|
|
2019-02-08 02:36:03 -07:00
|
|
|
if (type == "combo")
|
|
|
|
{
|
|
|
|
OptionsMap comboMap; // To have case insensitive compare
|
|
|
|
string token;
|
|
|
|
std::istringstream ss(defaultValue);
|
|
|
|
while (ss >> token)
|
|
|
|
comboMap[token] << Option();
|
|
|
|
if (!comboMap.count(v) || v == "var")
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2012-06-24 17:14:42 -06:00
|
|
|
if (type != "button")
|
|
|
|
currentValue = v;
|
|
|
|
|
|
|
|
if (on_change)
|
2014-02-09 09:31:45 -07:00
|
|
|
on_change(*this);
|
2012-07-05 04:52:11 -06:00
|
|
|
|
|
|
|
return *this;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
2012-08-18 04:50:43 -06:00
|
|
|
|
|
|
|
} // namespace UCI
|