]> git.sesse.net Git - stockfish/log
stockfish
6 years agoMark all compile-time constants as constexpr.
Ronald de Man [Sun, 18 Mar 2018 22:38:58 +0000 (23:38 +0100)]
Mark all compile-time constants as constexpr.

To more clearly distinguish them from "const" local variables, this patch
defines compile-time local constants as constexpr. This is consistent with
the definition of PvNode as constexpr in search() and qsearch(). It also
makes the code more robust, since the compiler will now check that those
constants are indeed compile-time constants.

We can go even one step further and define all the evaluation and search
compile-time constants as constexpr.

In generate_castling() I replaced "K" with "step", since K was incorrectly
capitalised (in the Chess960 case).

In timeman.cpp I had to make the non-local constants MaxRatio and StealRatio
constepxr, since otherwise gcc would complain when calculating TMaxRatio and
TStealRatio. (Strangely, I did not have to make Is64Bit constexpr even though
it is used in ucioption.cpp in the calculation of constexpr MaxHashMB.)

I have renamed PieceCount to pieceCount in material.h, since the values of
the array are not compile-time constants.

Some compile-time constants in tbprobe.cpp were overlooked. Sides and MaxFile
are not compile-time constants, so were renamed to sides and maxFile.

Non-functional change.

6 years agoFix an MSVC 2017 error and warnings.
mstembera [Fri, 16 Mar 2018 04:34:38 +0000 (21:34 -0700)]
Fix an MSVC 2017 error and warnings.

Improved version by @mcostalba.

No functional change.

6 years agoRenaming some variables in code
Stéphane Nicolet [Thu, 15 Mar 2018 09:44:26 +0000 (10:44 +0100)]
Renaming some variables in code

Implements renaming suggestions by Marco Costalba, Günther Demetz,
Gontran Lemaire, Ronald de Man, Stéphane Nicolet, Alain Savard,
Joost VandeVondele, Jerry Donald Watson, Mike Whiteley, xoto10,
and I hope that I haven't forgotten anybody.

Perpetual renaming thread for suggestions:
https://github.com/official-stockfish/Stockfish/issues/1426

No functional change.

6 years agoMake using quiescence search implicit
Joost VandeVondele [Thu, 15 Mar 2018 08:21:34 +0000 (09:21 +0100)]
Make using quiescence search implicit

If search depth is less than ONE_PLY call qsearch(), no need to check the
depth condition at various call sites of search().

Passed STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 14568 W: 3011 L: 2877 D: 8680
http://tests.stockfishchess.org/tests/view/5aa846190ebc59029781015b

Also helps gcc to find some optimizations (smaller binary, some speedup).
Thanks to Aram and Stefan for identifying an oversight in an early version.

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

No functional change.

6 years agoCheck the clock every 1024 nodes
Stéphane Nicolet [Wed, 14 Mar 2018 20:35:57 +0000 (21:35 +0100)]
Check the clock every 1024 nodes

This patch checks the clock every 1024, instead of 4096 in current master.

This is a step towards a solution to alleviate the problem reported by
Gian-Carlo Pascutto in pull request #1471, about a situation where SF
would sometimes lose on time in endgames at time control 1min+1sec when
using Syzygy EGTB on a spinning drive.

We made four tests called "Estimate the Elo cost of calling now() every
N nodes", with N in {256,1024} and time control in {STC,LTC}. Each test
was 40000 games with auto-purge off, against master branch.

http://tests.stockfishchess.org/tests/view/5aa4f37c0ebc59029780ff2d
http://tests.stockfishchess.org/tests/view/5aa4f3080ebc59029780ff2b
http://tests.stockfishchess.org/tests/view/5aa5cbb50ebc59029780ffce
http://tests.stockfishchess.org/tests/view/5aa5cb730ebc59029780ffcc

Here is a summary of the results (speed-up and Elo gain against master):

|   Time   |       N=256       |      N=1024      |
|:--------:|:-----------------:|:----------------:|
| Speed-up |    0.1% slower    |   0.2% faster    |
|   STC    |  -0.33 +-2.2 Elo  |  1.33 +-2.2 Elo  |
|   LTC    |   1.08 +-2.3 Elo  |  2.34 +-2.2 Elo  |

Based on these results, we tested N=1024 as a non-regression against
master at LTC:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 80746 W: 12430 L: 12399 D: 55917
http://tests.stockfishchess.org/tests/view/5aa7ba660ebc590297810116

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

No functional change.

6 years agoUse intrinsics only for LSB/MSB
lucasart [Sun, 11 Mar 2018 22:56:14 +0000 (06:56 +0800)]
Use intrinsics only for LSB/MSB

The NO_BSF does not cover any real life use-case today. The only compilers that
can compile SF today, with the current Makefile and no source code changes, are
either GCC compatible (define __GNUC__) or MSVC compatible (define _MSC_VER). So
they all support LSB/MSB intrinsics.

This patch simplifies away the software fall-backs of LSB/MSB that were still
in Stockfish code, but unused in any of the officially supported compilers.

