]> git.sesse.net Git - stockfish/log
stockfish
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.

6 years agoClarify stats range
Marco Costalba [Fri, 18 Aug 2017 09:02:35 +0000 (02:02 -0700)]
Clarify stats range

Current update formula ensures that the
possible value range is [-32 * D, 32 * D].

So we never overflow if abs(32 * D) < INT16_MAX

Thanks to Joost and mstembera to clarify this.

No functional change.

6 years agoTime management simplification
IIvec [Fri, 7 Oct 2016 16:12:19 +0000 (18:12 +0200)]
Time management simplification

STC (http://tests.stockfishchess.org/tests/view/598188a40ebc5916ff64a21b):
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 25363 W: 4658 L: 4545 D: 16160

LTC (http://tests.stockfishchess.org/tests/view/5981d59a0ebc5916ff64a229):
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 75356 W: 9690 L: 9640 D: 56026

40/10 TC (http://tests.stockfishchess.org/tests/view/5980c5780ebc5916ff64a1ed):
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 19377 W: 3650 L: 3526 D: 12201

15+0 TC (http://tests.stockfishchess.org/tests/view/5982cb730ebc5916ff64a25d):
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 5913 W: 1217 L: 1069 D: 3627

This time management handles base time and movestogo cases separatelly. One can test one case without affecting the other. Also, increment usage can be tested separately without (necessarily) affecting sudden death or x moves in y seconds performance.

On stable machines there are no time losses on 0.1+0.001 time control (tested on i7 + Windows 10 platform).

Bench 5608839

6 years agoFix involuntary conversions of ExtMove to Move
Marco Costalba [Sun, 13 Aug 2017 18:01:26 +0000 (11:01 -0700)]
Fix involuntary conversions of ExtMove to Move

The trick is to create an ambiguity for the
compiler in case an unwanted conversion to
Move is attempted like in:

    ExtMove m1{Move(17),4}, m2{Move(4),17};

    std::cout << (m1 < m2) << std::endl; // 1
    std::cout << (m1 > m2) << std::endl; // 1(!)

This fixes issue #1204

No functional change.

6 years agoUnify stats update()
Marco Costalba [Thu, 17 Aug 2017 08:47:32 +0000 (01:47 -0700)]
Unify stats update()

Now that is a bit bigger makes sense to
unify some duplicated code.

No functional change.

6 years agoUse int16_t in History values
lucasart [Wed, 9 Aug 2017 11:35:05 +0000 (19:35 +0800)]
Use int16_t in History values

Reduces memory footprint by ~1.2MB (per thread).

Strong pressure: small but mesurable gain
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 258430 W: 46977 L: 45943 D: 165510

Low pressure: no regression
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 73542 W: 13058 L: 13026 D: 47458

Strong pressure + LTC: elo gain confirmed
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 31489 W: 4532 L: 4295 D: 22662

Tested for crashing on overflow and after 70K
games at STC we have only 4 time losses,
possible candidate for an overflow.

No functional change.

6 years agoFix incorrect StateInfo
Marco Costalba [Mon, 14 Aug 2017 16:12:16 +0000 (09:12 -0700)]
Fix incorrect StateInfo

We use Position::set() to set root position across
threads. But there are some StateInfo fields (previous,
pliesFromNull, capturedPiece) that cannot be deduced
from a fen string, so set() clears them and to not lose
the info we need to backup and later restore setupStates->back().
Note that setupStates is shared by threads but is accessed
in read-only mode.

This fixes regression introduced by df6cb446eaf21

Tested with 3 threads at STC:
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 14436 W: 2304 L: 2196 D: 9936

Bench: 5608839

6 years agoRun clang-tidy 'modernize'
Marco Costalba [Sun, 13 Aug 2017 12:33:25 +0000 (05:33 -0700)]
Run clang-tidy 'modernize'

Some warnings after a run of:

$ clang-tidy-3.8 -checks='modernize-*' *.cpp syzygy/*.cpp -header-filter=.* -- -std=c++11

I have not fixed all suggestions, for instance I still prefer
to declare the type instead of a spread use of 'auto'. I also
perfer good old 'typedef' to the new 'using' form.

I have not fixed some warnings in the last functions of
syzygy code because those are still the original functions
and need to be completely rewritten anyhow.

Thanks to erbsenzaehler for the original idea.

No functional change.

6 years agoThread code reformat
Marco Costalba [Sun, 13 Aug 2017 06:58:31 +0000 (23:58 -0700)]
Thread code reformat

Simplify out low level sync stuff (mutex
and friends) and avoid to use them directly
in many functions.

Also some renaming and better comment while
there.

No functional change.

6 years agoRetire States global variable
Marco Costalba [Sun, 13 Aug 2017 06:38:39 +0000 (23:38 -0700)]
Retire States global variable

And other small touches in uci.cpp

No functional change.

6 years agoFix the handling of opposite bishops in KXK endgame evaluation
tthsqe12 [Sat, 12 Aug 2017 08:50:38 +0000 (10:50 +0200)]
Fix the handling of opposite bishops in KXK endgame evaluation

The case of three or more bishops against a long king must look at all of the
bishops and not just the first two in the piece lists. This patch makes sure
that the position is treated as a win when there are bishops on opposite
colors. This functional change is very small because bench remains the same.

LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 24249 W: 4349 L: 4275 D: 15625
http://tests.stockfishchess.org/tests/view/598186530ebc5916ff64a218

Bench: 5608839

6 years agoSimplify finished search in ponder/infinite mode.
Joost VandeVondele [Fri, 4 Aug 2017 17:48:07 +0000 (19:48 +0200)]
Simplify finished search in ponder/infinite mode.

In this rare case (e.g. go infinite on a stalemate),
just spin till ponderhit/stop comes.

The Thread::wait() is a renmant of the old YBWC
code, today with lazy SMP, threads don't need to
wait when outside of their idle loop.

No functional change.

6 years agoRe-apply the fix for Limits::ponder race
Marco Costalba [Thu, 10 Aug 2017 19:32:50 +0000 (12:32 -0700)]
Re-apply the fix for Limits::ponder race

But this time correctly set Threads.ponder

We avoid using 'limits' for passing pondering
flag because we don't want to have 2 ponder
variables in search scope: Search::Limits.ponder
and Threads.ponder. This would be confusing also
because limits.ponder is set at the beginning of
the search and never changes, instead Threads.ponder
can change value asynchronously during search.

No functional change.

6 years agoRevert "Fix a race on Limits::ponder"
Marco Costalba [Thu, 10 Aug 2017 17:57:28 +0000 (10:57 -0700)]
Revert "Fix a race on Limits::ponder"

This reverts commit 5410424e3d036b43715c7989aa99e449cdcde18e.

After the commit pondering is broken, so revert for now. I will
resubmit with a proper fix.

The issue is mine, Joost original code is correct.

No functional change.

6 years agoFix a race on Limits::ponder
Joost VandeVondele [Thu, 27 Jul 2017 06:31:25 +0000 (08:31 +0200)]
Fix a race on Limits::ponder

Limits::ponder was used as a signal between uci and search threads,
but is not an atomic variable, leading to the following race as
flagged by a sanitized binary.

Expect input:
```
 spawn  ./stockfish
 send "uci\n"
 expect "uciok"
 send "setoption name Ponder value true\n"
 send "go wtime 4000 btime 4000\n"
 expect "bestmove"
 send "position startpos e2e4 d7d5\n"
 send "go wtime 4000 btime 4000 ponder\n"
 sleep 0.01
 send "ponderhit\n"
 expect "bestmove"
 send "quit\n"
 expect eof
```

Race:
```
WARNING: ThreadSanitizer: data race (pid=7191)
  Read of size 4 at 0x0000005c2260 by thread T1:

  Previous write of size 4 at 0x0000005c2260 by main thread:

  Location is global 'Search::Limits' of size 88 at 0x0000005c2220 (stockfish+0x0000005c2260)
```

The reason of teh race is that ponder is not just set in UCI go()
assignment but also is signaled by an async ponderhit in uci.cpp:

      else if (token == "ponderhit")
          Search::Limits.ponder = 0; // Switch to normal search

The fix is to add an atomic bool to the threads structure to
signal the ponder status, letting Search::Limits to reflect just
what was passed to 'go'.

No functional change.

6 years agoFix some races and clarify the code
Marco Costalba [Sun, 6 Aug 2017 11:43:02 +0000 (04:43 -0700)]
Fix some races and clarify the code

Better split code that should be run at
startup from code run at ucinewgame. Also
fix several races when 'bench', 'perft' and
'ucinewgame' are sent just after 'bestomve'
from the engine threads are still running.

Also use a specific UI thread instead of
main thread when setting up the Position
object used by UI uci loop. This fixes a
race when sending 'eval' command while searching.

We accept a race on 'setoption' to allow the
GUI to change an option while engine is searching
withouth stalling the pipe. Note that changing an
option while searchingg is anyhow not mandated by
UCI protocol.

No functional change.

6 years agoMake variable naming consistent
AndyGrant [Thu, 10 Aug 2017 01:43:30 +0000 (21:43 -0400)]
Make variable naming consistent

moved_piece is the only variable in search not using camel case

6 years agoUnify scoring functions in MovePicker
Joost VandeVondele [Wed, 9 Aug 2017 12:04:59 +0000 (14:04 +0200)]
Unify scoring functions in MovePicker

No functional change.

6 years agoRemove Stack/thread dependence in movepick
Joost VandeVondele [Fri, 30 Jun 2017 15:20:00 +0000 (17:20 +0200)]
Remove Stack/thread dependence in movepick

as a lower level routine, movepicker should not depend on the
search stack or the thread class, removing a circular dependency.
Instead of copying the search stack into the movepicker object,
as well as accessing the thread class for one of the histories,
pass the required fields explicitly to the constructor (removing
the need for thread.h and implicitly search.h in movepick.cpp).
The signature is thus longer, but more explicit:

Also some renaming of histories structures while there.

passed STC [-3,1], suggesting a small elo impact:

LLR: 3.13 (-2.94,2.94) [-3.00,1.00]
Total: 381053 W: 68071 L: 68551 D: 244431
elo =   -0.438 +-    0.660 LOS:    9.7%

No functional change.

6 years agoTweak connected pawns seed[] array values
snicolet [Wed, 2 Aug 2017 01:40:27 +0000 (18:40 -0700)]
Tweak connected pawns seed[] array values

Raise a little bit the values in the connected pawns seed[] array.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 99033 W: 17939 L: 17448 D: 63646
http://tests.stockfishchess.org/tests/view/597355630ebc5916ff649e3e

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 48044 W: 6371 L: 6099 D: 35574
http://tests.stockfishchess.org/tests/view/597596610ebc5916ff649eba

Bench: 5608839

Closes #1182

6 years agoRework the "unsupported" penalty into a "supported" bonus
Rocky640 [Wed, 2 Aug 2017 01:36:33 +0000 (18:36 -0700)]
Rework the "unsupported" penalty into a "supported" bonus

A pawn (according to all the searched positions of a bench run) is not supported 85% of the time,
(in current master it is either isolated, backward or "unsupported").

So it made sense to try moving the S(17, 8) "unsupported" penalty value into the base pawn value hoping for a more representative pawn value, and accordingly
a) adjust backward and isolated so that they stay more or less the same as master
b) increase the mg connected bonus in the supported case by S(17, 0) and let the Connected formula find a suitable eg value according to rank.

Tested as a simplification SPRT(-3, 1)

Passed STC
http://tests.stockfishchess.org/tests/view/5970dbd30ebc5916ff649dd6
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 19613 W: 3663 L: 3540 D: 12410

Passed LTC
http://tests.stockfishchess.org/tests/view/597137780ebc5916ff649de3
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 24721 W: 3306 L: 3191 D: 18224

Bench: 5581946

Closes #1179

6 years agoRemove redundant if-statements
VoyagerOne [Thu, 27 Jul 2017 09:14:18 +0000 (02:14 -0700)]
Remove redundant if-statements

No functional change

Closes #1173

6 years agoTuned PSQT using a custom tuner.
mstembera [Wed, 5 Jul 2017 20:05:29 +0000 (13:05 -0700)]
Tuned PSQT using a custom tuner.

bench: 5878420

Closes #1177

6 years agoSimplify aspiration window
VoyagerOne [Mon, 24 Jul 2017 00:25:23 +0000 (17:25 -0700)]
Simplify aspiration window

Don't modify alpha window on fail-high

Bench: 5875983

Closes #1172

6 years agoFaster travis checks
Joost VandeVondele [Sat, 15 Jul 2017 08:25:35 +0000 (10:25 +0200)]
Faster travis checks

in the last month a couple of timeouts have been seen in travis valgrind testing, leading to undesired false positives. The precise cause of this is unclear: a normal valgrind instrumented run is about 6min, the timeout is 10min. Either there are rare hangs (not reproduced locally), or maybe the actual runtime fluctuates on the travis infrastructure (which uses VMs on AWS as far as I know). This patch leads to roughly a 2x speedup of the instrumented testing by reducing the depth from 10 to 9. If timeouts persist, it needs further analysis.

No functional change.

Closes #1171

6 years agoMove game_phase() to material.cpp
Marco Costalba [Sun, 9 Jul 2017 09:45:31 +0000 (11:45 +0200)]
Move game_phase() to material.cpp

For some reason, although game phase is used
only in material, it is computed in Position.

Move computation to material, where it belongs,
and remove the useless call chain.

No functional change.

6 years agoRevert "Remove questionable gcc flags from profile-build"
Joona Kiiski [Thu, 13 Jul 2017 23:36:27 +0000 (16:36 -0700)]
Revert "Remove questionable gcc flags from profile-build"

This reverts commit 0371a8f8c4a043cb3e7d08b5b8e7d08d49f28324.

6 years agoProvide selective search depth info for each pv move
joergoster [Thu, 13 Jul 2017 23:30:03 +0000 (16:30 -0700)]
Provide selective search depth info for each pv move

No functional change

Closes #1166

6 years agoMove stop signal to Threads
Joost VandeVondele [Thu, 13 Jul 2017 23:07:19 +0000 (16:07 -0700)]
Move stop signal to Threads

Instead of having Signals in the search namespace,
make the stop variables part of the Threads structure.
This moves more of the shared (atomic) variables towards
the thread-related structures, making their role more clear.

No functional change

Closes #1149

6 years agoRemove questionable gcc flags from profile-build
Joona Kiiski [Sat, 8 Jul 2017 21:19:03 +0000 (14:19 -0700)]
Remove questionable gcc flags from profile-build

Optimization options for official stockfish should be
consistent, easy, future proof and simple.

We don't want to optimize for any specific version of gcc

No functional change

Closes #1165

6 years agoQueen vs. Minors imbalance
GuardianRM [Sat, 8 Jul 2017 21:07:25 +0000 (14:07 -0700)]
Queen vs. Minors imbalance

Addition of correction values in case of Imbalance of queens,
depending on the number of light pieces on the side without a queen.

Passed patch:

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 29036 W: 5379 L: 5130 D: 18527

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 13680 W: 1836 L: 1674 D: 10170

Bench: 6258930

Closes #1155

6 years agoDon't uselessy share rootDepth
Marco Costalba [Sun, 2 Jul 2017 10:10:50 +0000 (03:10 -0700)]
Don't uselessy share rootDepth

It is not needed becuase the only case is a real special
one (bench on depth with many threads) and can be easily
rewritten to avoid sharing rootDepth.

Verified with ThreadSanitizer.

No functional change.

Closes #1159

6 years agoFix some warnings with clang static analyzer
Marco Costalba [Sun, 2 Jul 2017 11:39:58 +0000 (13:39 +0200)]
Fix some warnings with clang static analyzer

Only one remains (also in tbprobe.cpp), but is bougus.

As a side note, tbprobe.cpp is almost clean, only the last 3
functions probe_wdl(), root_probe() and root_probe_wdl()
are still the original ones and are quite hacky.

Somewhere in the future we will reformat also the last 3
ones. The reason why has not been done before it is because
these functions are really wrong by design and should be
rewritten entirely, not only reformatted.

No functional change.

Closes #1160

6 years agoIndentation fix in index()
Marco Costalba [Sat, 1 Jul 2017 05:58:38 +0000 (07:58 +0200)]
Indentation fix in index()

No functional change.

Closes #1158

6 years agoTidy up
Alain SAVARD [Fri, 23 Jun 2017 04:03:58 +0000 (00:03 -0400)]
Tidy up

No functional change

Closes #1148

6 years agoMagic::index()
mstembera [Thu, 29 Jun 2017 00:11:17 +0000 (17:11 -0700)]
Magic::index()

Make magic_index() a member of Magic since it uses all it's members
and keep us from having to pass the function pointer around to
init_magics().

No functional change

Closes #1146

6 years agoRemove race suppression.
Joost VandeVondele [Fri, 23 Jun 2017 16:23:27 +0000 (18:23 +0200)]
Remove race suppression.

Pull #1134 fixed another race, so that can be removed from the thread sanitizer suppressions.

No functional change.

Closes #1150

6 years agoOnly main thread checks time
Marco Costalba [Sat, 24 Jun 2017 05:15:46 +0000 (07:15 +0200)]
Only main thread checks time

The main change of the patch is that now time check
is done only by main thread. In the past, before lazy
SMP, we needed all the threds to check for available
time because main thread could have been blocked on
a split point, now this is no more the case and main
thread can do the job alone, greatly simplifying the logic.

Verified for regression testing on STC with 7 threads:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 11895 W: 1741 L: 1608 D: 8546

No functional change.

Closes #1152

6 years agoSimplify pos_is_ok()
Marco Costalba [Sat, 24 Jun 2017 10:36:07 +0000 (12:36 +0200)]
Simplify pos_is_ok()

Now we don't need anymore the tricky pointer to
show the failed test. Added some few tests too.

Also small rename in see_ge() while there.

No functional change

Closes #1151

6 years agoIncrease reduction if tt-move is a capture
VoyagerOne [Wed, 21 Jun 2017 21:05:14 +0000 (14:05 -0700)]
Increase reduction if tt-move is a capture

The idea is that chances are the tt-move is best and will be difficult to raise alpha when playing a quiet move.

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 7582 W: 1415 L: 1259 D: 4908

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 59553 W: 7885 L: 7573 D: 44095

Bench: 5725676

Closes #1147

6 years agoImprove readability of evaluation functions
snicolet [Wed, 21 Jun 2017 21:01:59 +0000 (14:01 -0700)]
Improve readability of evaluation functions

This patch puts the evaluation helper functions inside EvalInfo struct, which simplifies a bit their signature and (most importantly, IMHO) makes their C++ code much cleaner and simpler to read (by removing the "ei." qualifiers all around in evaluate.cpp).

Also rename the EvalInfo struct into Evaluation class to get a natural invocation v = Evaluation(p).value() to evaluation position p.

The downside is an increase of 20 lines in evaluate.cpp (for the prototypes of the helper functions). The upsides are better readability and a speed-up of 0.6% (by generating all the helpers for the NO_TRACE case together, which helps the instruction cache).

No functional change

Closes #1135

6 years agoUpdate Top CPU - Bench: 6599721
VoyagerOne [Sun, 18 Jun 2017 19:03:18 +0000 (15:03 -0400)]
Update Top CPU - Bench:  6599721

Closes #1145

6 years agoRevert "Prefetch earlier in qsearch()"
Joona Kiiski [Wed, 21 Jun 2017 20:44:05 +0000 (13:44 -0700)]
Revert "Prefetch earlier in qsearch()"

This reverts commit b73016bb41d4c2fad3126b2e0018d71a36e78331.

No functional change

Closes #1144

6 years agoFix four data races.
Joost VandeVondele [Wed, 21 Jun 2017 20:36:53 +0000 (13:36 -0700)]
Fix four data races.

the nodes, tbHits, rootDepth and lastInfoTime variables are read by multiple threads, but not declared atomic, leading to data races as found by -fsanitize=thread. This patch fixes this issue. It is based on top of the CI-threading branch (PR #1129), and should fix the corresponding CI error messages.

The patch passed an STC check for no regression:

http://tests.stockfishchess.org/tests/view/5925d5590ebc59035df34b9f
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 169597 W: 29938 L: 30066 D: 109593

Whereas rootDepth and lastInfoTime are not performance critical, nodes and tbHits are. Indeed, an earlier version using relaxed atomic updates on the latter two variables failed STC testing (http://tests.stockfishchess.org/tests/view/592001700ebc59035df34924), which can be shown to be due to x86-32 (http://tests.stockfishchess.org/tests/view/592330ac0ebc59035df34a89). Indeed, the latter have no instruction to atomically update a 64bit variable. The proposed solution thus uses a variable in Position that is accessed only by one thread, which is copied every few thousand nodes to the shared variable in Thread.

No functional change.

Closes #1130
Closes #1129

6 years agoMisc coding style fixes
Alain SAVARD [Sun, 11 Jun 2017 21:31:15 +0000 (17:31 -0400)]
Misc coding style fixes

a few comment and blank fixes.

No functional change

Closes #1141

6 years agoPrefetch earlier in qsearch()
snicolet [Sat, 17 Jun 2017 02:52:38 +0000 (19:52 -0700)]
Prefetch earlier in qsearch()

Closes #1139

6 years agoBetter naming in endgame code
Marco Costalba [Sun, 4 Jun 2017 09:03:23 +0000 (11:03 +0200)]
Better naming in endgame code

And small clean-up of magic bitboards code.

No functional change.

Closes #1138