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

6 years agoMove depth calculation in probCut
Brian Sheppard [Sat, 17 Jun 2017 02:27:36 +0000 (19:27 -0700)]
Move depth calculation in probCut

The change passed an STC regression:

LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 59350 W: 10793 L: 10738 D: 37819

I verified that there was no change in performance on my machine, but of course YMMV:

Results for 40 tests for each version:

                Base      Test      Diff
        Mean    2014338   2016121   -1783
        StDev   62655     63441     3860

p-value: 0.678
speedup: 0.001

No functional change.

Closes #1137

6 years agoCall TT.new_search() earlier.
Joost VandeVondele [Tue, 6 Jun 2017 07:48:57 +0000 (09:48 +0200)]
Call TT.new_search() earlier.

TT.new_search() was being called by mainThread in Thread::search(). However, mainThread is the last to start searching, and helper threads could reach a measured rootDepth 10 (on 64 cores) before mainThread increments the TT generation. Fixed by moving the call to MaintThread::search() before helper threads start searching.

No functional change.

Closes #1134

6 years agoReordering magic data
mstembera [Tue, 6 Jun 2017 17:20:43 +0000 (10:20 -0700)]
Reordering magic data

Gather all magic relevant data into a struct.

This changes memory layout putting everything necessary for processing a single square
in the same memory location thus speeding up access.

Original patch by @snicolet

No functional change.

Closes #1127
Closes #1128

6 years agoDon't score as an immediate draw 2-fold repetitions of the root position
atumanian [Tue, 6 Jun 2017 17:13:10 +0000 (10:13 -0700)]
Don't score as an immediate draw 2-fold repetitions of the root position

In the current version a search stops when the current position is the same as
any position earlier in the search stack,
including the root position but excluding positions before the root.
The new version makes an exception for repeating the root position.

This gives correct scores for moves in the MultiPV > 1 mode.

Fixes #948 (see it for the detailed description of the bug).

LTC: http://tests.stockfishchess.org/tests/view/587910bc0ebc5915193f754b
ELO: 0.38 +-1.7 (95%) LOS: 66.8%
Total: 40000 W: 5166 L: 5122 D: 29712

STC: http://tests.stockfishchess.org/tests/view/5922e6230ebc59035df34a50
LLR: 2.94 (-2.94,2.94) [-3.00,1.00]
Total: 94622 W: 17059 L: 17064 D: 60499

 LTC: http://tests.stockfishchess.org/tests/view/59273a000ebc59035df34c03
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 61259 W: 7965 L: 7897 D: 45397

Bench: 6599721

Closes #1126

6 years agouse auto& for histories
Joost VandeVondele [Sun, 28 May 2017 07:58:52 +0000 (09:58 +0200)]
use auto& for histories

No functional change.

Closes #1113