Note the (legacy) MSVC/WIN32 case, where we use a 32-bit BSF/BSR solution, as
64-bit intrinsics aren't available there.

Discussed in: https://github.com/official-stockfish/Stockfish/pull/1447
and:          https://github.com/official-stockfish/Stockfish/pull/1479

No functional change.

6 years agoSimplify condition for ProbCut move count pruning
Jerry Donald Watson [Tue, 13 Mar 2018 09:15:42 +0000 (09:15 +0000)]
Simplify condition for ProbCut move count pruning

We retire depth-dependence in ProbCut move count pruning,
the move count limit condition is now : "probCutCount < 3"

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 33895 W: 6995 L: 6897 D: 20003
http://tests.stockfishchess.org/tests/view/5aa6eaba0ebc59029781009d

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28959 W: 4441 L: 4333 D: 20185
http://tests.stockfishchess.org/tests/view/5aa73dfa0ebc5902978100be

Ideas for future work:

• Is a flat move count limit in ProbCut ideal? Depth dependence, or
  dependence on some other variable, could possibly be reintroduced.

• The move count limit 3 is untuned and a better value may exist.

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

Bench: 5741807

6 years agoTweak probcut margin with 'improving' flag
Jerry Donald Watson [Tue, 13 Mar 2018 22:19:36 +0000 (23:19 +0100)]
Tweak probcut margin with 'improving' flag

Adjust ProbCut rBeta by whether the score is improving, and also
set improving to false when in check. More precisely, this patch
has two parts:

1) the increased beta threshold for ProbCut is now adjusted based
   on whether the score is improving
2) when in check, improving is always set to false.

Co-authored by Joost VandeVondele (@vondele) and Bill Henry (@VoyagerOne).

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 13480 W: 2840 L: 2648 D: 7992
http://tests.stockfishchess.org/tests/view/5aa693fe0ebc59029781004c

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 25895 W: 4099 L: 3880 D: 17916
http://tests.stockfishchess.org/tests/view/5aa6ac940ebc59029781006e

In terms of opportunities for future work opened up by this patch,
the ProbCut rBeta formula could probably be tuned to gain more Elo.

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

Bench: 5328254

6 years agoUse quiescence search for Probcut
VoyagerOne [Tue, 13 Mar 2018 07:20:20 +0000 (08:20 +0100)]
Use quiescence search for Probcut

Perform qsearch for the preliminary search in Probcut

Passed STC with sprt[-3..1] bounds:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 31090 W: 6386 L: 6283 D: 18421
http://tests.stockfishchess.org/tests/view/5aa598ed0ebc59029780ff9f

Passed LTC with sprt[0..4] bounds:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 104056 W: 15990 L: 15531 D: 72535
http://tests.stockfishchess.org/tests/view/5aa5b0f30ebc59029780ffa9

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

Bench: 5404567

6 years agoqsearch(): remove inCheck as a template parameter
Joost VandeVondele [Tue, 13 Mar 2018 07:10:59 +0000 (08:10 +0100)]
qsearch(): remove inCheck as a template parameter

Simplifies a bit, and avoids bugs as in #1478

Passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 104862 W: 21302 L: 21337 D: 62223
http://tests.stockfishchess.org/tests/view/5aa6de1b0ebc590297810097

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

No functional change

6 years agoAdjust initiative in pure pawn endgames
Jerry Donald Watson [Mon, 12 Mar 2018 09:09:02 +0000 (09:09 +0000)]
Adjust initiative in pure pawn endgames

King and pawn endgames are typically decisive, and a small
advantage is often sufficient to win. Therefore we now take
this into account when computing the initiative adjustment.

This idea came from a series of patches by Gian-Carlo Pascutto.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 48770 W: 10203 L: 9845 D: 28722
http://tests.stockfishchess.org/tests/view/5aa58cce0ebc59029780ff8d

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 22252 W: 3572 L: 3366 D: 15314
http://tests.stockfishchess.org/tests/view/5aa5b27c0ebc59029780ffad

Ideas for future developement:

- There have been a number of changes to the initiative
  calculation lately. Perhaps the coefficients could be
  tuned again.

- It may be possible to add special knowledge for other
  endgames in the initiative calculation.

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

Bench: 5750110

6 years agoMovePicker: combine countermove with killers.
protonspring [Mon, 12 Mar 2018 01:47:35 +0000 (02:47 +0100)]
MovePicker: combine countermove with killers.

Handle the countermove in the same way we use stages to progress
through the killer moves, using a common array called "refutations".
Removes some lines of code and simplifies a bit the jump table.

STC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 71707 W: 14622 L: 14595 D: 42490
http://tests.stockfishchess.org/tests/view/5aa003cf0ebc590297cb6276

LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 22320 W: 3470 L: 3352 D: 15498
http://tests.stockfishchess.org/tests/view/5aa051020ebc590297cb62ba

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

No functional change.

