]> git.sesse.net Git - stockfish/log
stockfish
6 years agoUpdate travis CI to g++7
Marco Costalba [Sun, 11 Feb 2018 11:25:48 +0000 (12:25 +0100)]
Update travis CI to g++7

Use newer g++ 7 instead of 6 in travis CI tests.

No functional change.

6 years agoIntroduce dynamic contempt
Stefano Cardanobile [Fri, 9 Feb 2018 17:43:53 +0000 (18:43 +0100)]
Introduce dynamic contempt

Make contempt dependent on the current score of the root position.

The idea is that we now use a linear formula like the following to decide
on the contempt to use during a search :

    contempt = x + y * eval

where x is the base contempt set by the user in the "Contempt" UCI option,
and y * eval is the dynamic part which adapts itself to the estimation of
the evaluation of the root position returned by the search. In this patch,
we use x = 18 centipawns by default, and the y * eval correction can go
from -20 centipawns if the root eval is less than -2.0 pawns, up to +20
centipawns when the root eval is more than 2.0 pawns.

To summarize, the new contempt goes from -0.02 to 0.38 pawns, depending if
Stockfish is losing or winning, with an average value of 0.18 pawns by default.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 110052 W: 24614 L: 23938 D: 61500
http://tests.stockfishchess.org/tests/view/5a72e6020ebc590f2c86ea20

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 16470 W: 2896 L: 2705 D: 10869
http://tests.stockfishchess.org/tests/view/5a76c5b90ebc5902971a9830

A second match at LTC was organised against the current master:

ELO: 1.45 +-2.9 (95%) LOS: 84.0%
Total: 19369 W: 3350 L: 3269 D: 12750
http://tests.stockfishchess.org/tests/view/5a7acf980ebc5902971a9a2e

Finally, we checked that there is no apparent problem with multithreading,
despite the fact that some threads might have a slightly different contempt
level that the main thread.

Match of this version against master, both using 5 threads, time control 30+0.3:
ELO: 2.18 +-3.2 (95%) LOS: 90.8%
Total: 14840 W: 2502 L: 2409 D: 9929
http://tests.stockfishchess.org/tests/view/5a7bf3e80ebc5902971a9aa2

Include suggestions from Marco Costalba, Aram Tumanian, Ronald de Man, etc.

Bench: 5207156

6 years agoRetire "Extra thinking before accepting draw PVs"
Leonid Pechenik [Tue, 6 Feb 2018 10:14:55 +0000 (05:14 -0500)]
Retire "Extra thinking before accepting draw PVs"

This patch simplifies the time management code, removing the extra
thinking time for moves with draw PV and increasing thinking time
for all moves proportionally by around 4%.

Last time when the time management was carefully tuned was 1.5-2 years
ago. As new patches were getting added, time management was drifting out
of optimum. This happens because when search becomes more precise pv and
score are becoming more stable, there are less fail lows, best move is
picked earlier and there are less best move changes. All this factors are
entering in time management, and average time per move is decreasing with
more and more good patches. For individual patches such effect is small
(except some) and may be up or down, but when there are many of them,
effect is more substantial. The same way benchmark with more and more
patches is slowly drifting down on average.

So my understanding that back in October adding more think time for draw
PV showed positive Elo because time management was not well tuned, there
was more time available, and think_hard patch applied this additional time
to moves with draw PV, while just retuning back to optimum would recover Elo
anyway. It is possible that absence of contempt also helped, as SF9 is showing
less 0.0 scores than the October version.

Anyway, to me it seems that proper place to deal with draw PV is search, and
contempt sounds as much better solution. In time management there is little
additional elo, and if some code is not helping like removed here, it is better
to discard it. It is simpler to find genuine improvement if code is clean.

• Passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 20487 W: 4558 L: 4434 D: 11495
http://tests.stockfishchess.org/tests/view/5a7706ec0ebc5902971a9854

• Passed LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 41960 W: 7145 L: 7058 D: 27757
http://tests.stockfishchess.org/tests/view/5a778c830ebc5902971a9895

• Passed an additional non-regression [-5..0] test at the time control
of 60sec for the game (sudden death) with disabled draw adjudication:
LLR: 2.95 (-2.94,2.94) [-5.00,0.00]
Total: 8438 W: 1675 L: 1586 D: 5177
http://tests.stockfishchess.org/tests/view/5a7c3d8d0ebc5902971a9ac0

• Passed an additional non-regression [-5..0] test at the time control
of 1sec+1sec per move with disabled draw adjudication:
LLR: 2.97 (-2.94,2.94) [-5.00,0.00]
Total: 27664 W: 5575 L: 5574 D: 16515
http://tests.stockfishchess.org/tests/view/5a7c3e820ebc5902971a9ac3

This is a functional change for the time management code.

Bench: 4983414

6 years agoFix bug for 'eval' command in terminal
Stéphane Nicolet [Fri, 9 Feb 2018 00:10:27 +0000 (01:10 +0100)]
Fix bug for 'eval' command in terminal

The 'eval' debugging command in Terminal did not initialize the Eval::Contempt
variable, leading to random output during debugging sessions (normal search
was unaffected by the bug).

Example of session where the two 'eval' commands should give the same output,
but did not:

./stockfish
position startpos
d
eval
go depth 20
d
eval

The bug is fixed by initializing Eval::Contempt to SCORE_ZERO in Eval::trace

No functional change.

6 years agoA combo of 3 successful tuning patches
FauziAkram [Thu, 8 Feb 2018 14:13:26 +0000 (15:13 +0100)]
A combo of 3 successful tuning patches

Shelter Weakness by Fauzi Akram Dabat
Threats by Alain Savard
Passed Pawns by Alain Savard

STC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 51378 W: 11592 L: 11223 D: 28563
http://tests.stockfishchess.org/tests/view/5a79e2fe0ebc5902971a99d1

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 21631 W: 3888 L: 3661 D: 14082
http://tests.stockfishchess.org/tests/view/5a7aefe80ebc5902971a9a39

Bench: 4983414

6 years agoObey skipQuiets strictly in MovePicker
protonspring [Thu, 8 Feb 2018 09:45:45 +0000 (10:45 +0100)]
Obey skipQuiets strictly in MovePicker

The current logic in master is to continue return quiet moves if their
history score is above 0. It appears as though this check can be
removed, which is also more logically consistent with the “skipQuiets”
semantics used in search.cpp.

This patch may open new opportunitiesto get Elo by changing or
tuning the definition of 'moveCountPruning' in line 830 of search.cpp,
because obeying skipQuiets without checking the history scores makes
the search more sensitive to 'moveCountPruning'.

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 34780 W: 7680 L: 7584 D: 19516
http://tests.stockfishchess.org/tests/view/5a79f8d80ebc5902971a99db

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 38757 W: 6732 L: 6641 D: 25384
http://tests.stockfishchess.org/tests/view/5a7afebe0ebc5902971a9a46

Bench 4954595

6 years agoMore robust bench extraction
Joost VandeVondele [Wed, 7 Feb 2018 00:26:46 +0000 (01:26 +0100)]
More robust bench extraction

Allow travis.yml to recognize a variety of bench formats in commit messages, for instance:

Bench: 5023593. (really).
bench: 5023593 (it was 1234567)
bench : 5023593 (blah blah)
Bench:5023593
Bench: 5023593. 567 something (1234567) 563

No functional change.

6 years agoEnable LTO for clang
syzygy1 [Mon, 5 Feb 2018 23:43:29 +0000 (00:43 +0100)]
Enable LTO for clang