6 years agoHistory code rewrite (#1122)
Marco Costalba [Fri, 26 May 2017 06:42:50 +0000 (08:42 +0200)]
History code rewrite (#1122)

Rearrange and rename all history heuristic code. Naming
is now based on chessprogramming.wikispaces.com conventions
and the relations among the various heuristics are now more
clear and consistent.

No functional change.

6 years agoChanged spelling back to "Bishops" in eval output
Nathan Rugg [Tue, 23 May 2017 06:56:49 +0000 (14:56 +0800)]
Changed spelling back to "Bishops" in eval output

No functional change.

Closes #1124

6 years agoEvasion Pruning Tweak
VoyagerOne [Mon, 22 May 2017 01:25:20 +0000 (18:25 -0700)]
Evasion Pruning Tweak

Use moveCount to decide when to prune for evasion pruning

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 24476 W: 4518 L: 4289 D: 15669

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 18362 W: 2476 L: 2298 D: 13588

Bench: 6469989

Closes #1120

6 years agoDo check analysis later in the game
snicolet [Thu, 18 May 2017 01:23:07 +0000 (18:23 -0700)]
Do check analysis later in the game

The previous patch has added a fraction of the king danger score to the
endgame score of the tapered eval, so it seems natural to perform the
king danger computation later in the endgame.

With this patch we extend the limit of such check analysis down to the
material of Rook+Knight, when we have at least two pieces attacking the
opponent king zone.

Passed STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 7446 W: 1409 L: 1253 D: 4784
http://tests.stockfishchess.org/tests/view/591c097c0ebc59035df3477c

and LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 14234 W: 1946 L: 1781 D: 10507
http://tests.stockfishchess.org/tests/view/591c24f10ebc59035df3478c

Bench: 5975183

Closes #1121

6 years agoUse a fraction of king danger in endgame score
snicolet [Thu, 18 May 2017 01:19:47 +0000 (18:19 -0700)]
Use a fraction of king danger in endgame score

When SF has an attack on the opponent king in one flank, the huge
midgame -> endgame gradient of the tapered eval prevents us to properly
evaluate neutral exchanges on the other flank as the current king
danger score is a pure midgame term. This may affect SF's ability to
switch to defense in some positions. We add a small contribution
of the king danger to the endgame score to limit this
effect.

Again suggested in the following forum thread:
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/xrUCQ7b0ObE

Passed STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 12719 W: 2371 L: 2192 D: 8156
http://tests.stockfishchess.org/tests/view/5919761a0ebc59035df3468f

And LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 31293 W: 4194 L: 3974 D: 23125
http://tests.stockfishchess.org/tests/view/591980450ebc59035df34695

Bench: 5961548

Closes #1118

6 years agoFix memory access in Search::clear()
Joost VandeVondele [Thu, 18 May 2017 01:15:01 +0000 (18:15 -0700)]
Fix memory access in Search::clear()

Fixes a bug in Search::clear, where the filling of CounterMoveStats&, overwrote (currently presumably unused) memory because sizeof(cm) returns the size in bytes, whereas elements was needed.

No functional change

Closes #1119

6 years agoLimit king ring to eight squares
snicolet [Tue, 16 May 2017 02:26:27 +0000 (19:26 -0700)]
Limit king ring to eight squares

In current master the size of the king ring varies abruptly from eight
squares when the king is in g8, to 12 squares when it is in g7. Because
the king ring is used for estimating attack strength, this may lead to
an overestimation of king danger in some positions. This patch limits
the king ring to eight squares in all cases.

 Inspired by the following forum thread:
https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/xrUCQ7b0ObE

Passed STC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 9244 W: 1777 L: 1611 D: 5856

and LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 87121 W: 11765 L: 11358 D: 63998

Bench: 6121121

Closes #1115

6 years agoExecute an implied ucinewgame at startup
Joost VandeVondele [Sat, 6 May 2017 11:12:39 +0000 (13:12 +0200)]
Execute an implied ucinewgame at startup

execute an implied ucinewgame upon entering the UCI::loop,
to make sure that searches starting with and without an (optional) ucinewgame
command yield the same search.

This is needed now that seach::clear() initializes tables to non-zero default values.

No functional change

Closes #1101
Closes #1104

6 years agoDefault argument for see_ge()
Marco Costalba [Tue, 9 May 2017 11:50:05 +0000 (13:50 +0200)]
Default argument for see_ge()

No functional change.

Closes #1111

6 years agoRemove int to int conversion, unused include.
Joost VandeVondele [Wed, 10 May 2017 01:36:18 +0000 (18:36 -0700)]
Remove int to int conversion, unused include.

No functional change.

Closes #1112

6 years agoLinear Protector bonus by distance
FauziAkram [Mon, 8 May 2017 04:03:59 +0000 (21:03 -0700)]
Linear Protector bonus by distance

Replacing the old Protector table with a simple linear formula which takes into account a different slope for each different piece type.

The idea of this simplification of Protector is originated by Alain (Rocky)

STC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 70382 W: 12859 L: 12823 D: 44700

LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 61554 W: 8098 L: 8031 D: 45425

Bench: 6107863

Closes #1099

6 years agoKing safety and rook mobility parameters tweak
IIvec [Mon, 8 May 2017 03:56:04 +0000 (20:56 -0700)]
King safety and rook mobility parameters tweak

STC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 19280 W: 3595 L: 3373 D: 12312

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 221405 W: 28940 L: 28220 D: 164245

Bench: 6506664

Closes #1105

6 years agoBonus for pawn scrifice which create passed pawn
Stefan Geschwentner [Mon, 8 May 2017 03:38:03 +0000 (20:38 -0700)]
Bonus for pawn scrifice which create passed pawn

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 16752 W: 3141 L: 2944 D: 10667

LTC:
LLR: 3.34 (-2.94,2.94) [0.00,5.00]
Total: 33928 W: 4544 L: 4300 D: 25084

Bench: 5639223

Closes #1092

6 years agoMove Pieces[] out of global visibility
Marco Costalba [Sun, 7 May 2017 08:26:09 +0000 (10:26 +0200)]
Move Pieces[] out of global visibility

It is an helper array used only in position.cpp

Also small code tidy up while there.

No functional change.

Closes #1106

6 years agoAvoid *begin always being included in the sorted list regardless of its value.
mstembera [Mon, 8 May 2017 03:14:23 +0000 (20:14 -0700)]
Avoid *begin always being included in the sorted list regardless of its value.

This was a minor criticism by @zamar in the original pull request
https://github.com/official-stockfish/Stockfish/pull/1065
necessitating a comment explanation.

No functional change.

Closes #1091

6 years agoFix multiPV issue #502
joergoster [Thu, 4 May 2017 02:46:40 +0000 (19:46 -0700)]
Fix multiPV issue #502

In general, this patch handles the cases where we don't have a valid score for each PV line in a multiPV search. This can happen if the search has been stopped in an unfortunate moment while still in the aspiration loop. The patch consists of two parts.

Part 1: The new PVIdx was already part of the k-best pv's in the last iteration, and we therefore have a valid pv and score to output from the last iteration. This is taken care of with:

      bool updated = (i <= PVIdx && rootMoves[i].score != -VALUE_INFINITE);

Case 2: The new PVIdx was NOT part of the k-best pv's in the last iteration, and we have no valid pv and score to output. Not from the current nor from the previous iteration. To avoid this, we are now also considering the previous score when sorting, so that the PV lines with no actual but with a valid previous score are pushed up again, and the previous score can be displayed.

  bool operator<(const RootMove& m) const {
    return m.score != score ? m.score < score : m.previousScore < previousScore; } // Descending sort

I also added an assertion in UCI::value() to possibly catch similar issues earlier.

No functional change.

Closes #502
Closes #1074

6 years agogcc 7 port
Joost VandeVondele [Fri, 28 Apr 2017 15:30:14 +0000 (17:30 +0200)]
gcc 7 port

Testing the release candidate revealed only one minor issue, namely a new warning -Wimplicit-fallthrough (part of -Wextra) triggers in the movepicker. This can be silenced by adding a comment, and once we move to c++17 by adding a standard annotation [[fallthrough]];.

No functional change.

Closes #1090

6 years agoDon't do InCheck Pruning at the root of QS
VoyagerOne [Sat, 29 Apr 2017 03:40:01 +0000 (20:40 -0700)]
Don't do InCheck Pruning at the root of QS

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 34603 W: 6441 L: 6167 D: 21995

LTC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 24474 W: 3274 L: 3076 D: 18124

Bench: 5934421

Closes #1089

6 years agoRemove cap in kingDanger initialization
Rocky640 [Sat, 29 Apr 2017 03:36:24 +0000 (20:36 -0700)]
Remove cap in kingDanger initialization

Passed STC
http://tests.stockfishchess.org/tests/view/58fd53be0ebc59035df33eb5
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 52048 W: 9397 L: 9329 D: 33322

Passed LTC
http://tests.stockfishchess.org/tests/view/58ff9e0a0ebc59035df33f5c
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 35382 W: 4650 L: 4549 D: 26183

Bench: 5872717

Closes #1087

6 years agoRetire the misdesigned StepAttacks[] array.
Marco Costalba [Sat, 29 Apr 2017 03:33:30 +0000 (20:33 -0700)]
Retire the misdesigned StepAttacks[] array.

StepAttacks[] is misdesigned, the color dependance is specific
to pawns, and trying to generalise to king and knights, proves
neither useful nor convinient in practice.

So this patch reformats the code with the following changes:

- Use PieceType instead of Piece in attacks_() functions

- Use PseudoAttacks for KING and KNIGHT

- Rename StepAttacks[] into PawnAttacks[]

Original patch and idea from Alain Savard.

No functional change.

Closes #1086

6 years agoCopy killers in the movepicker
Joost VandeVondele [Sat, 29 Apr 2017 03:27:39 +0000 (20:27 -0700)]
Copy killers in the movepicker

ss->killers can change while the movepicker is active.
The reason ss->killers changes is related to the singular
extension search in the moves loop that calls search<>
recursively with ss instead of ss+1,
effectively using the same stack entry for caller and callee.
By making a copy of the killers,
the movepicker does the right thing nevertheless.

Tested as a bug fix

STC:
http://tests.stockfishchess.org/tests/view/58ff130f0ebc59035df33f37
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 70845 W: 12752 L: 12716 D: 45377

LTC:
http://tests.stockfishchess.org/tests/view/58ff48000ebc59035df33f3d
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 28368 W: 3730 L: 3619 D: 21019

Bench: 6465887

Closes #1085

6 years agoAvoid misuse of StepAttacksBB for pawns
snicolet [Wed, 26 Apr 2017 00:57:30 +0000 (17:57 -0700)]
Avoid misuse of StepAttacksBB for pawns

Make it explicit that first index of StepAttacksBB is a piece, not a piece type.

No functional change

Closes #1083

6 years agoZero unused constant
Joost VandeVondele [Wed, 26 Apr 2017 00:19:23 +0000 (17:19 -0700)]
Zero unused constant

No functional change

Closes #1081

6 years agoAssorted code style issues
Marco Costalba [Sat, 22 Apr 2017 07:03:17 +0000 (09:03 +0200)]
Assorted code style issues

I have removed the check for

 pieceCount[PAWN] > FILE_NB

because totally useless.

No functional change.

6 years agoSort moves partially: linear depth dependence
Joost VandeVondele [Sun, 23 Apr 2017 15:37:55 +0000 (08:37 -0700)]
Sort moves partially: linear depth dependence

STC: http://tests.stockfishchess.org/tests/view/58f98d260ebc59035df33d5e
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 58958 W: 10862 L: 10485 D: 37611

LTC: http://tests.stockfishchess.org/tests/view/58fa45d40ebc59035df33d86
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 18607 W: 2427 L: 2251 D: 13929

Bench: 6065528

Closes #1079

6 years agoKing safety parameters improved
IIvec [Sun, 23 Apr 2017 15:02:52 +0000 (08:02 -0700)]
King safety parameters improved

STC:
LLR: 2.97 (-2.94,2.94) [0.00,4.00]
Total: 58648 W: 10883 L: 10524 D: 37241

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 52546 W: 7131 L: 6844 D: 38571

Bench 6121479

Closes #1078

6 years agoUse int instead of Value for history related stats.
Joost VandeVondele [Sun, 23 Apr 2017 14:57:48 +0000 (07:57 -0700)]
Use int instead of Value for history related stats.

history related scores are not related to evaluation based scores.
For example, can easily exceed the range -VALUE_INFINITE,VALUE_INFINITE.
As such the current type is confusing, and a plain int is a better match.

tested for no regression:

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 43693 W: 7909 L: 7827 D: 27957

No functional change.

Closes #1070

6 years agosimplify logic for history based pruning
Joost VandeVondele [Thu, 20 Apr 2017 18:22:24 +0000 (11:22 -0700)]
simplify logic for history based pruning

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 34255 W: 6292 L: 6194 D: 21769

LTC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 89914 W: 11769 L: 11739 D: 66406

Bench: 6581936

Closes #1066

6 years agoPartial insertion sort
Joost VandeVondele [Thu, 20 Apr 2017 18:15:48 +0000 (11:15 -0700)]
Partial insertion sort

the order of elements returned by std::partition is implementation defined (since not stable) and could depend on the version of libstdc++ linked.
As std::stable_partition was tested to be too slow (http://tests.stockfishchess.org/tests/view/585cdfd00ebc5903140c6082).
Instead combine partition with our custom implementation of insert_sort, which fixes this issue.
Implementation based on a patch by mstembera (http://tests.stockfishchess.org/tests/view/58d4d3460ebc59035df3315c), which suggests some benefit by itself.
Higher depth moves are all sorted (INT_MIN version), as in current master.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 33116 W: 6161 L: 6061 D: 20894

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 88703 W: 11572 L: 11540 D: 65591

Bench: 6256522

Closes #1058
Closes #1065

7 years agoUpdate Readme.md
Stefano Cardanobile [Mon, 17 Apr 2017 16:58:02 +0000 (18:58 +0200)]
Update Readme.md

Update number of threads.

Closes #1072

7 years agoPrefer std::find over a hand-coded loop
Joost VandeVondele [Sun, 16 Apr 2017 08:48:17 +0000 (10:48 +0200)]
Prefer std::find over a hand-coded loop

tested for no regression.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 37378 W: 6649 L: 6556 D: 24173

No functional change.

Closes #1071

7 years agoMove-Count Formula Tweak
VoyagerOne [Mon, 17 Apr 2017 16:21:16 +0000 (09:21 -0700)]
Move-Count Formula Tweak

STC:
LLR: 3.18 (-2.94,2.94) [0.00,4.00]
Total: 55004 W: 10289 L: 9930 D: 34785

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 48184 W: 6401 L: 6128 D: 35655

Bench: 5960754

7 years agoRemove cap from space score contribution and increase bonus
Stefano80 [Mon, 17 Apr 2017 16:17:41 +0000 (09:17 -0700)]
Remove cap from space score contribution and increase bonus

STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 58462 W: 10615 L: 10558 D: 37289

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 65061 W: 8539 L: 8477 D: 48045

It is worth noting that an attempt to only increase the bonus passed STC but failed LTC, and
an attempt to remove the cap without increasing the bonus is still running at STC, but will probably fail after more than 100k.

Bench: 6188591

Closes #1063

7 years agoDoubled and supported pawns
Stéphane Nicolet [Tue, 11 Apr 2017 17:50:24 +0000 (19:50 +0200)]
Doubled and supported pawns

Do not give the doubled pawn penalty when the frontmost pawn is
supported, for instance f2-g2-g3

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 55927 W: 10418 L: 10052 D: 35457
http://tests.stockfishchess.org/tests/view/58eb9fc20ebc59035df33858

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 32078 W: 4257 L: 4035 D: 23786
http://tests.stockfishchess.org/tests/view/58ec48420ebc59035df3388b

Bench: 5995472

Closes #1062

7 years agoRemove minimum to contribution from king danger to score.
Stefano80 [Sun, 9 Apr 2017 14:48:20 +0000 (07:48 -0700)]
Remove minimum to contribution from king danger to score.

STC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 24858 W: 4559 L: 4445 D: 15854

LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40789 W: 5338 L: 5244 D: 30207

Bench: 7027489

Closes #1059

7 years agoFix zugzwang pruning issues
joergoster [Sat, 8 Apr 2017 00:07:40 +0000 (17:07 -0700)]
Fix zugzwang pruning issues

By adding pos.non_pawn_material(pos.side_to_move()) as a precondition in step 13,
which is already in use in Futility Pruning (child node) and Null Move Pruning for similar reasons.

Pawn endgames, especially those with only 1 or 2 pawns, are simply heavily influenced by zugzwang situations.

Since we are using a bitbase for KPK endgames, I see no reason to accept buggy evals as shown in #760

Patch looks neutral at STC
LLR: 2.32 (-2.94,2.94) [-3.00,1.00]
Total: 79580 W: 10789 L: 10780 D: 58011

and LTC
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 27071 W: 3502 L: 3390 D: 20179

Bench: 6259071

Closes #1051
Closes #760

7 years agoStandardize stat penalty
VoyagerOne [Sat, 8 Apr 2017 00:02:31 +0000 (17:02 -0700)]
Standardize stat penalty

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 90631 W: 16325 L: 16323 D: 57983

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 97679 W: 12779 L: 12759 D: 72141

Bench: 6340591

Closes #1053

7 years agoDon't update TT at excluded move ply
VoyagerOne [Mon, 3 Apr 2017 03:31:52 +0000 (20:31 -0700)]
Don't update TT at excluded move ply

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 38906 W: 7125 L: 6835 D: 24946

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 28600 W: 3752 L: 3543 D: 21305

Bench:  6861050

Closes #1048

7 years agoAdd assertion for the maximum number of pawns
Daniel Dugovic [Tue, 21 Mar 2017 07:32:16 +0000 (02:32 -0500)]
Add assertion for the maximum number of pawns

No functionl change

Closes #1039

7 years agoIntroduce assert for stats update
Joost VandeVondele [Sun, 26 Mar 2017 00:57:07 +0000 (17:57 -0700)]
Introduce assert for stats update

Make sure updates to the stats are done in a stable way.

No functional change

Closes #1038
Closes #1037

7 years agoIncrease maximum number of threads
Joost VandeVondele [Sat, 25 Mar 2017 17:34:10 +0000 (10:34 -0700)]
Increase maximum number of threads

a single Xeon Phi can present itself as a single numa node with up to 288 threads (4 threads per hardware core).
Tested to work as expected with a Xeon Phi CPU 7230 up to 256 threads.

No functional change

Closes #1045

7 years agoSimplify ThreatBySafePawn scoring
joergoster [Sat, 25 Mar 2017 17:21:24 +0000 (10:21 -0700)]
Simplify ThreatBySafePawn scoring

Bench: 6197938

Closes #1047

7 years agoSingular extension and check extension tweak
VoyagerOne [Sat, 25 Mar 2017 17:10:33 +0000 (10:10 -0700)]
Singular extension and check extension tweak

If singular extension fails to trigger extension then don't consider check extension.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 69428 W: 12663 L: 12271 D: 44494

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 44023 W: 5875 L: 5612 D: 32536

Bench: 6170444

Closes #1043

7 years agoSkip quiet moves based on moveCount pruning threshold and history stats
VoyagerOne [Sat, 18 Mar 2017 22:41:55 +0000 (15:41 -0700)]
Skip quiet moves based on moveCount pruning threshold and history stats

If we can moveCountPrune and next quiet move has negative stats,
then go directly to the next move stage (Bad_Captures).

Reduction formula is tweaked to compensate for the decrease in move count that is used in LMR.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 6847 W: 1276 L: 1123 D: 4448

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 48687 W: 6503 L: 6226 D: 35958

Bench: 5919519

Closes #1036

7 years agoHistory stat bonus: Move condition to bonus calculation
Joost VandeVondele [Fri, 17 Mar 2017 21:45:27 +0000 (14:45 -0700)]
History stat bonus: Move condition to bonus calculation

about 0.5% speedup.

No functional change

Closes #1034

7 years agoPawns count imbalance table
joergoster [Fri, 17 Mar 2017 21:41:08 +0000 (14:41 -0700)]
Pawns count imbalance table

Instead of having a continuous increasing bonus for our number of pawns when calculating imbalance, use a separate lookup array with tuned values.
Idea by GuardianRM.

STC
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 16155 W: 2980 L: 2787 D: 10388

LTC
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 100478 W: 13055 L: 12615 D: 74808

Bench: 6128779

Closes #1030

7 years agoAssorted code style fixes
Marco Costalba [Wed, 15 Mar 2017 04:00:03 +0000 (21:00 -0700)]
Assorted code style fixes

No functional change

Closes #1029

7 years agoFix pawn entry prefetch
mstembera [Wed, 15 Mar 2017 03:56:26 +0000 (20:56 -0700)]
Fix pawn entry prefetch

No functional change

Closes #1026

7 years agoHelper functions to count material for both sides
snicolet [Thu, 9 Mar 2017 02:45:09 +0000 (18:45 -0800)]
Helper functions to count material for both sides

Syntactic sugar: helper functions to count material or pieces for both sides.

No functional change

Closes #1025

7 years agoAlways have counterMoves associated
Joost VandeVondele [Thu, 9 Mar 2017 02:35:23 +0000 (18:35 -0800)]
Always have counterMoves associated

Simplifies away all associated checks, leading to a ~0.5% speedup.
The code now explicitly checks if moves are OK, rather than using nullptr checks.

Verified for no regression:

LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 32218 W: 5762 L: 5660 D: 20796

No functional change

Closes #1021

7 years agoFurther simplify skipping of plies with threads
pb00068 [Thu, 9 Mar 2017 02:01:16 +0000 (18:01 -0800)]
Further simplify skipping of plies with threads

No functional change

Closes #1020

7 years agoAllow pruning advance pawn pushes if not near endgame
VoyagerOne [Mon, 6 Mar 2017 02:56:39 +0000 (18:56 -0800)]
Allow pruning advance pawn pushes if not near endgame

STC:
LLR: -2.95 (-2.94,2.94) [0.00,5.00]
Total: 101088 W: 18016 L: 17717 D: 65355

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 61194 W: 8108 L: 7791 D: 45295

Bench: 5803228

Closes #1023

7 years agoSpeed-up some arrays reading
snicolet [Mon, 6 Mar 2017 02:20:27 +0000 (18:20 -0800)]
Speed-up some arrays reading

This patch removes the empty rows at the beginning and at the end of
MobilityBonus[] and Protector[] arrays:

• reducing the size of MobilityBonus from 768 bytes to 512 bytes
• reducing the size of Protector from 1024 to 512 bytes

Also adds some comments and cleaner code for the arrays in pawns.cpp

No speed penalty (measured speed-up of 0.4%).

No functional change.

Closes #1018

7 years agoSimplify skipping of plies with helper threads
Joost VandeVondele [Mon, 27 Feb 2017 00:41:58 +0000 (16:41 -0800)]
Simplify skipping of plies with helper threads

Replaces the HalfDensity array with an equivalent, compact implementation.
Includes suggestions by mcostalba & snicolet.

No functional change

Closes #1004

7 years agoChange definition of "weak" in threats calculation
snicolet [Sun, 26 Feb 2017 01:43:54 +0000 (17:43 -0800)]
Change definition of "weak" in threats calculation

By defining "strongly protected" as "protected by a pawn, or protected
by two pieces and not attacked by two enemy pieces".

Passed STC:
LLR: 2.97 (-2.94,2.94) [0.00,5.00]
Total: 17050 W: 3128 L: 2931 D: 10991

Passed LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 120995 W: 15852 L: 15343 D: 89800

Bench : 6269229

Closes #1016

7 years agoReorder members of Material::Entry
mstembera [Fri, 24 Feb 2017 05:33:03 +0000 (21:33 -0800)]
Reorder members of Material::Entry

This eliminates alignment padding and reduces size from 48 to 40 bytes.
This makes the material HashTable smaller and more cache friendly.

No functional change

Closes #1013

7 years agoPieces protecting king
GuardianRM [Fri, 24 Feb 2017 05:26:59 +0000 (21:26 -0800)]
Pieces protecting king

Initial protective idea by Snicolet for knight, for other pieces too
Patch add penalties and bonuses for pieces, depending on the distance from the own king

STC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 21192 W: 3919 L: 3704 D: 13569

LTC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 26177 W: 3642 L: 3435 D: 19100

Bench : 6687377

Closes #1012

7 years agoKeep pawns on both flanks
snicolet [Sun, 19 Feb 2017 22:25:05 +0000 (14:25 -0800)]
Keep pawns on both flanks

Positions with pawns on only one flank tend to be more drawish. We add
a term to the initiative bonus to help the attacking player keep pawns
on both flanks.

STC: yellowish run stopped after 257137 games
LLR: -0.92 (-2.94,2.94) [0.00,5.00]
Total: 257137 W: 46560 L: 45511 D: 165066

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 15602 W: 2125 L: 1956 D: 11521

Bench : 6976310

Closes #1009

7 years agoVariable tuning
FauziAkram [Sun, 19 Feb 2017 21:56:17 +0000 (13:56 -0800)]
Variable tuning

A tuning patch which cover the following changes:

increase the importance of queen and rook mobility in endgame and
decrease it in mg, since if we use the heavy pieces too early in the game
we will just make opponent develop their pieces by threatening ours.

King Psqt:
1)King will be encouraged more to stay in the first ranks in the MG
2)and will be encouraged more to go to the middle of the board/last ranks in the EG

Bishop scale better in EG
Logical changes on various psqt tables
1/6 of the changes of the last tuning session on mobility tables

STC: LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 227879 W: 41240 L: 40313 D: 146326
LTC : LLR: 2.95 (-2.94,2.94) [0.00,4.00]
Total: 167047 W: 21871 L: 21291 D: 123885

Bench: 5695960

Closes #1008

7 years agoRazor Simplification
VoyagerOne [Sun, 19 Feb 2017 06:48:28 +0000 (22:48 -0800)]
Razor Simplification

Remove code that restrict using tt-moves for razoring.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 67442 W: 12039 L: 11997 D: 43406

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 38541 W: 5044 L: 4947 D: 28550

Bench: 5667216

Closes #1002

7 years agoRetire loose enemies bonus
torfranz [Wed, 15 Feb 2017 05:26:08 +0000 (21:26 -0800)]
Retire loose enemies bonus

STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 44727 W: 7943 L: 7862 D: 28922

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 148343 W: 19044 L: 19088 D: 110211

Bench: 5669076

Closes #1005

7 years agosearch(): Move nullValue variable into local scope
VoyagerOne [Wed, 15 Feb 2017 05:20:37 +0000 (21:20 -0800)]
search(): Move nullValue variable into local scope

No functional change

Closes #1003

7 years agoFix makefile: 32 bit builds without optimization.
Joost VandeVondele [Wed, 15 Feb 2017 05:11:44 +0000 (21:11 -0800)]
Fix makefile: 32 bit builds without optimization.

Fixes failing build for

make ARCH=x86-32 clean && make ARCH=x86-32 optimize=no build

by passing -m32 also to the link step.

Extend travis testing accordingly.

No functional change.

Closes #999

7 years agoRetire small bonus in passed pawn evaluation
torfranz [Sat, 11 Feb 2017 00:52:34 +0000 (16:52 -0800)]
Retire small bonus in passed pawn evaluation

STC: http://tests.stockfishchess.org/tests/view/5899824d0ebc59099759f3ee
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 33370 W: 6061 L: 5961 D: 21348

LTC: http://tests.stockfishchess.org/tests/view/5899e3820ebc59099759f415
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 36206 W: 4664 L: 4563 D: 26979

Bench: 6072262

Closes #998

7 years agoA small tweak in doEasyMove()
Joona Kiiski [Sat, 11 Feb 2017 00:42:22 +0000 (16:42 -0800)]
A small tweak in doEasyMove()

Time.elapsed() > Time.optimum() * 5 / 44
instaed of:
Time.elapsed() > Time.optimum() * 5 / 42

This was yellow on STC:
LLR: -2.96 (-2.94,2.94) [0.00,4.00]
Total: 156856 W: 28317 L: 27942 D: 100597

Passed on LTC:
LLR: 2.96 (-2.94,2.94) [0.00,4.00]
Total: 36909 W: 4926 L: 4682 D: 27301

Note: Patch was originally submitted by user GuardianRM.
However his repo was deleted before merge.

No functional change

Closes #995

7 years agoSimplify scale factor computation
Stefano80 [Mon, 6 Feb 2017 00:02:02 +0000 (16:02 -0800)]
Simplify scale factor computation

Minor non-functional simplifications in computing the scale factor.

In my opinion, the code is now slightly more readable:

- remove one condition which can never be satisfied.
- immediately return instead of assigning the sf variable.

Tested for non-regression:

LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 62162 W: 11166 L: 11115 D: 39881

No functional change

Closes #992

7 years agoSimplify Queen Mobility
VoyagerOne [Sun, 5 Feb 2017 23:39:29 +0000 (15:39 -0800)]
Simplify Queen Mobility

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 85997 W: 15550 L: 15540 D: 54907

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 25333 W: 3370 L: 3256 D: 18707

Bench: 6459194

Closes #991

7 years agoSimplify away QueenContactChecks
Stéphane Nicolet [Mon, 30 Jan 2017 21:05:43 +0000 (22:05 +0100)]
Simplify away QueenContactChecks

Changing the definition of safe checks to include
squares protected only by the king, but twice
attacked by the opponent.

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 8691 W: 1683 L: 1541 D: 5467
http://tests.stockfishchess.org/tests/view/588f53b50ebc5915193f7dc7

LTC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 31266 W: 4150 L: 4043 D: 23073
http://tests.stockfishchess.org/tests/view/588f68ab0ebc5915193f7dda

Bench : 5885815

7 years agoSimplify TT penalty stat (#980)
VoyagerOne [Sun, 29 Jan 2017 07:54:58 +0000 (02:54 -0500)]
Simplify TT penalty stat (#980)

STC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 20251 W: 3692 L: 3570 D: 12989

LTC:
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 16432 W: 2155 L: 2029 D: 12248

Bench: 5941174

7 years agoPenalty for a quiet ttMove that fails low
VoyagerOne [Wed, 25 Jan 2017 14:32:10 +0000 (09:32 -0500)]
Penalty for a quiet ttMove that fails low

Also the penalty/bonus function is misleading, we
should simply change it to stat_bonus(depth) for
bonus and -stat_bonus(depth+ ONE_PLY) for extra
penalty.

STC:
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 11656 W: 2183 L: 2008 D: 7465

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 11152 W: 1531 L: 1377 D: 8244

Bench: 6101931

7 years agoCandidate passed pawns
Stefan Geschwentner [Thu, 19 Jan 2017 17:16:23 +0000 (18:16 +0100)]
Candidate passed pawns

Detect safe candidate passers.

STC: http://tests.stockfishchess.org/tests/view/5882395c0ebc5915193f78b3
LLR: 2.96 (-2.94,2.94) [0.00,5.00]
Total: 53569 W: 9925 L: 9570 D: 34074

LTC: http://tests.stockfishchess.org/tests/view/5882b4fb0ebc5915193f78e2
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 77576 W: 10387 L: 10014 D: 57175

Bench: 5325829