6 years agoConnectivity Score S(3,1) is stronger than S(2,2)
protonspring [Mon, 12 Mar 2018 00:51:12 +0000 (01:51 +0100)]
Connectivity Score S(3,1) is stronger than S(2,2)

I believe my tests were conclusive enough to demonstrate
that a connectivity score of S(3,1) is stronger than S(2,2).

STC
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 16175 W: 3386 L: 3165 D: 9624
http://tests.stockfishchess.org/tests/view/5aa48b150ebc59029780fef6

LTC
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 98685 W: 15209 L: 14765 D: 68711
http://tests.stockfishchess.org/tests/view/5aa496f50ebc59029780fefa

Bench 5601228

6 years agoImplement an old Russian proverb
protonspring [Sat, 10 Mar 2018 10:46:44 +0000 (11:46 +0100)]
Implement an old Russian proverb

"Loose pieces drop, in blitz keep everything protected"

Adding a small S(2,2) bonus for knights, bishops, rooks, and
queens that are "connected" to each other (in the sense that
they are under attack by our own pieces) apparently is a good
thing. It probably helps the pieces work together a bit better.

STC
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 12317 W: 2655 L: 2467 D: 7195
http://tests.stockfishchess.org/tests/view/5aa2d86b0ebc590297cb6474

LTC
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 35725 W: 5516 L: 5263 D: 24946
http://tests.stockfishchess.org/tests/view/5aa2fc6f0ebc590297cb64a8

How to continue from there (by Stefan Geschwentner)?

• First we should identify all other eval terms which have an overlap
  with new connectivity bonus (like the outpost bonus). A simple way
  would be subtract the connectivity bonus from them and look if this
  better, or use a SPSA session for these terms.

• Tuning Connectivity himself with SPSA seems not so promising because
  of the small range which is useful. Here manual testing changes of
  Connectivity like +-1 seems better.

• The eg value is more important because in endgame the position gets
  more open and so attacks on pieces are easier. Another important point
  is that when defending/fortress-like positions each defending piece
  needs a protection, otherwise attacks on them can break defense.

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

Bench: 5318575

6 years agoAssign improving only once
Joost VandeVondele [Sat, 10 Mar 2018 09:35:10 +0000 (10:35 +0100)]
Assign improving only once

Avoid duplicated code after recent commit "Use evaluation trend
to adjust futility margin". We initialize the improving variable
to true in the check case, which allows to avoid redundant code
in the general case.

Tested for speed by snicolet, patch seems about 0.4% faster.

No functional change.

Note: initializing the improving variable to false in the check
case was tested as a functional change, ending yellow in both STC
and LTC. This change is not included in the commit, but it is an
interesting result that could become part of a future patch about
improving or LMR. Reference of the LTC yellow test:
http://tests.stockfishchess.org/tests/view/5aa131560ebc590297cb636e

6 years agoTwo steps slider threats on queen
Alain SAVARD [Fri, 9 Mar 2018 01:04:33 +0000 (20:04 -0500)]
Two steps slider threats on queen

Allow a potential slider threat from a square currently occupied
by a harmless attacker, just as the recent "knight on queen" patch.
Also from not completely safe squares, use the mobilityArea instead
of excluding all pawns for both SlidersOnQueen and KnightOnQueen

We now compute the potential sliders threat on queen only if opponent
has one queen.

Run as SPRT [0,4] since it is some kind of simplification but maybe
not clearly one.

STC:
http://tests.stockfishchess.org/tests/view/5aa1ddf10ebc590297cb63d8
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 22997 W: 4817 L: 4570 D: 13610

LTC:
http://tests.stockfishchess.org/tests/view/5aa1fe6b0ebc590297cb63e5
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 11926 W: 1891 L: 1705 D: 8330

After this patch is committed, we may try to:

• re-introduce some "threat by queen" bonus to make Stockfish's queen
  more aggressive (attacking aspect)

• introduce a concept of "queen overload" to force the opponent queen
  into passivity and protecting duties (defensive aspect)

• more generally, re-tune the queen mobility array since patches in the
  last three months have affected a lot the location/activity of queens.

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

bench: 5788691

6 years agoSimplification: use Arctan for the optimism S-curve
IIvec [Mon, 5 Mar 2018 21:24:26 +0000 (22:24 +0100)]
Simplification: use Arctan for the optimism S-curve

This was an idea of Gontran Lemaire (gonlem), but the graphs
he published did not seem accurate to me. I did my own graphs,
got my own constants and here is the result:

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 42179 W: 8704 L: 8622 D: 24853
http://tests.stockfishchess.org/tests/view/5a9db6270ebc590297cb611b

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 17737 W: 2702 L: 2577 D: 12458
http://tests.stockfishchess.org/tests/view/5a9eb5b20ebc590297cb61b2

Note: we are now back to 70% draw rate in selfplay mode!

Bench: 5544908

6 years agoUse evaluation trend to adjust futility margin
Jerry Donald Watson [Wed, 7 Mar 2018 21:31:51 +0000 (22:31 +0100)]
Use evaluation trend to adjust futility margin