Enable link-time optimization in the Makefile when compiling with clang.
Also update travis.yml to use clang++-5.0 and llvm-5.0-dev.

No functional change.

6 years ago Don’t score and sort all captures in RECAPTURES stage.
protonspring [Mon, 5 Feb 2018 16:27:59 +0000 (17:27 +0100)]
Don’t score and sort all captures in RECAPTURES stage.

    For these recaptures, we’re are only considering those captures
    that recapture the recapture square (small portion of all the
    captures). Therefore, scoring all of the captures and pick_besting
    out of the whole group is not necessary.

    STC
    LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
    Total: 85583 W: 18978 L: 18983 D: 47622
    http://tests.stockfishchess.org/tests/view/5a717faa0ebc590f2c86e9a7

    LTC
    LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
    Total: 20231 W: 3533 L: 3411 D: 13287
    http://tests.stockfishchess.org/tests/view/5a73ad330ebc5902971a96ba

    Bench: 5023593

6 years agoRevert "Implement old 'multipv' search"
Stéphane Nicolet [Sun, 4 Feb 2018 20:42:56 +0000 (21:42 +0100)]
Revert "Implement old 'multipv' search"

This revert the following commit:
https://github.com/official-stockfish/Stockfish/commit/44a7db0f9ac02d2461aff39e25f1ac9107ffbfac

Bug report by Ronald de Man in issue:
https://github.com/official-stockfish/Stockfish/issues/1392

Bench: 5023629

6 years agoSimplify qsearch stages in MovePicker
protonspring [Sun, 4 Feb 2018 13:57:57 +0000 (14:57 +0100)]
Simplify qsearch stages in MovePicker

The difference between QCAPTURES_1 and QCAPTURES_2 quiescence search stages
boils down to a simple check of depth. The way it's being done now is
unnecessarily complex.

This patch is simpler, clearer, and easier to understand.

Passed SPRT[-3..1] test at STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 99755 W: 22158 L: 22192 D: 55405
http://tests.stockfishchess.org/tests/view/5a71f41c0ebc590f2c86e9cb

No functional change.

6 years agoImplement 'old' multipv search.
joergoster [Wed, 31 Jan 2018 17:23:57 +0000 (18:23 +0100)]
Implement 'old' multipv search.

It seems to be a waste of time to loop through all remaining root moves
after finishing each PV line. This patch skips this until we have reached
the last PV line (this is the way it was done in Glaurung and very early
versions of Stockfish).

No functional change in Single PV mode.

MultiPV=3 STC and LTC tests
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 3113 W: 1248 L: 1064 D: 801

LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 2260 W: 848 L: 679 D: 733

Bench: 5023629

6 years agoRestore development version
Stéphane Nicolet [Sun, 4 Feb 2018 01:08:09 +0000 (02:08 +0100)]
Restore development version

No functional change.

6 years agoImproved spelling, grammar and comment
Stéphane Nicolet [Sat, 3 Feb 2018 23:13:56 +0000 (00:13 +0100)]
Improved spelling, grammar and comment

Author: Ben Koshy

No functional change

6 years agoStockfish 9
mstembera [Wed, 31 Jan 2018 10:41:09 +0000 (02:41 -0800)]
Stockfish 9

Official release version of Stockfish 9

Bench 5023629