Adjust futility margin in the child node based on whether the
static evaluation is improving.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 15271 W: 3157 L: 2958 D: 9156
http://tests.stockfishchess.org/tests/view/5a9f2f8c0ebc590297cb6216

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 6617 W: 1053 L: 908 D: 4656
http://tests.stockfishchess.org/tests/view/5a9f98390ebc590297cb6241

Ideas for future work:

- Tune the new margins.
- Try to get this idea to work for futility pruning in parent
  nodes as well.

Bench: 5779242

6 years agoKnight threats on Queen
Stéphane Nicolet [Wed, 7 Mar 2018 21:12:29 +0000 (22:12 +0100)]
Knight threats on Queen

We give a S(21,11) bonus for knight threats on the next moves
against enemy queen. The threats are from squares which are
"not strongly protected" and which may be empty, contain enemy
pieces or even one of our piece at the moment (N,B,Q,R) -- hence
be two-steps threats in the later case because we will have to
move our piece and *then* attack the enemy queen with the knight.

STC: http://tests.stockfishchess.org/tests/view/5a9e442e0ebc590297cb6162
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 35129 W: 7346 L: 7052 D: 20731

LTC: http://tests.stockfishchess.org/tests/view/5a9e6e620ebc590297cb617f
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 42442 W: 6695 L: 6414 D: 29333

How to continue from there?

• Trying to refine the threat condition ("not strongly protected")
• Trying the two-steps idea for bishops or rooks threats against queen

Bench: 6051247

6 years agoRemove popcount trick from space evaluation
Torsten Franz [Mon, 5 Mar 2018 13:10:13 +0000 (14:10 +0100)]
Remove popcount trick from space evaluation

Similar removal of superposition code trick as in the
"Simplify tropism computation" patch. This simplification
of the space() function will allow us to specify space
masks which can reach into enemy territory.

passed STC:
LLR: 3.38 (-2.94,2.94) [-3.00,1.00]
Total: 184630 W: 40581 L: 40758 D: 103291
http://tests.stockfishchess.org/tests/view/5a8433360ebc590297cc80c5

passed LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 231799 W: 37647 L: 37858 D: 156294
http://tests.stockfishchess.org/tests/view/5a96a34a0ebc590297cc8cfd

No functional change.

6 years agoFix a warning in GCC for Windows
Stéphane Nicolet [Tue, 6 Mar 2018 21:11:45 +0000 (22:11 +0100)]
Fix a warning in GCC for Windows

No functional change

6 years agoCode style in Razoring and ProbCut
joergoster [Fri, 2 Mar 2018 10:38:11 +0000 (11:38 +0100)]
Code style in Razoring and ProbCut

No functional change.

6 years agoIntroduce variadic make_bitboard()
Chris Cain [Tue, 6 Mar 2018 00:32:16 +0000 (01:32 +0100)]
Introduce variadic make_bitboard()

Adds a helper function to make a bitboard from a list of squares.

No functional change

6 years agoUsing a S-curve for the optimism measure
Stefano Cardanobile [Sun, 4 Mar 2018 15:50:19 +0000 (16:50 +0100)]
Using a S-curve for the optimism measure

Add a logarithmic term in the optimism computation, increase
the maximal optimism and lower the contempt offset.

This increases the dynamics of the optimism aspects, giving
a boost for balanced positions without skewing too much on
unbalanced positions (but this version will enter panic mode
faster than previous master when behind, trying to draw faster
when slightly behind). This helps, since optimism is in general
a good thing, for instance at LTC, but too high optimism
rapidly contaminates play.

passed STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 159343 W: 34489 L: 33588 D: 91266
http://tests.stockfishchess.org/tests/view/5a8db9340ebc590297cc85b6

passed LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 47491 W: 7825 L: 7517 D: 32149
http://tests.stockfishchess.org/tests/view/5a9456a80ebc590297cc8a89

It must be mentioned that a version of the PR with contempt 0
did not pass STC [0,5]. The version in the patch, which uses
default contempt 12, was found to be as strong as current master
on different matches against SF7 and SF8, both at STC and LTC.

One drawback maybe is that it raises the draw rate in self-play
from 56% to 59%, giving a little bit less sensitivity for SF
developpers to find evaluation improvements by selfplay tests
in fishtest.

Possible further work:

• tune the values accurately, while keeping in mind the drawrate issue
• check whether it is possible to remove linear and offset term
• try to simplify the S-shape curve

Bench: 5934644

6 years agoNo extra stage for QS recaptures.
Joost VandeVondele [Tue, 27 Feb 2018 19:31:13 +0000 (20:31 +0100)]
No extra stage for QS recaptures.

remove the QRECAPTURES and QSEARCH_RECAPTURES stages as they can be
incoorporated in QCAPTURES stage with a simple condition on depth.

passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 214964 W: 46188 L: 46443 D: 122333
http://tests.stockfishchess.org/tests/view/5a98544b0ebc590297cc8e35

passed LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 14552 W: 2404 L: 2274 D: 9874
http://tests.stockfishchess.org/tests/view/5a9947b20ebc590297cc8e93

Bench: 6361582

6 years agoDo move-count pruning in probcut
VoyagerOne [Sat, 3 Mar 2018 11:03:38 +0000 (12:03 +0100)]
Do move-count pruning in probcut

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 4928 W: 1163 L: 1007 D: 2758

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 20368 W: 3441 L: 3238 D: 13689
http://tests.stockfishchess.org/tests/view/5a98bea40ebc590297cc8e5d

Bench: 6361568

6 years agoMerge Stats tables
Marco Costalba [Sat, 3 Mar 2018 10:29:29 +0000 (11:29 +0100)]
Merge Stats tables

Use a recursive std::array with variadic template
parameters to get rid of the last redundacy.

The first template T parameter is the base type of
the array, the W parameter is the weight applied to
the bonuses when we update values with the << operator,
the D parameter limits the range of updates (range is
[-W * D, W * D]), and the last parameters (Size and
Sizes) encode the dimensions of the array.

This allows greater flexibility because we can now tweak
the range [-W * D, W * D] for each table.

Patch removes more lines than what adds and streamlines
the Stats soup in movepick.h

Closes PR#1422 and PR#1421

No functional change.

6 years agoBetter indentation in Makefile
Stéphane Nicolet [Sat, 3 Mar 2018 10:07:23 +0000 (11:07 +0100)]
Better indentation in Makefile

No functional change

6 years agoReintroduce depth 2 razoring (with additional margin)
Tom Vijlbrief [Wed, 28 Feb 2018 12:41:24 +0000 (13:41 +0100)]
Reintroduce depth 2 razoring (with additional margin)

The first depth 2 margin triggers the verification quiescence search.
This qsearch() result has to be better then the second lower margin,
so we only skip the razoring when the qsearch gives a significant
improvement.

Passed STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 32133 W: 7395 L: 7101 D: 17637
http://tests.stockfishchess.org/tests/view/5a93198b0ebc590297cc8942

Passed LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 17382 W: 3002 L: 2809 D: 11571
http://tests.stockfishchess.org/tests/view/5a93b18c0ebc590297cc89c2

This Elo-gaining version was further simplified following a suggestion
of Marco Costalba:

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 15553 W: 3505 L: 3371 D: 8677
http://tests.stockfishchess.org/tests/view/5a964be90ebc590297cc8cc4

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 13253 W: 2270 L: 2137 D: 8846
http://tests.stockfishchess.org/tests/view/5a9658880ebc590297cc8cca

How to continue after this patch?

Reformating the razoring code (step 7 in search()) to unify the
depth 1 and depth 2 treatements seems quite possible, this could
possibly lead to more simplifications.

Bench: 5765806

6 years agoBlocked pawn storm
Stefan Geschwentner [Wed, 28 Feb 2018 12:00:45 +0000 (13:00 +0100)]
Blocked pawn storm

In pawn structures like white pawns f6,h6 against black pawns f7,g6,h7
the attack on the king is blocked by the own pawns. So decrease the
penalty for king safety.

See diagram and discussion in
https://github.com/official-stockfish/Stockfish/pull/1434

A sample position that this patch wants to avoid is the following
1rr2bk1/3q1p1p/2n1bPpP/pp1pP3/2pP4/P1P1B3/1PBQN1P1/1K3R1R w - - 0 1

White pawn storm on the king side was a disaster, it locked the king
side completely. Therefore, all the king tropism bonus that white have
on the king side are useless, and kingadjacent attacks too. Master
gives White a static +4.5 advantage, but White cannot win that game.
The patch is lowering this evaluation artefact.

STC:
LLR: 2.94 (-2.94,2.94) [0.00,5.00]
Total: 16467 W: 3750 L: 3537 D: 9180
http://tests.stockfishchess.org/tests/view/5a92102d0ebc590297cc87d0

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 64242 W: 11130 L: 10745 D: 42367
http://tests.stockfishchess.org/tests/view/5a923dc80ebc590297cc8806

This version includes reformatting and speed optimization by Alain Savard.

Bench: 5643527

6 years agoTweak time management
Leonid Pechenik [Wed, 28 Feb 2018 11:36:36 +0000 (12:36 +0100)]
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.

6 years agoSimplify tropism computation
Stéphane Nicolet [Tue, 27 Feb 2018 18:10:40 +0000 (19:10 +0100)]
Simplify tropism computation

Simplification. Tests show that the "shift-and-superpose" trick is no longer
necessary. The speed benefit of avoiding a popcount is no longer relevant
on modern machines.

Passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 41675 W: 9168 L: 9086 D: 23421
http://tests.stockfishchess.org/tests/view/5a840bcc0ebc590297cc80b5

Passed LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 117728 W: 19875 L: 19911 D: 77942
http://tests.stockfishchess.org/tests/view/5a8444800ebc590297cc80ca

No functional change.

6 years agoStat score initialization: grandchildren
Stefan Geschwentner [Tue, 27 Feb 2018 17:38:08 +0000 (18:38 +0100)]
Stat score initialization: grandchildren