6 years agoRetire lever (#1378)
Torsten Franz [Tue, 30 Jan 2018 08:40:56 +0000 (09:40 +0100)]
Retire lever (#1378)

Retire the lever bonus from pawns evaluation

STC: http://tests.stockfishchess.org/tests/view/5a6aef5c0ebc590d945d59c8
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 88290 W: 19549 L: 19560 D: 49181

LTC: http://tests.stockfishchess.org/tests/view/5a6b70140ebc590d945d59f7
LLR: 3.22 (-2.94,2.94) [-3.00,1.00]
Total: 104603 W: 18105 L: 18108 D: 68390

Bench 5023629

6 years agoLimit the king distance factor when evaluating passed pawns (#1373)
Rocky640 [Sun, 28 Jan 2018 13:56:45 +0000 (08:56 -0500)]
Limit the king distance factor when evaluating passed pawns (#1373)

Limit the king distance factor when evaluating passed pawns
Passed STC
http://tests.stockfishchess.org/tests/view/5a6bf7290ebc590d945d5a3a
LLR: 3.31 (-2.94,2.94) [0.00,5.00]
Total: 23987 W: 5550 L: 5281 D: 13156

and LTC
http://tests.stockfishchess.org/tests/view/5a6c57710ebc590297c36af2
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 16926 W: 3014 L: 2820 D: 11092

Bench: 5059457

6 years agoThis modifies the in-search TB probing to continue searching for a mate "behind"...
syzygy1 [Sun, 28 Jan 2018 13:40:07 +0000 (14:40 +0100)]
This modifies the in-search TB probing to continue searching for a mate "behind" a TB win (or loss). (#1285)

It does the following:

- If a TB win or loss value allows an alpha or beta cutoff, the cutoff is taken.
- Otherwise, the search of the current subtree continues. In PV nodes, the final value returned is adjusted to reflect that the position is a TB win (or loss).

The patch also fixes a potential problem caused by root_probe() and root_probe_wdl() dirtying the root-move scores.

This patch removes the limitation of current master that a mate is never found if the root position is not yet in the TBs, but the path to mate at some point enters the TBs. The patch is intended to preserve the efficiency and effectiveness of the current TB probing approach.

No functional change (withouth TB)

6 years agoTop CPU Contributors as of January 2018 (#1367)
mibere [Wed, 24 Jan 2018 15:54:04 +0000 (16:54 +0100)]
Top CPU Contributors as of January 2018 (#1367)

No functional change.

6 years agoContempt 20
Stéphane Nicolet [Mon, 22 Jan 2018 11:59:00 +0000 (12:59 +0100)]
Contempt 20

Set the default contempt value of Stockfish to 20 centipawns.

The contempt feature of Stockfish tries to prevent the engine from
simplifying the position too quickly when it feels that it is very
slightly behind, instead keeping the tension a little bit longer.

Various tests in November 2017 have proved that our current imple-
mentation works well against SF7 (which is about 130 Elo weaker than
current master) and than the Elo gain is an increasing function of
contempt, going (against SF7) from +0 Elo when contempt is set at
zero centipawns, to +30 Elo when contempt is 40 centipawns.

See pull request 1325 for details:

https://github.com/official-stockfish/Stockfish/pull/1325

This november discussion left open the decision of which "default"
value for contempt we should use for Stockfish, taking into account
the various uses ofStockfish (opening preparation for humans, computer
online tournaments,analysis tool for web pages, human/computer play,
etc).

This pull request proposes to set the default contempt value of SF
to twenty centipawns, which turns out to be the highest value which
is not a regression against current master, as this seemed to be a
good compromise between risk and safety. A couple of SPRT[-3..1]
tests were done to bisect this value:

Contempt 10: http://tests.stockfishchess.org/tests/view/5a5d42d20ebc5902977e2901 (PASSED)
Contempt 15: http://tests.stockfishchess.org/tests/view/5a5d41740ebc5902977e28fa (PASSED)
Contempt 20: http://tests.stockfishchess.org/tests/view/5a5d42060ebc5902977e28fc (PASSED)
Contempt 25: http://tests.stockfishchess.org/tests/view/5a5d433f0ebc5902977e2904 (FAILED)

Surprisingly, a test at "very long time control" hinted that using
contempt 20 is not only be non-regressive against contempt 0, but
may actually exhibit some small Elo gain, giving a likehood of superio-
rity of 88.7% after 8500 games:

VLTC:
ELO: 2.28 +-3.7 (95%) LOS: 88.7%
Total: 8521 W: 1096 L: 1040 D: 6385
http://tests.stockfishchess.org/tests/view/5a60b2820ebc590297b9b7e0

Finally, there was some concerns that a contempt value of 20 would
be worse than a value of 7, but a test with 20000 games at STC was
neutral:

STC:
ELO: 0.45 +-3.1 (95%) LOS: 61.2%
Total: 20000 W: 4222 L: 4196 D: 11582
http://tests.stockfishchess.org/tests/view/5a64d2fd0ebc590297903868

See the comments in pull request 1361 for the long, nice discussion
(180 entries :-)) leading to the decision to propose contempt 20 as
the default value:

https://github.com/official-stockfish/Stockfish/pull/1361

Whether Stockfish should strictly adhere to the Komodo and Houdini
semantics and add the UCI commands to force the contempt to be White
in the so-called "analysis mode" is still under discussion, and may
be or may not be the object of a future commit.

Bench: 5783344

6 years agoMake razor margin depth independent
Tom Vijlbrief [Tue, 16 Jan 2018 07:21:41 +0000 (08:21 +0100)]
Make razor margin depth independent

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 37171 W: 6680 L: 6587 D: 23904

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 11632 W: 1574 L: 1442 D: 8616

bench: 5098576

6 years agoSimplify away redundant SEE pruning condition (#1363)
Fabian Fichter [Tue, 23 Jan 2018 13:05:48 +0000 (14:05 +0100)]
Simplify away redundant SEE pruning condition (#1363)

SEE immediately returns true for promotions,
so excluding them before checking SEE is redundant.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 56758 W: 10166 L: 10106 D: 36486
http://tests.stockfishchess.org/tests/view/5a645eaf0ebc590297903833

No functional change.

6 years agoFix bench number
Marco Costalba [Sat, 13 Jan 2018 08:21:23 +0000 (09:21 +0100)]
Fix bench number

Incorrect bench number in master. Fix it.

bench: 4971497

6 years agoSimplify verification search (#1362)
Günther Demetz [Sat, 13 Jan 2018 08:01:23 +0000 (09:01 +0100)]
Simplify verification search (#1362)

1. avoid recursive call of verification.
   For the interested side to move recursion makes no sense.
   For the other side it could make sense in case of mutual zugzwang,
   but I was not able to figure out any concrete problematic position.
   Allows the removal of 2 local variables.

2. avoid further reduction by removing R += ONE_PLY;

Benchmark with zugzwang-suite (see #1338), max 45 secs per position:
Patch  solves 33 out of 37
Master solves 31 out of 37

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 76188 W: 13866 L: 13840 D: 48482
http://tests.stockfishchess.org/tests/view/5a5612ed0ebc590297da516c

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40479 W: 5247 L: 5152 D: 30080
http://tests.stockfishchess.org/tests/view/5a56f7d30ebc590299e4550e

bench: 5340015

6 years agoRevert to old time management (#1351)
IIvec [Sat, 13 Jan 2018 07:59:20 +0000 (08:59 +0100)]
Revert to old time management (#1351)

As many users reported some problems with new time management,
and recent tests on longer time controls

http://tests.stockfishchess.org/tests/view/5a460e160ebc590ccbb8c35d
http://tests.stockfishchess.org/tests/view/5a462f4d0ebc590ccbb8c37a

are even little in favor of old time management, this revert seems as a logical step.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 14060 W: 2562 L: 2430 D: 9068

LTC:
LLR: 3.44 (-2.94,2.94) [-3.00,1.00]
Total: 31611 W: 3958 L: 3827 D: 23826

bench: 5365777 (same as master)

6 years agoUse mobility in kingsafety (#1360)
mbootsector [Sat, 13 Jan 2018 07:56:42 +0000 (08:56 +0100)]
Use mobility in kingsafety (#1360)

Use mobility in kingsafety

STC: http://tests.stockfishchess.org/tests/view/5a55134d0ebc590296938a28
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 32651 W: 6057 L: 5792 D: 20802

LTC: http://tests.stockfishchess.org/tests/view/5a5618f40ebc590297da516f
LLR: 2.94 (-2.94,2.94) [0.00,5.00]
Total: 17875 W: 2421 L: 2245 D: 13209

bench: 5365777

6 years agoRemove ThreatByHangingPawn bonus (#1356)
hxim [Thu, 4 Jan 2018 21:31:30 +0000 (22:31 +0100)]
Remove ThreatByHangingPawn bonus (#1356)

* no ThreatByHangingPawn

* bench: 4919682

6 years agoNew Year 2018
Joost VandeVondele [Mon, 1 Jan 2018 09:33:07 +0000 (10:33 +0100)]
New Year 2018

Adjust copyright headers.

No functional change.

6 years agoExplicitly zero TT upon resize.
Joost VandeVondele [Mon, 1 Jan 2018 09:10:41 +0000 (10:10 +0100)]
Explicitly zero TT upon resize.

as discussed in issue #1349, the way pages are allocated with calloc might imply some overhead on first write.
This overhead can be large and slow down the first search after a TT resize significantly, especially for large TT.
Using an explicit clear of the TT on resize fixes this problem.

Not implemented, but possibly useful for large TT, is to do this zero-ing using all search threads. Not only would this be faster, it could also lead to a more favorable memory allocation on numa systems with a first touch policy.

No functional change.

6 years agoInclude x-ray attacks through all queens independently of the color.
Guenther Demetz [Fri, 22 Dec 2017 10:50:09 +0000 (11:50 +0100)]
Include x-ray attacks through all queens independently of the color.

When calculating attacks from rooks/bishops current master includes
x-rays through own queen. This patch includes also x-rays through
opponent queen.

Credits go to Brian who inspired for this idea
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/Z3APRYpQeMU

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 41549 W: 7544 L: 7244 D: 26761
Elo 2.05 [-0.29,4.19] (95%)
http://tests.stockfishchess.org/tests/view/5a3b5fe50ebc590ccbb8bf9a

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 110010 W: 14208 L: 13739 D: 82063
Elo 1.20 [-0.27,2.55] (95%)
http://tests.stockfishchess.org/tests/view/5a3b8e7c0ebc590ccbb8bfad

bench: 5544445

6 years agoUpon changing the number of threads, make sure all threads are bound
Joost VandeVondele [Tue, 26 Dec 2017 09:40:42 +0000 (10:40 +0100)]
Upon changing the number of threads, make sure all threads are bound

The heuristic to avoid thread binding if less than 8 threads are requested resulted in the first 7 threads not being bound.
The branch was verified to yield a roughly 13% speedup by @CoffeeOne on the appropriate hardware and OS, and an earlier version of this patch tested well on his machine:

http://tests.stockfishchess.org/tests/view/5a3693480ebc590ccbb8be5a
ELO: 9.24 +-4.6 (95%) LOS: 100.0%
Total: 5000 W: 634 L: 501 D: 3865

To make sure all threads (including mainThread) are bound as soon as the total number exceeds 7, recreate all threads on a change of thread number.
To do this, unify Threads::init, Threads::exit and Threads::set are unified in a single Threads::set function that goes through the needed steps.
The code includes several suggestions from @joergoster.

Fixes issue #1312

No functional change

6 years agoAllow for general transposition table sizes. (#1341)
Joost VandeVondele [Mon, 18 Dec 2017 15:32:21 +0000 (16:32 +0100)]
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

6 years agoEnhanced verify search (#1338)
Günther Demetz [Mon, 18 Dec 2017 15:30:27 +0000 (16:30 +0100)]
Enhanced verify search (#1338)

by disabling null-move-pruning for the side to move for first part of
the remaining search tree. This helps to better recognize zugzwang.

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 18220 W: 3379 L: 3253 D: 11588
http://tests.stockfishchess.org/tests/view/5a2fa6460ebc590ccbb8bc2f

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 41899 W: 5359 L: 5265 D: 31275
http://tests.stockfishchess.org/tests/view/5a2fcf440ebc590ccbb8bc47

For further detail see commit notes and discussion at
https://github.com/pb00068/Stockfish/commit/6401a80ab91df5c54390ac357409fef2e51ff5bb

bench: 5776193

6 years agoRemove QueenMinorsImbalance array #1340
Gontran Lemaire [Fri, 1 Dec 2017 22:02:45 +0000 (22:02 +0000)]
Remove QueenMinorsImbalance array #1340

Remove QMI array and adjust bishop, knight and queen coefficients
in QuadraticOurs and QuadraticTheirs arrays in compensation of
this removal.

STC : http://tests.stockfishchess.org/tests/view/5a21d8350ebc590ccbb8b5fe
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 49659 W: 9029 L: 8957 D: 31673

LTC : http://tests.stockfishchess.org/tests/view/5a33c0dd0ebc590ccbb8bd7e
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 45905 W: 5834 L: 5745 D: 34326

Bench: 5176807

6 years agoMake staticEval independent of the search path
Joost VandeVondele [Sun, 10 Dec 2017 15:46:57 +0000 (16:46 +0100)]
Make staticEval independent of the search path

Current master can yield different staticEvals depending on the path
used to reach the position. The reason for this is that the evaluation after a
null move is always computed subtracting 2 * Eval::Tempo, while this is not
the case for lazy or specialized evals. This patch always adds tempo to evals,
which doesn't affect playing strength:

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 59911 W: 7616 L: 7545 D: 44750

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 104947 W: 18897 L: 18919 D: 67131

Fixes issue #1335

Bench: 5208264

6 years agoSimplify other checks (#1337)
Rocky640 [Sun, 17 Dec 2017 07:50:45 +0000 (02:50 -0500)]
Simplify other checks (#1337)

Replace an intricate definition with a more natural one.

Master was excluding squares occupied by a pawn which was blocked by a pawn.
This version excludes any squares occupied by a pawn which is blocked by "something"

Passed STC
http://tests.stockfishchess.org/tests/view/5a2f557b0ebc590ccbb8bc0d
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 44211 W: 8009 L: 7928 D: 28274

and LTC
http://tests.stockfishchess.org/tests/view/5a301d440ebc590ccbb8bc80
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 31958 W: 4108 L: 4002 D: 23848

Bench 5000136

6 years agoSimplify other checks #1334
Alain SAVARD [Sun, 10 Dec 2017 15:13:28 +0000 (10:13 -0500)]
Simplify other checks #1334

Simplify the other check penalty computation. Compared to current master,

a) it uses a 143 kingDanger penalty instead of S(10, 10) for the "otherCheck"
(credits to ElbertoOne for finding a suitable kingDanger range to replace the score
and to Guardian for showing this could also be a neutral change at LTC).
This makes our king safety model more consistent and simpler.

b) it might also score more than one "otherCheck" penalty for a given piece type instead of just one

c) it might score many pinned penalties instead of just one.

d) It also remove 3 conditionals and uses simpler expressions.
So it was tested as a SPRT[-3, 1]

Passed STC
http://tests.stockfishchess.org/tests/view/5a2b560b0ebc590ccbb8ba6b
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 11705 W: 2217 L: 2080 D: 7408

And LTC
http://tests.stockfishchess.org/tests/view/5a2bfd0d0ebc590ccbb8bab0
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 26812 W: 3575 L: 3463 D: 19774

Trying to improve on b) another attempt was made to score also the
"otherchecks" for piece types which had some safe checks, but this
failed STC http://tests.stockfishchess.org/tests/view/5a2c79e60ebc590ccbb8badd

bench: 5149133

6 years agoAdd Resources to understand code base (#1332)
Ben Koshy [Sun, 10 Dec 2017 12:46:43 +0000 (23:46 +1100)]
Add Resources to understand code base (#1332)

No functional change.

6 years agoDon't consider defending queen as check blocker (#1328)
Günther Demetz [Wed, 6 Dec 2017 13:23:41 +0000 (14:23 +0100)]
Don't consider defending queen as check blocker (#1328)

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 22636 W: 4212 L: 3990 D: 14434
http://tests.stockfishchess.org/tests/view/5a2506140ebc590ccbb8b75a

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 63448 W: 8287 L: 7965 D: 47196
http://tests.stockfishchess.org/tests/view/5a253a610ebc590ccbb8b776

bench: 5767699

6 years agoA better contempt implementation for Stockfish (#1325)
Stéphane Nicolet [Tue, 5 Dec 2017 06:25:42 +0000 (07:25 +0100)]
A better contempt implementation for Stockfish (#1325)

* A better contempt implementation for Stockfish

The round 2 of TCEC season 10 demonstrated the benefit of having a nice contempt implementation: it gives the strongest programs in the tournament the ability to slow down the game when they feel the position is slightly worse, prefering to stay in a complicated (even if slightly risky) middle game rather than simplifying by force into a drawn endgame.

The current contempt implementation of Stockfish is inadequate, and this patch is an attempt to provide a better one.

Passed STC non-regression test against master:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 83360 W: 15089 L: 15075 D: 53196
http://tests.stockfishchess.org/tests/view/5a1bf2de0ebc590ccbb8b370

This contempt implementation is showing promising results in certains situations. For instance, it obtained a nice +30 Elo gain when playing with contempt=40 against Stockfish 7, compared to current master:

• master against SF 7 (20000 games at LTC): +121.2 Elo
• this patch with contempt=40 (20000 games at LTC): +154.11 Elo

This was the result of real cooperative work from the Stockfish team, with key ideas coming from Stefan Geschwentner (locutus2) and Chris Cain (ceebo) while most of the community helped with feedback and computer time.

In this commit the bench is unchanged by default, but you can test at home with the new contempt in the UCI options. The style of play will change a lot when using contempt different of zero (I repeat: not done in this version by default, however)!

The Stockfish team is still deliberating over the best default contempt value in self-play and the best contempt modeling strategy, to help users choosing a contempt value when playing against much weaker programs. These informations will be given in future commits when available :-)

Bench: 5051254

* Remove the prefetch

No functional change.

6 years agoPawn endgames directly skip early pruning.
Joost VandeVondele [Sun, 3 Dec 2017 11:49:02 +0000 (12:49 +0100)]
Pawn endgames directly skip early pruning.

Instead of checking individual steps. Idea by @Stefano80.

passed STC
http://tests.stockfishchess.org/tests/view/5a23e5d20ebc590ccbb8b6d5
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 37445 W: 6866 L: 6773 D: 23806

passed LTC
http://tests.stockfishchess.org/tests/view/5a24260c0ebc590ccbb8b716
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 38780 W: 4946 L: 4848 D: 28986

Bench: 5466219

6 years agoAvoid warnings by the Clang compiler
Stéphane Nicolet [Mon, 4 Dec 2017 16:01:17 +0000 (17:01 +0100)]
Avoid warnings by the Clang compiler

Clang gave a couple of warnings for unused parameters after the recnet commit "Use constexpr when makes sense".

No functional change.

6 years agoUse a Direction enum for Square deltas
syzygy1 [Mon, 4 Dec 2017 16:52:31 +0000 (17:52 +0100)]
Use a Direction enum for Square deltas

Currently the NORTH/WEST/SOUTH/EAST values are of type Square, but conceptually they are not squares but directions. This patch separates these values into a Direction enum and overloads addition and subtraction to allow adding a Square to a Direction (to get a new Square).

I have also slightly trimmed the possible overloadings to improve type safety. For example, it would normally not make sense to add a Color to a Color or a Piece to a Piece, or to multiply or divide them by an integer. It would also normally not make sense to add a Square to a Square.

This is a non-functional change.

6 years agoUse bool(Bitboard b) instead of !!b (#1321)
Joost VandeVondele [Sun, 3 Dec 2017 17:29:55 +0000 (18:29 +0100)]
Use bool(Bitboard b) instead of !!b (#1321)

The idiom !!b is confusing newcomers (e.g. Stefan needs explaining here https://groups.google.com/d/msg/fishcooking/vYqnsRI4brY/Gaf60QuACwAJ).

No functional change.

6 years agoUse constexpr when makes sense
Guy Vreuls [Sun, 26 Nov 2017 03:33:34 +0000 (04:33 +0100)]
Use constexpr when makes sense

No functional change.

6 years agoCompile without exceptions
Stéphane Nicolet [Tue, 28 Nov 2017 15:50:31 +0000 (16:50 +0100)]
Compile without exceptions

Add the -fno-exceptions flag to the Makefile to avoid the unecessary exceptions support in the executable (we do not use any exception in Stockfish at the moment).

This change gives a 9.2% reduction in size for the executable binary.

Before : executable size = 376956 bytes
After: executable size = 347652 bytes

No functional change.

6 years agoMinor cleanup of search.cpp
syzygy [Sat, 25 Nov 2017 22:20:36 +0000 (23:20 +0100)]
Minor cleanup of search.cpp

Four very minor edits. Note that tte->save() uses posKey and
not pos.key() in other places.

Originally I also added a futility_move_counts() function to
make things more consistent with the futility_margin() and
reduction() functions. But then razor_margin[] should probably
also be turned into a function, etc. Maybe a good idea, maybe not.
So I did not include it.

Non functional change.

6 years agoAttack threats
Stefan Geschwentner [Sun, 3 Dec 2017 09:41:48 +0000 (10:41 +0100)]
Attack threats

Give bonus for safe attack threats from bishops and rooks on opponent queen

STC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 8629 W: 1599 L: 1438 D: 5592
http://tests.stockfishchess.org/tests/view/5a1ad4490ebc590ccbb8b30d

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 7093 W: 987 L: 846 D: 5260
http://tests.stockfishchess.org/tests/view/5a1aec5d0ebc590ccbb8b317

Bench: 5051254

6 years agoOpenBSD friendly start.
basepr1me [Thu, 16 Nov 2017 16:54:21 +0000 (09:54 -0700)]
OpenBSD friendly start.

6 years agoSimplify good/bad capture detection. bench 5336313
Stefan Geschwentner [Sat, 18 Nov 2017 15:33:37 +0000 (16:33 +0100)]
Simplify good/bad capture detection. bench 5336313

6 years agoFix comments. Bench: 5109559.
Stefano Cardanobile [Tue, 14 Nov 2017 20:16:41 +0000 (21:16 +0100)]
Fix comments. Bench: 5109559.

6 years agoSimplify away the PawnSet[] imbalance array (#1308)
Stéphane Nicolet [Sat, 18 Nov 2017 10:24:23 +0000 (11:24 +0100)]
Simplify away the PawnSet[] imbalance array (#1308)

Simplify away the PawnSet[] imbalance array

STC:
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 52977 W: 9550 L: 9484 D: 33943
http://tests.stockfishchess.org/tests/view/5a06b4780ebc590ccbb8a833

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 83717 W: 10599 L: 10559 D: 62559
http://tests.stockfishchess.org/tests/view/5a0aa36a0ebc590ccbb8aa99

Bench: 5340212

6 years agoSimplify some kingring penalties expressions
Rocky640 [Sat, 11 Nov 2017 12:37:29 +0000 (07:37 -0500)]
Simplify some kingring penalties expressions

The new "weak" expression helps simplify the safe check calculations for rooks or minors, (but the end result for all the safe checks is the exactly the same as in current master)

The only functional change is for the "outer king ring" (for example, squares f3 g3 h3 when white king is on g1). In current master, there was a 191 penalty if any of these was not defended at all.
With this pr, there is this 191 penalty if any of these is not defended at all or is only defended by a white queen.

Tested as a simplification
STC
http://tests.stockfishchess.org/tests/view/59fb03d80ebc590ccbb89fee
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 66167 W: 12015 L: 11971 D: 42181
(against master (Update Copyright year inMakefile))

LTC
http://tests.stockfishchess.org/tests/view/5a0106ae0ebc590ccbb8a55f
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 15790 W: 2095 L: 1968 D: 11727
(against master (Handle BxN trade as good capture when history scor))

same as #1296 but rebased on latest master
bench: 5109559

6 years agoAdd comments to pos.see_ge()
ceebo [Wed, 8 Nov 2017 17:21:46 +0000 (17:21 +0000)]
Add comments to pos.see_ge()

In terms of technical changes this patch eliminates the return
statements from the main loop of pos.see_ge() and replaces two conditional
computations with a single bitwise negation.

No functional change

6 years agoCapture Stat Simplification- Bench: 5363761
VoyagerOne [Thu, 9 Nov 2017 23:23:19 +0000 (18:23 -0500)]
Capture Stat Simplification- Bench:  5363761

6 years agoAlways do MaxCardinality checks.
Gian-Carlo Pascutto [Tue, 7 Nov 2017 08:26:13 +0000 (09:26 +0100)]
Always do MaxCardinality checks.

Stockfish currently relies on the "filter_root_moves" function also
having the side effect of clamping Cardinality against MaxCardinality
(the actual piece count in the tablebases). So if we skip this function,
we will end up probing in the search even without tablebases installed.

We cannot bail out of this function before this check is done, so move
the MultiPV hack a few lines below.

6 years agoSimplify Null Move Search condition
Joost VandeVondele [Wed, 8 Nov 2017 12:44:24 +0000 (13:44 +0100)]
Simplify Null Move Search condition

Removes depth condition, adjust parameters.

passed STC:
http://tests.stockfishchess.org/tests/view/5a008cbc0ebc590ccbb8a512
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 29282 W: 5317 L: 5210 D: 18755

passed LTC:
http://tests.stockfishchess.org/tests/view/5a00d8530ebc590ccbb8a541
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 26893 W: 3458 L: 3345 D: 20090

Bench: 5015773

6 years agoHandle BxN trade as good capture when history score is good
Günther Demetz [Sun, 5 Nov 2017 18:49:17 +0000 (19:49 +0100)]
Handle BxN trade as good capture when history score is good

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 19374 W: 3499 L: 3294 D: 12581
http://tests.stockfishchess.org/tests/view/59fc23f50ebc590ccbb8a0bf

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 91030 W: 11680 L: 11274 D: 68076
http://tests.stockfishchess.org/tests/view/59fc43ad0ebc590ccbb8a0d0

Bench: 5482249

6 years agoIntroduce capture history table for capture move sorting
Stefan Geschwentner [Fri, 3 Nov 2017 11:37:11 +0000 (12:37 +0100)]
Introduce capture history table for capture move sorting

Introduce capture move history table indexed by moved piece,
target square and captured piece type for sorting capture moves.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 11374 W: 2096 L: 1924 D: 7354
http://tests.stockfishchess.org/tests/view/59fac8dc0ebc590ccbb89fc5

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 24791 W: 3196 L: 3001 D: 18594
http://tests.stockfishchess.org/tests/view/59fae4d20ebc590ccbb89fd9

Bench: 5536775

6 years agoReplace easyMove with simple scheme
Joost VandeVondele [Fri, 3 Nov 2017 12:51:53 +0000 (13:51 +0100)]
Replace easyMove with simple scheme

Reduces time for a stable bestMove, giving some of the won time for the next move.

the version before the pvDraw passed both STC and LTC

passed STC:
http://tests.stockfishchess.org/tests/view/59e98d5a0ebc590ccbb896ec
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 78561 W: 13945 L: 13921 D: 50695
elo =    0.106 +-    1.445 LOS:   55.716%

passed LTC:
http://tests.stockfishchess.org/tests/view/59eb9df90ebc590ccbb897ae
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 29056 W: 3640 L: 3530 D: 21886
elo =    1.315 +-    1.982 LOS:   90.314%

This version, rebased on pvDrawPR with the obvious change, was verified again on STC:

http://tests.stockfishchess.org/tests/view/59ee104e0ebc590ccbb89899
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 19890 W: 3648 L: 3525 D: 12717
elo =    2.149 +-    2.895 LOS:   92.692%

and LTC:
http://tests.stockfishchess.org/tests/view/59f9673a0ebc590ccbb89ea0
Total             :    17966
Win               :     2273 (  12.652%)
Loss              :     2149 (  11.961%)
Draw              :    13544 (  75.387%)
Score             :   50.345%
Sensitivity       :    0.014%
2*(W-L)/(W+L)     :    5.608%

LLR  [-3.0,  1.0] :     2.95

BayesElo range    : [  -1.161,   4.876,  10.830] (DrawElo:  341.132)
LogisticElo range : [  -0.501,   2.105,   4.677]
LOS               :   94.369 %

LTC again:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 17966 W: 2273 L: 2149 D: 13544
LogisticElo range : [ -0.501, 2.105, 4.677]
LOS : 94.369 %

unchanged bench: 5234652

6 years agoUpdate Copyright year inMakefile
Cooffe [Fri, 27 Oct 2017 18:05:19 +0000 (21:05 +0300)]
Update Copyright year inMakefile

No functional change.

6 years agoExtra thinking before accepting draw PVs.
Joost VandeVondele [Fri, 20 Oct 2017 17:17:49 +0000 (19:17 +0200)]
Extra thinking before accepting draw PVs.

If the PV leads to a draw (3-fold / 50-moves) position
and we're ahead of time, think a little longer, possibly
finding a better way.

As this is most likely effective at higher draw rates,
tried speculative LTC after a yellow STC:

STC:
http://tests.stockfishchess.org/tests/view/59eb173a0ebc590ccbb8975d
LLR: -2.95 (-2.94,2.94) [0.00,5.00]
Total: 56095 W: 10013 L: 9902 D: 36180
elo =    0.688 +-    1.711 LOS:   78.425%

LTC:
http://tests.stockfishchess.org/tests/view/59eba1670ebc590ccbb897b4
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 59579 W: 7577 L: 7273 D: 44729
elo =    1.773 +-    1.391 LOS:   99.381%

bench: 5234652

6 years agoFix premature using of all available time in x/y TC
IIvec [Sun, 15 Oct 2017 14:44:29 +0000 (16:44 +0200)]
Fix premature using of all available time in x/y TC

In x/y time controls there was a theoretical possibility
to use all available time few moves before the clock will
be updated with new time. This patch fixes that issue.

Tested at 60/15 time control:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 113963 W: 20008 L: 20042 D: 73913

The test was done without adjudication rules!

Bench 5234652

6 years agoDon't filter root moves if MultiPV mode is enabled
Gian-Carlo Pascutto [Wed, 18 Oct 2017 08:25:12 +0000 (10:25 +0200)]
Don't filter root moves if MultiPV mode is enabled

A band-aid patch to workaround current TB code
limitations with multi PV.

Hopefully this will be removed after committing the
big update of TB impementation, now under discussion.

No functional change.

6 years agoAdd initiative to trace
ceebo [Sun, 22 Oct 2017 05:00:46 +0000 (06:00 +0100)]
Add initiative to trace

No functional change

6 years agoFix issue #1268
Joost VandeVondele [Wed, 11 Oct 2017 05:49:58 +0000 (07:49 +0200)]
Fix issue #1268

If the search is quit before skill.pick_best is called,
skill.best_move might be MOVE_NONE.

Ensure skill.best is always assigned anyhow.

Also retire the tricky best_move() and let the underlying
semantic to be clear and explicit.

No functional change.

6 years agoSimplify bonus for bishop on long diagonal
Alain SAVARD [Sat, 7 Oct 2017 20:35:19 +0000 (16:35 -0400)]
Simplify bonus for bishop on long diagonal

Removing 2 conditions, and increase the ThreatbyPawn to compensate.

Passed STC
http://tests.stockfishchess.org/tests/view/59dbde900ebc5916ff64be6d
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 14236 W: 2615 L: 2483 D: 9138

Passed LTC
http://tests.stockfishchess.org/tests/view/59dc26470ebc5916ff64be92
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 16552 W: 2136 L: 2010 D: 12406

Bench: 5234652

6 years agoWLDEntryPiece -> WDLEntryPiece for consistency
Niklas Fiekas [Thu, 5 Oct 2017 09:00:01 +0000 (11:00 +0200)]
WLDEntryPiece -> WDLEntryPiece for consistency

No functional change.

6 years agoGood bishops on the main diagonals
Stéphane Nicolet [Sun, 1 Oct 2017 22:41:06 +0000 (00:41 +0200)]
Good bishops on the main diagonals

Bonus in midgame for bishops on long diagonals when the central squares are not occupied by pawns.

Author: ElbertoOne

Passed STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 10801 W: 1955 L: 1786 D: 7060
http://tests.stockfishchess.org/tests/view/59cf5c1d0ebc5916ff64b9da

and LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 83978 W: 10685 L: 10303 D: 62990
http://tests.stockfishchess.org/tests/view/59cf6f6c0ebc5916ff64b9e4

Bench: 5620312

6 years agoDecrease reduction for exact PV nodes
VoyagerOne [Sat, 30 Sep 2017 14:16:28 +0000 (10:16 -0400)]
Decrease reduction for exact PV nodes

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 59004 W: 10621 L: 10249 D: 38134

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 25801 W: 3306 L: 3108 D: 19387

Bench: 5742466

6 years agoMeasure nodes after search finished.
Joost VandeVondele [Fri, 29 Sep 2017 14:39:12 +0000 (16:39 +0200)]
Measure nodes after search finished.

Only affects nmpsec in the multithreaded case.

No functional change.

6 years agoTweak statScore condition
GuardianRM [Thu, 21 Sep 2017 06:58:29 +0000 (09:58 +0300)]
Tweak statScore condition

The first change (ss->statScore >= 0) does nothing.

The second change ((ss-1)->statScore >= 0 ) has a massive change.
(ss-1)->statScore is not set until (ss-1) begins to apply LMR to moves.
So we now increase the reduction for bad quiets when our opponent is
running through the first captures and the hash move.

STC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 57762 W: 10533 L: 10181 D: 37048

LTC
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 19973 W: 2662 L: 2480 D: 14831

Bench: 5037819

6 years agoLet ss->ply denote the number of plies from the root to the current node
syzygy [Sat, 16 Sep 2017 19:49:29 +0000 (21:49 +0200)]
Let ss->ply denote the number of plies from the root to the current node

This patch lets ss->ply be equal to 0 at the root of the search.

Currently, the root has ss->ply == 1, which is less intuitive:

- Setting the rootNode bool has to check (ss-1)->ply == 0.

- All mate values are off by one: the code seems to assume that mated-in-0
  is -VALUE_MATE, mate-1-in-ply is VALUE_MATE-1, mated-in-2-ply is VALUE_MATE+2, etc.
  But the mate_in() and mated_in() functions are called with ss->ply, which is 1 in
  at the root.

- The is_draw() function currently needs to explain why it has "ply - 1 > i" instead
  of simply "ply > i".

- The ss->ply >= MAX_PLY tests in search() and qsearch() already assume that
  ss->ply == 0 at the root. If we start at ss->ply == 1, it would make more sense to
  go up to and including ss->ply == MAX_PLY, so stop at ss->ply > MAX_PLY. See also
  the asserts testing for 0 <= ss->ply && ss->ply < MAX_PLY.

The reason for ss->ply == 1 at the root is the line "ss->ply = (ss-1)->ply + 1" at
the start for search() and qsearch(). By replacing this with "(ss+1)->ply = ss->ply + 1"
we keep ss->ply == 0 at the root. Note that search() already clears killers in (ss+2),
so there is no danger in accessing ss+1.

I have NOT changed pv[MAX_PLY + 1] to pv[MAX_PLY + 2] in search() and qsearch().
It seems to me that MAX_PLY + 1 is exactly right:

- MAX_PLY entries for ss->ply running from 0 to MAX_PLY-1, and 1 entry for the
  final MOVE_NONE.

I have verified that mate scores are reported correctly. (They were already reported
correctly due to the extra ply being rounded down when converting to moves.)

The value of seldepth output to the user should probably not change, so I add 1 to it.
(Humans count from 1, computers from 0.)

A small optimisation I did not include: instead of setting ss->ply in every invocation
of search() and qsearch(), it could be set once for all plies at the start of
Thread::search(). This saves a couple of instructions per node.

No functional change (unless the search searches a branch MAX_PLY deep), so bench
does not change.

6 years agoScore unopposed weak pawns only if majors
Stéphane Nicolet [Sat, 16 Sep 2017 12:07:41 +0000 (14:07 +0200)]
Score unopposed weak pawns only if majors

Do not use the opposed flag for scoring backward and isolated pawns
in pawns.cpp, instead give a S(5,25) bonus for each opponent unopposed
weak pawns when we have a rook or a queen on the board.

STC run stopped after 113188 games:
LLR: 1.63 (-2.94,2.94) [0.00,5.00]
Total: 113188 W: 20804 L: 20251 D: 72133
http://tests.stockfishchess.org/tests/view/59b58e4d0ebc5916ff64b12e

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 66673 W: 8672 L: 8341 D: 49660
http://tests.stockfishchess.org/tests/view/59b902580ebc5916ff64b231

This is Alain Savard's idea, just with a different bonus.
Original patch there:

green STC, http://tests.stockfishchess.org/tests/view/597dcd2b0ebc5916ff64a09b
yellow LTC, http://tests.stockfishchess.org/tests/view/597ea69e0ebc5916ff64a0e6

Bench: 6259498

6 years agoHigher Move Overhead
IIvec [Wed, 6 Sep 2017 20:55:03 +0000 (22:55 +0200)]
Higher Move Overhead

This shoudl reduce time losses experienced by
users after new time management code.

Verified for no regression in very short TC (4sec + 0.1)
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 35262 W: 7426 L: 7331 D: 20505

Bench 5322108

6 years agoExtend ShelterWeakness array by dimension isKingFile
ianfab [Wed, 6 Sep 2017 06:12:32 +0000 (08:12 +0200)]
Extend ShelterWeakness array by dimension isKingFile

Use different penalties for weaknesses in the pawn shelter
depending on whether it is on the king's file or not.

STC
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 71617 W: 13471 L: 13034 D: 45112

LTC
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 48708 W: 6463 L: 6187 D: 36058

Bench: 5322108

6 years agoStreamlline reduction based on movecount
VoyagerOne [Mon, 4 Sep 2017 20:27:22 +0000 (16:27 -0400)]
Streamlline reduction based on movecount

Use MoveCount History only at quiet moves and simply reduce
reduction by one depth instead of increasing moveCount in formula.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 27511 W: 5171 L: 4919 D: 17421

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 92337 W: 12135 L: 11748 D: 68454

Bench: 6351176

6 years agoSmall simplication of see_ge()
syzygy [Sun, 3 Sep 2017 20:02:49 +0000 (22:02 +0200)]
Small simplication of see_ge()

Two simplifications:

- Remove the initialisation to 0 of occupied, which is now unnecessary.
- Remove the initial check for nextVictim == KING

If nextVictim == KING, then PieceValue[MG][nextVictim] will be 0, so that
balance >= threshold is true. So see_ge() returns true anyway.

No functional change.

6 years agoTravis CI: Make all warnings into errors
Marco Costalba [Sun, 3 Sep 2017 07:25:02 +0000 (09:25 +0200)]
Travis CI: Make all warnings into errors

Compile with -Werror flag. To make debugging easier
also show compile ourput.

This flag is enabled only in Travis CI, not in the shipped
Makefile becuase we can't test on every possible platform.

6 years agoRemove unneeded compile options.
Joost VandeVondele [Fri, 1 Sep 2017 19:24:32 +0000 (21:24 +0200)]
Remove unneeded compile options.

In light of issue #1232, a test was performed about the value of '-fno-exceptions' and a second one of the combination '-fno-exceptions -fno-rtti'. It turns out these options are can be removed without introducing slowdown.

STC for removing '-fno-exceptions'
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 13678 W: 2572 L: 2439 D: 8667

STC for removing '-fno-exceptions -fno-rtti' (current patch)
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 32557 W: 6074 L: 5973 D: 20510

No functional change.

6 years agoPrevent Stockfish from exiting if DTZ table is not present
syzygy [Sat, 2 Sep 2017 02:14:02 +0000 (04:14 +0200)]
Prevent Stockfish from exiting if DTZ table is not present

During TB initialisation, Stockfish checks for the presence of WDL
tables but not for the presence of DTZ tables. When attempting to probe
a DTZ table, it is therefore possible that the table is not present.
In that case, Stockfish should neither exit nor report an error.

To verify the bug:
$ ./stockfish
setoption name SyzygyTable value <path_to_WDL_dir>
position fen 8/8/4r3/4k3/8/1K2P3/3P4/6R1 w - -
go infinite
Could not mmap() /opt/tb/regular/KRPPvKR.rtbz
$

(On my system, the WDL tables are in one directory and the DTZ tables
in another. If they are in the same directory, it will be difficult
to trigger the bug.)

The fix is trivial: check the file descriptor/handle after opening
the file.

No functional change.

6 years agoFix a warning with MSVC
Marco Costalba [Thu, 31 Aug 2017 07:01:20 +0000 (09:01 +0200)]
Fix a warning with MSVC

warning C4244: '*=': conversion from 'double' to 'int', possible loss of data

No functional change.

6 years agoMulti-threaded search testing with valgrind
Joost VandeVondele [Thu, 31 Aug 2017 20:11:09 +0000 (22:11 +0200)]
Multi-threaded search testing with valgrind

Also check with valgrind the multi-threaded search.

On top of the fix for issue #1227 (PR #1235).

No functional change.

6 years agoFix uninitialized memory usage
Joost VandeVondele [Thu, 31 Aug 2017 07:34:32 +0000 (09:34 +0200)]
Fix uninitialized memory usage

After increasing the number of threads, the histories were not cleared,
resulting in uninitialized memory usage.

This patch fixes this by clearing threads histories in Thread c'tor as
is the idomatic way.

This fixes issue 1227

No functional change.

6 years agoAdjust moveCount history only at LMR
VoyagerOne [Tue, 29 Aug 2017 17:06:19 +0000 (13:06 -0400)]
Adjust moveCount history only at LMR

STC:
LLR: 3.32 (-2.94,2.94) [-3.00,1.00]
Total: 17584 W: 3277 L: 3131 D: 11176

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 26412 W: 3447 L: 3334 D: 19631

Bench: 5417521

6 years agoSimplify away non-normal moves in SEE
Joost VandeVondele [Fri, 25 Aug 2017 13:15:26 +0000 (15:15 +0200)]
Simplify away non-normal moves in SEE

credit goes to @mstembera for suggesting this approach.
SEE now deals with castling, promotion and en passant in a similar way.

passed STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 32902 W: 6079 L: 5979 D: 20844

passed LTC
LLR: 3.92 (-2.94,2.94) [-3.00,1.00]
Total: 110698 W: 14198 L: 14145 D: 82355

Bench: 5713905

6 years agoAppveyor: do a Debug and Release build
Marco Costalba [Tue, 22 Aug 2017 09:58:44 +0000 (11:58 +0200)]
Appveyor: do a Debug and Release build

And set x86 and x64 platforms for real.

Currently this is broken and the same binary is compiled for all platforms.

This is becuase we use a custom build step. OTH the default
build step seems not compatible with cmake generated *sln file.

No functional change.

6 years agoImprove multi-threaded mate finding
Joost VandeVondele [Fri, 18 Aug 2017 17:38:18 +0000 (19:38 +0200)]
Improve multi-threaded mate finding

If any thread found a 'mate in x' stop the search. Previously only
mainThread would do so. Requires the bestThread selection to be
adjusted to always prefer mate scores, even if the search depth is less.

I've tried to collect some data for this patch. On 30 cores, mate finding
seems 5-30% faster on average. It is not so easy to get numbers for this,
as the time to find a mate fluctuates significantly with multi-threaded runs,
so it is an average over 100 searches for the same position. Furthermore,
hash size and position make a difference as well.

Bench: 5965302

6 years agoCount all weak squares in the king ring with a single popcount
Stéphane Nicolet [Fri, 25 Aug 2017 21:50:11 +0000 (23:50 +0200)]
Count all weak squares in the king ring with a single popcount

Passed STC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 26966 W: 4993 L: 4745 D: 17228
http://tests.stockfishchess.org/tests/view/599e798a0ebc5916ff64aa8c

and LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 39570 W: 5104 L: 4857 D: 29609
http://tests.stockfishchess.org/tests/view/599ee5230ebc5916ff64aabe

Bench: 5965302

6 years agoUse moveCount history for reduction
Joost VandeVondele [Wed, 23 Aug 2017 19:00:28 +0000 (21:00 +0200)]
Use moveCount history for reduction

Use less reduction for moves with larger moveCount if your
opponent did an unexpected (== high moveCount) move in the
previous ply... unexpected moves might need unexpected answers.

passed STC:
http://tests.stockfishchess.org/tests/view/599f08cc0ebc5916ff64aace
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 9638 W: 1889 L: 1720 D: 6029

passed LTC:
http://tests.stockfishchess.org/tests/view/599f1e5c0ebc5916ff64aadc
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 28308 W: 3742 L: 3533 D: 21033

Bench: 5747429

6 years agoAvoid constructing an empty tuple in qsearch
Stéphane Nicolet [Mon, 21 Aug 2017 16:59:24 +0000 (18:59 +0200)]
Avoid constructing an empty tuple in qsearch

Avoid constructing, passing as a parameter and binding a useless empty tuple of pointers in the qsearch move picker constructor.

Also reformat the scoring function in movepicker.cpp and do some cleaning in evaluate.cpp while there.

No functional change.

6 years agoImprove appeyor build
Marco Costalba [Sun, 20 Aug 2017 13:29:11 +0000 (15:29 +0200)]
Improve appeyor build

Check bench number and do not
hard-code *.cpp file names.

No functional change.

6 years agoRestore safety margin of 60ms
lucasart [Sun, 20 Aug 2017 11:59:46 +0000 (19:59 +0800)]
Restore safety margin of 60ms

What this patch does is:
* increase safety margin from 40ms to 60ms. It's worth noting that the previous
  code not only used 60ms incompressible safety margin, but also an additional
  buffer of 30ms for each "move to go".
* remove a whart, integrating the extra 10ms in Move Overhead value instead.
  Additionally, this ensures that optimumtime doesn't become bigger than maximum
  time after maximum time has been artificially discounted by 10ms. So it keeps
  the code more logical.

Tested at 3 different time controls:

Standard 10+0.1
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 58008 W: 10674 L: 10617 D: 36717

Sudden death 16+0
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 59664 W: 10945 L: 10891 D: 37828

Tournament 40/10
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 16371 W: 3092 L: 2963 D: 10316

bench: 5479946

6 years agoFix some Clang warnings
Marco Costalba [Sat, 19 Aug 2017 12:32:31 +0000 (14:32 +0200)]
Fix some Clang warnings

Found by Clang in extra verbose mode :-)

No functional change.

6 years agoWide bench coverage
Marco Costalba [Tue, 15 Aug 2017 09:51:14 +0000 (02:51 -0700)]
Wide bench coverage

Add tests for:

- Positions with move list
- Chess960 positions

Now bench covers almost all cases, only few endgames
are still out of reach (verified with lcov)

It is a non functionality patch, but bench
changed because we added new test positions.

bench: 5479946

6 years agoRestore perft
Marco Costalba [Tue, 15 Aug 2017 08:05:22 +0000 (01:05 -0700)]
Restore perft

Rewrite perft to be placed naturally inside new
bench code. In particular we don't have special
custom code to run perft anymore but perft is
just a new parameter of 'go' command.

So user API is now changed, old style command:

$perft 5

becomes

$go perft 4

No functional change.

6 years agoRewrite benchmark
Marco Costalba [Mon, 14 Aug 2017 17:41:04 +0000 (10:41 -0700)]
Rewrite benchmark

First step in improving bench to handle
arbitrary UCI commands so to test many
more code paths.

This first patch just set the new code
structure.

No functional change.

6 years agoReformat time manager code
Marco Costalba [Fri, 18 Aug 2017 15:44:37 +0000 (08:44 -0700)]
Reformat time manager code

In particular clarify that 'sd'
parameter is used only in !movesToGo
case.

Verified with Ivan's check tool it is
equivalent to original code.

No functional change.

6 years agoCollect more corrections to optimum/maximum
Joost VandeVondele [Fri, 18 Aug 2017 07:38:27 +0000 (09:38 +0200)]
Collect more corrections to optimum/maximum

The only call site of Time.maximum() corrected by 10.
Do this directly in remaining().

Ponder increased Time.optimum by 25% in init(). Idem.
Delete unused includes.

No functional change.

6 years agoSpeed up Trevis CI
Marco Costalba [Wed, 16 Aug 2017 09:28:54 +0000 (02:28 -0700)]
Speed up Trevis CI

Avoid a couple of redundant rebuilds and compile
with 2 threads since travis gives 2vCPUs.

Also enable -O1 optimization for valgrind and
sanitizers, it should be safe withouth false
positives and it gives a very sensible speed
up, especially with valgrind.

The spee dup allow us to increase testing to
depth 10, useful for thread sanitizer.

No functional change.