This is the sequel of the previous patch, we now let the parent node initialize
stat score to zero once for all grandchildren.

Initialize statScore to zero for the grandchildren of the current position.
So statScore is shared between all grandchildren and only the first grandchild
starts with statScore = 0. Later grandchildren start with the last calculated
statScore of the previous grandchild. This influences the reduction rules in
LMR which are based on the statScore of parent position.

Tests results against the previous patch:

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 23676 W: 5417 L: 5157 D: 13102
http://tests.stockfishchess.org/tests/view/5a9423a90ebc590297cc8a46

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 35485 W: 6168 L: 5898 D: 23419
http://tests.stockfishchess.org/tests/view/5a9435550ebc590297cc8a54

Bench: 5643520

6 years agoStat score initialization: children
Stefan Geschwentner [Tue, 27 Feb 2018 17:18:07 +0000 (18:18 +0100)]
Stat score initialization: children

Let the parent node initialize stat score to zero once for all siblings.

Initialize statScore to zero for the children of the current position.
So statScore is shared between sibling positions and only the first sibling
starts with statScore = 0. Later siblings start with the last calculated
statScore of the previous sibling. This influences the reduction rules in
in LMR which are based on the statScore of parent position.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 22683 W: 5202 L: 4946 D: 12535
http://tests.stockfishchess.org/tests/view/5a93315f0ebc590297cc894f

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 48548 W: 8346 L: 8035 D: 32167
http://tests.stockfishchess.org/tests/view/5a933ba90ebc590297cc8962

Bench: 5833683

6 years agoNo Tempo for draw scores given by heuristic functions
Stéphane Nicolet [Wed, 21 Feb 2018 00:07:35 +0000 (01:07 +0100)]
No Tempo for draw scores given by heuristic functions

The current master applies Eval::Tempo even to leaves evaluated
as draw by some of the static evaluation functions of endgame.cpp
(for instance KNN vs K or stalemates in KP vs K). This results in
some lines being reported as +0.07 or -0.07 when the terminal
position has reached such endgames (0.07 being about the value
of a tempo for Stockfish).

This patch does not apply Eval::tempo to these positions. This leads
to more nodes being evaluated as VALUE_DRAW during search, giving more
opportunities for cut-offs in alpha-beta.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 52602 W: 11776 L: 11403 D: 29423
http://tests.stockfishchess.org/tests/view/5a8cb8f60ebc590297cc8546

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,4.00]
Total: 156613 W: 26820 L: 26158 D: 103635
http://tests.stockfishchess.org/tests/view/5a8f452d0ebc590297cc865a

Bench: 4924749

6 years agoSpeedup and simplify pinners and blockers
Marco Costalba [Tue, 27 Feb 2018 00:18:33 +0000 (01:18 +0100)]
Speedup and simplify pinners and blockers

To compute dicovered check or pinned pieces we use some bitwise
operators that are not really needed because already accounted for
at the caller site.

For instance in evaluation we compute:

     pos.pinned_pieces(Us) & s

Where pinned_pieces() is:

     st->blockersForKing[c] & pieces(c)

So in this case the & operator with pieces(c) is useless,
given the outer '& s'.

There are many places where we can use the naked blockersForKing[]
instead of the full pinned_pieces() or discovered_check_candidates().

This path is simpler than original and gives around 1% speed up for me.
Also tested for speed by mstembera and snicolet (neutral in both cases).

No functional change.

6 years agoUnify use of -mdynamic-no-pic
erbsenzaehler [Sat, 10 Feb 2018 01:39:57 +0000 (02:39 +0100)]
Unify use of -mdynamic-no-pic

Apply -mdynamic-no-pic in a single place in the Makefile instead of 5 places.

Verified on three different Macs:
- a MacBook from 2013
- a MacBook running MacOS 10.9.5
- an iMac running MacOS 10.13.3

No functional change.

6 years agoShallow search to verify probcut
AndyGrant [Mon, 26 Feb 2018 02:01:37 +0000 (03:01 +0100)]
Shallow search to verify probcut

Perform a preliminary shallow search to verify a probcut before doing
the normal "depth - 4 plies" search.

STC:
LLR: 4.73 (-2.94,2.94) [0.00,5.00]
Total: 36281 W: 8221 L: 7830 D: 20230
http://tests.stockfishchess.org/tests/view/5a921cb90ebc590297cc87f6

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 22907 W: 3954 L: 3738 D: 15215
http://tests.stockfishchess.org/tests/view/5a92672b0ebc590297cc8814

Happy to see something from Ethereal work for Stockfish :)

Bench: 5882274

6 years agoCount passed pawns in asymmetry measure
Stéphane Nicolet [Sun, 25 Feb 2018 23:55:01 +0000 (00:55 +0100)]
Count passed pawns in asymmetry measure

The previous asymmetry measure of the pawn structure only used to
consider the number of pawns on semi-opened files in the position.
With this patch we also increase the measure by the number of passed
pawns for both players.

Many thanks to the community for the nice feedback on the previous
version, with special mentions to Alain Savard and Marco Costalba
for clarity and speed suggestions.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 13146 W: 3038 L: 2840 D: 7268
http://tests.stockfishchess.org/tests/view/5a91dd0c0ebc590297cc877e

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 27776 W: 4771 L: 4536 D: 18469
http://tests.stockfishchess.org/tests/view/5a91fdd50ebc590297cc879b

How to continue after this patch?

Stockfish will now evaluate more positions with passed pawns, so
tuning the passed pawns values may bring Elo. The patch has also
consequences on the initiative term, where we might want to give
different weights to passed pawns and semi-openfiles (idea by
Stefano Cardanobile).

Bench: 5302866

6 years agoCombine killer moves
Joost VandeVondele [Sun, 25 Feb 2018 21:33:40 +0000 (22:33 +0100)]
Combine killer moves

Move the first killer move out of the capture stage, combining treatment
of first and second killer move.

passed STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 55777 W: 12367 L: 12313 D: 31097
http://tests.stockfishchess.org/tests/view/5a88617e0ebc590297cc8351

Similar to an earlier proposition of Günther Demetz, see pull request #1075.
I think it is more robust and readable than master, why hand-unroll the loop
over the killer array, and duplicate code ?

This version includes review comments from Marco Costalba.

Bench: 5227124

6 years agoRevert "Count passed pawns in asymmetry measure"
Stéphane Nicolet [Sun, 25 Feb 2018 14:12:19 +0000 (15:12 +0100)]
Revert "Count passed pawns in asymmetry measure"

6 years agoCount passed pawns in asymmetry measure
Stéphane Nicolet [Sun, 25 Feb 2018 12:12:09 +0000 (13:12 +0100)]
Count passed pawns in asymmetry measure

The previous asymmetry measure of the pawn structure only used to
consider the number of pawns on semi-opened files in the postions.
With this patch we also increase the measure by the number of passed
pawns for both players.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 13146 W: 3038 L: 2840 D: 7268
http://tests.stockfishchess.org/tests/view/5a91dd0c0ebc590297cc877e

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 27776 W: 4771 L: 4536 D: 18469
http://tests.stockfishchess.org/tests/view/5a91fdd50ebc590297cc879b

How to continue from there: Stockfish will now evaluate more positions
with passed pawns, so tuning the passed pawns values may bring Elo.
The patch also has consequences on the initiative term.

Bench: 5302866

6 years agoJoin all capture init stages in MovePicker
Joost VandeVondele [Sun, 25 Feb 2018 11:49:03 +0000 (12:49 +0100)]
Join all capture init stages in MovePicker

Passed STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 16789 W: 3685 L: 3554 D: 9550
http://tests.stockfishchess.org/tests/view/5a91a8bb0ebc590297cc875b

Passed LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 21293 W: 3527 L: 3407 D: 14359
http://tests.stockfishchess.org/tests/view/5a920a730ebc590297cc87ba

No functional change

6 years agoMore robust interaction of singular search and iid
DU-jdto [Sun, 25 Feb 2018 00:14:29 +0000 (01:14 +0100)]
More robust interaction of singular search and iid

When iid (Internal iterative deepening) is invoked, the prior value of ttValue is
not guaranteed to be VALUE_NONE. As such, it is currently possible to enter a state
in which ttValue has a specific value which is inconsistent with tte->bound() and
tte->depth(). Currently, ttValue is only used within the search in a context that
prevents this situation from making a difference (and so this change is non-functional,
but this is not guaranteed to remain the case in the future.

For instance, just changing the tt depth condition in singular extension node to be

    tte->depth() >= depth - 4 * ONE_PLY

instead of

    tte->depth() >= depth - 3 * ONE_PLY

interacts badly with the absence of ttMove in iid. For the ttMove to become a singular
extension candidate, singularExtensionNode needs to be true. With the current master,
this requires that tte->depth() >= depth - 3 * ONE_PLY. This is not currently possible
if tte comes from IID, since the depth 'd' used for the IID search is always less than
depth - 4 * ONE_PLY for depth >= 8 * ONE_PLY (below depth 8 singularExtensionNode can
never be true anyway). However, with DU-jdto/Stockfish@251281a , this condition can be
met, and it is possible for singularExtensionNode to become true after IID. There are
then two mechanisms by which this patch can affect the search:

• If ttValue was VALUE_NONE prior to IID, the fact that this patch sets ttValue allows
  the 'ttValue != VALUE_NONE' condition of singularExtensionNode to be met.

• If ttValue wasn't VALUE_NONE prior to IID, the fact that this patch modifies ttValue's
  value causes a different 'rBeta' to be calculated if the singular extension search is
  performed.

Tested at STC for non-regression:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 76981 W: 17060 L: 17048 D: 42873
http://tests.stockfishchess.org/tests/view/5a7738b70ebc5902971a9868

No functional change

6 years agoSimplification: do razoring only for depth 1
DU-jdto [Sat, 24 Feb 2018 12:06:18 +0000 (13:06 +0100)]
Simplification: do razoring only for depth 1

The razoring heuristic is quite a drastic pruning technique,
using a depth 0 search at internal nodes of the search tree
to estimate the true value of depth n nodes. This patch limits
this razoring to the case of internal nodes of depth 1.
Author: Jarrod Torriero (DU-jdto)

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 8043 W: 1865 L: 1716 D: 4462
http://tests.stockfishchess.org/tests/view/5a90a9290ebc590297cc86c1

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 32890 W: 5577 L: 5476 D: 21837
http://tests.stockfishchess.org/tests/view/5a90c8510ebc590297cc86d5

Opportunities opened by this patch: it would be interesting to
know if it brings Elo to re-introduce razoring or soft razoring
at depth >= 2, maybe using a larger margin to compensate for the
increased pruning effect.

Bench: 5227124

6 years agoLower razor depth to < 3 and adjust margin
Tom Vijlbrief [Thu, 15 Feb 2018 07:47:30 +0000 (08:47 +0100)]
Lower razor depth to < 3 and adjust margin

Various margins were tested: 600, 560, 585, 580, 590 and 595.

Only 590 (this patch) passed both STC and LTC.
Higher margins appear to be better for longer time controls.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 24496 W: 5470 L: 5210 D: 13816
http://tests.stockfishchess.org/tests/view/5a8c6d040ebc590297cc8508

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 74540 W: 12888 L: 12491 D: 49161
http://tests.stockfishchess.org/tests/view/5a8d14c70ebc590297cc8566

Bench: 5475941

6 years agoReformat SEE to better document the function
Marco Costalba [Fri, 23 Feb 2018 21:02:10 +0000 (22:02 +0100)]
Reformat SEE to better document the function

This is one of the most difficult to understand but also
most important and speed critical functions of SF.

This patch rewrites some part of it to hopefully
make it clearer and drop some redundant variables
in the process.

Same speed than master (or even a bit more).

Thanks to Chris Cain for useful feedback.

No functional change.

6 years agoMove pawn_attacks_bb() helper to bitboard.h
Stéphane Nicolet [Wed, 21 Feb 2018 21:31:38 +0000 (22:31 +0100)]
Move pawn_attacks_bb() helper to bitboard.h

No functional change.

6 years agorename shift variables.
Mike Whiteley [Wed, 21 Feb 2018 20:46:25 +0000 (21:46 +0100)]
rename shift variables.

Where variable names are explicitly incorrect, I feel morally obligated to at least
suggest an alternative. There are many, but these two are especially egregious.

No functional change.

6 years agoAvoid a compilation warning
Alain SAVARD [Tue, 20 Feb 2018 23:52:26 +0000 (00:52 +0100)]
Avoid a compilation warning

Avoid a warning while compiling with gcc version 4.9.2

No functional change.

6 years agoCode style in evaluate.cpp
Marco Costalba [Tue, 20 Feb 2018 16:10:37 +0000 (17:10 +0100)]
Code style in evaluate.cpp

Passed STC
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 75666 W: 16482 L: 16616 D: 42568
http://tests.stockfishchess.org/tests/view/5a8953af0ebc590297cc83ab

No functional change.

6 years agoUpdate list of authors after Stockfish 9
Stéphane Nicolet [Sun, 18 Feb 2018 00:51:35 +0000 (01:51 +0100)]
Update list of authors after Stockfish 9

No functional change.

6 years agoSimplify trapped rook
Mike Whiteley [Thu, 15 Feb 2018 18:34:23 +0000 (19:34 +0100)]
Simplify trapped rook

As far as can tell, semiopenFiles are set if there is a pawn anywhere on
the file. The removed condition would be true even if the pawns were very
advanced, which doesn't make sense if we're looking for a trapped rook.
Seems the engine fairs better with this removed. My guess s that the
condition that mobility is 3 or less does this well enough.

Begs the question whether this is a mobility issue alone... not sure.
Should I do LTC test?

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 13377 W: 3009 L: 2871 D: 7497
http://tests.stockfishchess.org/tests/view/5a855be40ebc590297cc8166

Passed LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 16288 W: 2813 L: 2685 D: 10790
http://tests.stockfishchess.org/tests/view/5a8575a80ebc590297cc817e

Bench: 5006365

6 years agoFix gcc PGO build on Windows
Ronald de Man [Sat, 10 Feb 2018 00:44:05 +0000 (01:44 +0100)]
Fix gcc PGO build on Windows

This fixes the issue #1375 of the PGO builds failing under Windows:
https://github.com/official-stockfish/Stockfish/issues/1375

Solution found during this discussion in the fishcooking forum:
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/RjIPgeFFLPQ

Closes #1408.

No functional change.

6 years agoCode style fixes in search.cpp
Marco Costalba [Mon, 12 Feb 2018 21:57:42 +0000 (22:57 +0100)]
Code style fixes in search.cpp

Some code style triviality.

No functional change.

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.