1
0
Fork 0
Commit Graph

883 Commits (406979ea12ee7828e079871b0f9f3dc8f127a741)

Author SHA1 Message Date
Stéphane Nicolet 406979ea12 Embed default net, and simplify using non-default nets
covers the most important cases from the user perspective:

It embeds the default net in the binary, so a download of that binary will result
in a working engine with the default net. The engine will be functional in the default mode
without any additional user action.

It allows non-default nets to be used, which will be looked for in up to
three directories (working directory, location of the binary, and optionally a specific default directory).
This mechanism is also kept for those developers that use MSVC,
the one compiler that doesn't have an easy mechanism for embedding data.

It is possible to disable embedding, and instead specify a specific directory, e.g. linux distros might want to use
CXXFLAGS="-DNNUE_EMBEDDING_OFF -DDEFAULT_NNUE_DIRECTORY=/usr/share/games/stockfish/" make -j ARCH=x86-64 profile-build

passed STC non-regression:
https://tests.stockfishchess.org/tests/view/5f4a581c150f0aef5f8ae03a
LLR: 2.95 (-2.94,2.94) {-1.25,-0.25}
Total: 66928 W: 7202 L: 7147 D: 52579
Ptnml(0-2): 291, 5309, 22211, 5360, 293

closes https://github.com/official-stockfish/Stockfish/pull/3070

fixes https://github.com/official-stockfish/Stockfish/issues/3030

No functional change.
2020-08-29 21:56:00 +02:00
Joost VandeVondele 5f1843c9cb Small trivial cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2801

No functional change
2020-08-23 01:53:41 +02:00
MJZ1977 cbcb05ca09 Display classic and NNUE evaluation in trace mode
show both the classical and NNUE evaluation,
as well as the Final evaluation.

closes https://github.com/official-stockfish/Stockfish/pull/3042

No functional change.
2020-08-22 10:58:08 +02:00
Joost VandeVondele a1ad8604a1 Send error message as an UCI info string
some GUIs do not show the error message when the engine terminates in the no-net case, as it is send to cerr.
Instead send it as an info string, which the GUI will more likely display.

closes https://github.com/official-stockfish/Stockfish/pull/3031

No functional change.
2020-08-20 21:13:07 +02:00
mstembera 1bcc981a5a Fallback to NNUE
If the classical eval ends up much smaller than estimated fall back to NNUE.
Also use multiply instead of divide for the threshold comparison for smoother transitions without rounding.

STC https://tests.stockfishchess.org/tests/view/5f3a5011b38d442594aabdfe
LLR: 2.96 (-2.94,2.94) {-0.50,1.50}
Total: 57352 W: 6325 L: 6135 D: 44892
Ptnml(0-2): 277, 4748, 18482, 4846, 323

LTC https://tests.stockfishchess.org/tests/view/5f3aee9db38d442594aabe82
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 16232 W: 897 L: 781 D: 14554
Ptnml(0-2): 19, 679, 6616, 771, 31

closes https://github.com/official-stockfish/Stockfish/pull/3023

bench: 4026216

-----

Recommended net: https://tests.stockfishchess.org/api/nn/nn-82215d0fd0df.nnue
2020-08-18 08:36:57 +02:00
Joost VandeVondele cd0b8b4cf2 Use NNUE more for fortresses
Increases the use of NNUE evaluation in positions without captures/pawn moves,
by increasing the NNUEThreshold threshold with rule50_count.

This patch will force Stockfish to use NNUE eval more and more in materially
unbalanced positions, when it seems that the classical eval is struggling to
win and only manages to shuffle. This will ask the (slower) NNUE eval to
double-check the potential fortress branches of the search tree, but only
when necessary.

passed STC:
https://tests.stockfishchess.org/tests/view/5f36f1bf11a9b1a1dbf192d8
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 51824 W: 5836 L: 5653 D: 40335
Ptnml(0-2): 264, 4356, 16512, 4493, 287

passed LTC:
https://tests.stockfishchess.org/tests/view/5f37836111a9b1a1dbf1936d
LLR: 2.93 (-2.94,2.94) {0.25,1.75}
Total: 29768 W: 1747 L: 1590 D: 26431
Ptnml(0-2): 33, 1347, 11977, 1484, 43

closes https://github.com/official-stockfish/Stockfish/pull/3011

Bench: 4173967
2020-08-16 08:20:32 +02:00
mstembera 6eb186c97e Try to match relative magnitude of NNUE eval to classical
The idea is that since we are mixing NNUE and classical evals matching their magnitudes closer allows for better comparisons.

STC https://tests.stockfishchess.org/tests/view/5f35a65411a9b1a1dbf18e2b
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 9840 W: 1150 L: 1027 D: 7663
Ptnml(0-2): 49, 772, 3175, 855, 69

LTC https://tests.stockfishchess.org/tests/view/5f35bcbe11a9b1a1dbf18e47
LLR: 2.93 (-2.94,2.94) {0.25,1.75}
Total: 44424 W: 2492 L: 2294 D: 39638
Ptnml(0-2): 42, 2015, 17915, 2183, 57

also corrects the location to clamp the evaluation (non-function on bench).

closes https://github.com/official-stockfish/Stockfish/pull/3003

bench: 3905447
2020-08-14 16:39:52 +02:00
Miguel Lahoz e5f450cf0b Also dampen NNUE eval with 50 move rule
Move the existing dampening function last so that NNUE evaluations are
also handled as we approach the 50 move rule.

STC:
LLR: 2.95 (-2.94,2.94) {-0.50,1.50}
Total: 4792 W: 695 L: 561 D: 3536
Ptnml(0-2): 19, 420, 1422, 478, 57
https://tests.stockfishchess.org/tests/view/5f3164179081672066537534

LTC:
LLR: 8.62 (-2.94,2.94) {0.25,1.75}
Total: 286744 W: 18494 L: 17430 D: 250820
Ptnml(0-2): 418, 14886, 111745, 15860, 463
https://tests.stockfishchess.org/tests/view/5f316b039081672066537541

closes https://github.com/official-stockfish/Stockfish/pull/3004

Bench: 4001800
2020-08-14 16:31:18 +02:00
jjoshua2 a54f9011c3 simplying hybrid condition
STC https://tests.stockfishchess.org/tests/view/5f3059d1908167206653736b:
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 12520 W: 766 L: 727 D: 11027
Ptnml(0-2): 13, 624, 4949, 659, 15

LTC: https://tests.stockfishchess.org/tests/view/5f30863a90816720665373d1
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 12520 W: 766 L: 727 D: 11027
Ptnml(0-2): 13, 624, 4949, 659, 15

closes: https://github.com/official-stockfish/Stockfish/pull/2965

Bench: 4084753
2020-08-10 07:34:45 +02:00
Vizvezdenec 2bfde55429 Adjust NNUE usage based on number of pawns in position
The idea of this patch is that positions are usually more complex and hard to evaluate even if there are more pawns.
This patch adjusts NNUE threshold usage depending on number of pawns in position, if pawn count is <3 we use the
classical evaluation more often, for pawn count = 3 patch the is non-functional,
with pawn count > 3 NNUE evaluation is used more often.

passed STC
https://tests.stockfishchess.org/tests/view/5f2f02d09081672066536b1f
LLR: 2.96 (-2.94,2.94) {-0.50,1.50}
Total: 36520 W: 5011 L: 4823 D: 26686
Ptnml(0-2): 299, 3482, 10548, 3594, 337

passed LTC
https://tests.stockfishchess.org/tests/view/5f2f4c329081672066536b5c
LLR: 2.98 (-2.94,2.94) {0.25,1.75}
Total: 39272 W: 2630 L: 2433 D: 34209
Ptnml(0-2): 53, 2066, 15218, 2229, 70

closes https://github.com/official-stockfish/Stockfish/pull/2960

bench 4084753
2020-08-09 21:26:17 +02:00
Joost VandeVondele 320fa1b2f0 Improve error message on missing net.
small rewording, but also print the download url for the default net.

closes https://github.com/official-stockfish/Stockfish/pull/2954

No functional change
2020-08-09 17:09:18 +02:00
U-DESKTOP-3900\Mark 23ecf3d5c6 simplified and increased threshold to switch between NNUE and classical
STC https://tests.stockfishchess.org/tests/view/5f2deb1661e3b6af6488200f
LLR: 2.96 (-2.94,2.94) {-1.50,0.50}
Total: 10376 W: 1481 L: 1359 D: 7536
Ptnml(0-2): 91, 953, 2981, 1069, 94

LTC: https://tests.stockfishchess.org/html/live_elo.html?5f2e0a0461e3b6af64882019
LLR: 2.99 (-2.94,2.94) {-1.50,0.50}
Total: 5040 W: 375 L: 315 D: 4350
Ptnml(0-2): 7, 263, 1926, 311, 13

closes https://github.com/official-stockfish/Stockfish/pull/2934

Bench: 4067325
2020-08-08 08:40:51 +02:00
Lolligerhans 5ccff25df2 Expand outposts to minors shielded by pawns
Allow any pawn in front of a minor piece to replace the pawn protection
requirement for outposts.

  +-------+  +-------+
  | . . o |  | o . . |    o  Their pawns
  | . o x |  | o . . |    x  Our pawns
  | o N . |  | x o B |  N,B  New (reachable) outpost
  | . . . |  | . _ . |    _  Reachable square behind a pawn
  +-------+  +-------+
  N outpost  B reaches
               outpost

  We want outposts to be secured by pawns against major pieces. If
a minor is shielded by any pawn from above, it is rarely at the same
time protected by our pawn attacks from below. However, the pawn shield
in itself offers some degree of protection.
  A pawn shield will now suffice to replace the pawn protection for the
outpost (and reachable outpost) bonus.

This effect stacks with the existing "minor behind pawn" bonus.

STC
https://tests.stockfishchess.org/tests/view/5f2bcd14b3ebe5cbfee85b2c
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 27248 W: 5353 L: 5119 D: 16776
Ptnml(0-2): 462, 3174, 6185, 3274, 529

LTC
https://tests.stockfishchess.org/tests/view/5f2bfef5b3ebe5cbfee85b5a
LLR: 2.96 (-2.94,2.94) {0.25,1.75}
Total: 99432 W: 12580 L: 12130 D: 74722
Ptnml(0-2): 696, 8903, 30049, 9391, 677

Closes #2935

Bench: 4143673
2020-08-08 08:31:06 +02:00
UnaiCorzo 7f336dd59b Remove QueenInfiltration
STC https://tests.stockfishchess.org/tests/view/5f2955b1a5abc164f05e4c85
LLR: 2.96 (-2.94,2.94) {-1.50,0.50}
Total: 29216 W: 5560 L: 5416 D: 18240
Ptnml(0-2): 466, 3329, 6902, 3417, 494

LTC https://tests.stockfishchess.org/tests/view/5f299154a5abc164f05e4ca1
LLR: 2.92 (-2.94,2.94) {-1.50,0.50}
Total: 54144 W: 6635 L: 6594 D: 40915
Ptnml(0-2): 372, 4859, 16536, 4966, 339

closes https://github.com/official-stockfish/Stockfish/pull/2910

Bench: 4609008
2020-08-07 09:00:45 +02:00
Stefan Geschwentner 8b8412ef87 Add tempo also to NNUE eval.
STC:
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 10608 W: 1507 L: 1358 D: 7743
Ptnml(0-2): 94, 945, 3074, 1100, 91
https://tests.stockfishchess.org/tests/view/5f2c5921b3ebe5cbfee85b8b

LTC:
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 7536 W: 556 L: 448 D: 6532
Ptnml(0-2): 9, 383, 2881, 481, 14
https://tests.stockfishchess.org/tests/view/5f2c6f4461e3b6af64881e95

closes https://github.com/official-stockfish/Stockfish/pull/2919

Bench: 4746616
2020-08-07 08:54:38 +02:00
MJZ1977 3dca13a958 NNUE evaluation threshold
The idea is to use NNUE only on quite balanced material positions. This bring a big speedup on research since NNUE eval is slower than classical eval for most of the hardwares and specially on unbalanced positions with LazyEval.

STC: https://tests.stockfishchess.org/tests/view/5f2c2680b3ebe5cbfee85b61
LLR: 2.95 (-2.94,2.94) {-0.50,1.50}
Total: 3168 W: 560 L: 400 D: 2208
Ptnml(0-2): 21, 294, 819, 404, 46

LTC: https://tests.stockfishchess.org/tests/view/5f2c2ca6b3ebe5cbfee85b69
LLR: 2.98 (-2.94,2.94) {0.25,1.75}
Total: 3200 W: 287 L: 183 D: 2730
Ptnml(0-2): 4, 149, 1191, 251, 5

closes https://github.com/official-stockfish/Stockfish/pull/2916

Bench 4746616
2020-08-06 21:46:31 +02:00
nodchip 84f3e86790 Add NNUE evaluation
This patch ports the efficiently updatable neural network (NNUE) evaluation to Stockfish.

Both the NNUE and the classical evaluations are available, and can be used to
assign a value to a position that is later used in alpha-beta (PVS) search to find the
best move. The classical evaluation computes this value as a function of various chess
concepts, handcrafted by experts, tested and tuned using fishtest. The NNUE evaluation
computes this value with a neural network based on basic inputs. The network is optimized
and trained on the evalutions of millions of positions at moderate search depth.

The NNUE evaluation was first introduced in shogi, and ported to Stockfish afterward.
It can be evaluated efficiently on CPUs, and exploits the fact that only parts
of the neural network need to be updated after a typical chess move.
[The nodchip repository](https://github.com/nodchip/Stockfish) provides additional
tools to train and develop the NNUE networks.

This patch is the result of contributions of various authors, from various communities,
including: nodchip, ynasu87, yaneurao (initial port and NNUE authors), domschl, FireFather,
rqs, xXH4CKST3RXx, tttak, zz4032, joergoster, mstembera, nguyenpham, erbsenzaehler,
dorzechowski, and vondele.

This new evaluation needed various changes to fishtest and the corresponding infrastructure,
for which tomtor, ppigazzini, noobpwnftw, daylen, and vondele are gratefully acknowledged.

The first networks have been provided by gekkehenker and sergiovieri, with the latter
net (nn-97f742aaefcd.nnue) being the current default.

The evaluation function can be selected at run time with the `Use NNUE` (true/false) UCI option,
provided the `EvalFile` option points the the network file (depending on the GUI, with full path).

The performance of the NNUE evaluation relative to the classical evaluation depends somewhat on
the hardware, and is expected to improve quickly, but is currently on > 80 Elo on fishtest:

60000 @ 10+0.1 th 1
https://tests.stockfishchess.org/tests/view/5f28fe6ea5abc164f05e4c4c
ELO: 92.77 +-2.1 (95%) LOS: 100.0%
Total: 60000 W: 24193 L: 8543 D: 27264
Ptnml(0-2): 609, 3850, 9708, 10948, 4885

40000 @ 20+0.2 th 8
https://tests.stockfishchess.org/tests/view/5f290229a5abc164f05e4c58
ELO: 89.47 +-2.0 (95%) LOS: 100.0%
Total: 40000 W: 12756 L: 2677 D: 24567
Ptnml(0-2): 74, 1583, 8550, 7776, 2017

At the same time, the impact on the classical evaluation remains minimal, causing no significant
regression:

sprt @ 10+0.1 th 1
https://tests.stockfishchess.org/tests/view/5f2906a2a5abc164f05e4c5b
LLR: 2.94 (-2.94,2.94) {-6.00,-4.00}
Total: 34936 W: 6502 L: 6825 D: 21609
Ptnml(0-2): 571, 4082, 8434, 3861, 520

sprt @ 60+0.6 th 1
https://tests.stockfishchess.org/tests/view/5f2906cfa5abc164f05e4c5d
LLR: 2.93 (-2.94,2.94) {-6.00,-4.00}
Total: 10088 W: 1232 L: 1265 D: 7591
Ptnml(0-2): 49, 914, 3170, 843, 68

The needed networks can be found at https://tests.stockfishchess.org/nns
It is recommended to use the default one as indicated by the `EvalFile` UCI option.

Guidelines for testing new nets can be found at
https://github.com/glinscott/fishtest/wiki/Creating-my-first-test#nnue-net-tests

Integration has been discussed in various issues:
https://github.com/official-stockfish/Stockfish/issues/2823
https://github.com/official-stockfish/Stockfish/issues/2728

The integration branch will be closed after the merge:
https://github.com/official-stockfish/Stockfish/pull/2825
https://github.com/official-stockfish/Stockfish/tree/nnue-player-wip

closes https://github.com/official-stockfish/Stockfish/pull/2912

This will be an exciting time for computer chess, looking forward to seeing the evolution of
this approach.

Bench: 4746616
2020-08-06 16:37:45 +02:00
Stéphane Nicolet 33f3cfae00 Improve handling of queen imbalance
We double the bonus for potential threats by minors and rooks against
our queen, in case of "queen vs pieces imbalance". Hopefully this will
improve a little bit the evaluation for this well-known Stockfish weakness.

passed STC:
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 72976 W: 14003 L: 13710 D: 45263
Ptnml(0-2): 1218, 8370, 17094, 8513, 1293
https://tests.stockfishchess.org/tests/view/5efa50eb020eec13834a977d

passed LTC:
LLR: 2.93 (-2.94,2.94) {0.25,1.75}
Total: 22232 W: 2779 L: 2560 D: 16893
Ptnml(0-2): 129, 1885, 6896, 2050, 156
https://tests.stockfishchess.org/tests/view/5f1fdd2dc09435d870cb9f13

closes https://github.com/official-stockfish/Stockfish/pull/2864

Bench: 4367349
2020-07-31 10:01:39 +02:00
protonspring f0abde241d Remove conditional_more_than_two().
This is a functional simplification that removes the conditional_more_than_two()
function, which was quite strange and kooky. Note the very minor change to the bench
value.

See this thread for relevant comments on the passing branch:
protonspring/Stockfish@d89730d...ff35b50

STC
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 59760 W: 11411 L: 11311 D: 37038
Ptnml(0-2): 992, 6863, 14044, 7015, 966
https://tests.stockfishchess.org/tests/view/5f179988c09435d870cb9b9a

LTC
LLR: 2.93 (-2.94,2.94) {-1.50,0.50}
Total: 45208 W: 5553 L: 5497 D: 34158
Ptnml(0-2): 315, 4081, 13761, 4127, 320
https://tests.stockfishchess.org/tests/view/5f184847c09435d870cb9bee

closes https://github.com/official-stockfish/Stockfish/pull/2826

Bench: 4578290
2020-07-31 09:47:24 +02:00
mstembera c3092c54bc Multiple lazy stages.
An extension of the lazy eval idea: when the score is sufficiently large
we now skip more granular parts of the eval.

Inspired by an original patch by Moez Jellouli
https://tests.stockfishchess.org/tests/view/5f03b2a159f6f03532894529
Credit to him!

STC https://tests.stockfishchess.org/tests/view/5f0a862c59f6f03532894924
LLR: 2.95 (-2.94,2.94) {-0.50,1.50}
Total: 13504 W: 2684 L: 2472 D: 8348
Ptnml(0-2): 229, 1496, 3111, 1666, 250

LTC https://tests.stockfishchess.org/tests/view/5f0ac0e159f6f0353289495b
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 31312 W: 3926 L: 3677 D: 23709
Ptnml(0-2): 185, 2773, 9509, 2986, 203

closes https://github.com/official-stockfish/Stockfish/pull/2814

bench: 4541608
2020-07-17 20:24:02 +02:00
SFisGOD 1f3bd968bb Introduce bad outpost penalty
In some French games, Stockfish likes to bring the Knight to a bad outpost spot. This is evident in TCEC S18 Superfinal Game 63, where there is a Knight outpost on the queenside but is actually useless. Stockfish is effectively playing a piece down while holding ground against Leela's break on the kingside.

This patch turns the +56 mg bonus for a Knight outpost into a -7 mg penalty if it satisfies the following conditions:

* The outpost square is not on the CenterFiles (i.e. not on files C,D,E and F)
* The knight is not attacking non pawn enemies.
* The side where the outpost is located contains only few enemies, with a particular conditional_more_than_two() implementation

Thank you to apospa...@gmail.com for bringing this to our attention and for providing insights.
See https://groups.google.com/forum/?fromgroups=#!topic/fishcooking/dEXNzSIBgZU
Reference game: https://tcec-chess.com/#div=sf&game=63&season=18

Passed STC:
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 6960 W: 1454 L: 1247 D: 4259
Ptnml(0-2): 115, 739, 1610, 856, 160
https://tests.stockfishchess.org/tests/view/5f08221059f6f0353289477e

Passed LTC:
LLR: 2.98 (-2.94,2.94) {0.25,1.75}
Total: 21440 W: 2767 L: 2543 D: 16130
Ptnml(0-2): 122, 1904, 6462, 2092, 140
https://tests.stockfishchess.org/tests/view/5f0838ed59f6f035328947a2

various related tests show strong test results, but so far no generalizations or simplifications of conditional_more_than_two() are found. See PR for details.

closes https://github.com/official-stockfish/Stockfish/pull/2803

Bench: 4366686
2020-07-11 11:23:55 +02:00
Joost VandeVondele 4006f2c913 Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2772

No functional change
2020-07-09 22:01:06 +02:00
SFisGOD 67818ee948 Remove passed pawn condition.
This will help scale down relatively high eval in drawish rook endgames with passed pawn like in TCEC S18 Superfinal Game 90.

Passed STC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 50456 W: 9644 L: 9540 D: 31272
Ptnml(0-2): 760, 5637, 12332, 5737, 762
https://tests.stockfishchess.org/tests/view/5efcb76e59f6f035328940ed

Passed LTC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 77264 W: 9518 L: 9518 D: 58228
Ptnml(0-2): 402, 6766, 24321, 6716, 427
https://tests.stockfishchess.org/tests/view/5efd2ad759f6f03532894143

closes https://github.com/official-stockfish/Stockfish/pull/2792

Bench: 4431626
2020-07-03 21:09:22 +02:00
Alain SAVARD 268c00b648 Use arrays
for safe checks, outposts and king protectors in evaluate.cpp

Tested for non regression on the safe checks
https://tests.stockfishchess.org/tests/view/5ef8b75c020eec13834a9596
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 22256 W: 4283 L: 4143 D: 13830
Ptnml(0-2): 291, 2439, 5588, 2459, 351

Tested for non regression on the safe checks, outposts and king protectors
https://tests.stockfishchess.org/tests/view/5ef8e543020eec13834a95e7
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 28400 W: 5382 L: 5253 D: 17765
Ptnml(0-2): 394, 3078, 7119, 3223, 386

closes https://github.com/official-stockfish/Stockfish/pull/2785

No functional change
2020-07-03 21:06:36 +02:00
Stefan Geschwentner 69d3be42a1 Tweak single queen endgame scaling.
Increase scaling factor for each minor of the opponent side of the queen.

STC:
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 14528 W: 2860 L: 2653 D: 9015
Ptnml(0-2): 217, 1632, 3408, 1741, 266
https://tests.stockfishchess.org/tests/view/5ef98384020eec13834a96a0

LTC:
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 34584 W: 4371 L: 4111 D: 26102
Ptnml(0-2): 205, 3080, 10501, 3262, 244
https://tests.stockfishchess.org/tests/view/5ef99972020eec13834a96c9

closes https://github.com/official-stockfish/Stockfish/pull/2782

Bench: 4523573
2020-06-29 20:02:58 +02:00
Stéphane Nicolet c7194bd924 Scale down eval for queen imbalance
We lower the endgame value of the evaluation when we detect that there
is only one queen left on the board (more precisely, we use a scale
factor of 37/64, or about 0.58, for the endgame part of the evaluation).
Hopefully this helps a little bit for the assessment of positions with
queen imbalance, which are one of the well-known Stockfish weaknesses.

STC:
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 21600 W: 4176 L: 3955 D: 13469
Ptnml(0-2): 351, 2457, 5003, 2598, 391
https://tests.stockfishchess.org/tests/view/5ef871b6020eec13834a94e8

LTC:
LLR: 2.97 (-2.94,2.94) {0.25,1.75}
Total: 248328 W: 30596 L: 29720 D: 188012
Ptnml(0-2): 1544, 22345, 75665, 22911, 1699
https://tests.stockfishchess.org/tests/view/5ef87aec020eec13834a94fe

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

Bench: 4441323
2020-06-28 22:42:43 +02:00
Stefan Geschwentner 16836f39b2 Scale down eval for drawish rook endgames.
STC:
LLR: 2.96 (-2.94,2.94) {-0.50,1.50}
Total: 82136 W: 15694 L: 15407 D: 51035
Ptnml(0-2): 1076, 8960, 20767, 9131, 1134
https://tests.stockfishchess.org/tests/view/5ef86cf8020eec13834a94dd

LTC:
LLR: 2.93 (-2.94,2.94) {0.25,1.75}
Total: 70200 W: 8787 L: 8440 D: 52973
Ptnml(0-2): 325, 5983, 22170, 6264, 358
https://tests.stockfishchess.org/tests/view/5ef88225020eec13834a950a

closes https://github.com/official-stockfish/Stockfish/pull/2780

Bench: 4478869
2020-06-28 22:05:09 +02:00
Joost VandeVondele ab5cd8340f Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2756

No functional change
2020-06-24 22:20:04 +02:00
FauziAkram e9966d9a8e Introduce bonus for queen infiltration
Idea is that queen feels much better when it can't be kicked away now
or later by pawn moves, especially in endgame. Special thanks to
Linmiao Xu for the original idea of this patch.

passed STC:
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 84008 W: 16271 L: 15958 D: 51779
Ptnml(0-2): 1476, 9688, 19420, 9887, 1533
https://tests.stockfishchess.org/tests/view/5eee7ca0447c5b640047a439

passed LTC:
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 11720 W: 1522 L: 1328 D: 8870
Ptnml(0-2): 52, 1021, 3574, 1107, 106
https://tests.stockfishchess.org/tests/view/5eefc588122d6514328d75f9

closes https://github.com/official-stockfish/Stockfish/pull/2759

Bench: 4471740
2020-06-22 12:47:14 +02:00
Joost VandeVondele 6f15e7fab2 small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2695

No functional change
2020-06-21 15:22:20 +02:00
Joost VandeVondele 4d657618e9 Quantize eval to multiples of 16
Removes some excess precision, helps searchs.

Effectively reintroduces evaluation grain, with a slightly different context.
45dbd9cd03

passed STC
LLR: 2.97 (-2.94,2.94) {-0.50,1.50}
Total: 197032 W: 37938 L: 37462 D: 121632
Ptnml(0-2): 3359, 22994, 45446, 23246, 3471
https://tests.stockfishchess.org/tests/view/5ee0c228f29b40b0fc95ae53

passed LTC
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 77696 W: 9970 L: 9581 D: 58145
Ptnml(0-2): 530, 7075, 23311, 7340, 592
https://tests.stockfishchess.org/tests/view/5ee21426f29b40b0fc95af43

passed LTC SMP
LLR: 2.96 (-2.94,2.94) {0.25,1.75}
Total: 64136 W: 7425 L: 7091 D: 49620
Ptnml(0-2): 345, 5416, 20228, 5718, 361
https://tests.stockfishchess.org/tests/view/5ee387bbf29b40b0fc95b04c

closes https://github.com/official-stockfish/Stockfish/pull/2733

Bench: 4939103
2020-06-13 07:10:34 +02:00
Stéphane Nicolet 3af083a7cd Improve the anti-shuffling policy
We replace the current decrease of the complexity term in initiative
when shuffling by a direct damping of the evaluation. This scheme may
have two benefits over the initiative approach:

a) the damping effect is more brutal for fortresses with heavy pieces
   on the board, because the initiative term is almost an endgame term;

b) the initiative implementation had a funny side effect, almost a bug,
   in the rare positions where mg > 0, eg < 0 and the tampered eval
   returned a positive value (ie with heavy pieces still on the board):
   sending eg to zero via shuffling would **increase** the tampered
   eval instead of decreasing it, which is somewhat illogical. This
   patch avoids this phenomenon.

STC:
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 43072 W: 8373 L: 8121 D: 26578
Ptnml(0-2): 729, 4954, 9940, 5162, 751
https://tests.stockfishchess.org/tests/view/5ee008ebf29b40b0fc95ade2

LTC:
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 37376 W: 4816 L: 4543 D: 28017
Ptnml(0-2): 259, 3329, 11286, 3508, 306
https://tests.stockfishchess.org/tests/view/5ee03b06f29b40b0fc95ae0c

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

Bench: 4757174
2020-06-10 13:07:12 +02:00
protonspring b0eb5a1ba3 Wrap all access to LineBB and add assert
This is a non-functional code style change which provides a safe access handler for LineBB.
Also includes an assert in debug mode to verify square correctness.

closes https://github.com/official-stockfish/Stockfish/pull/2719

No functional change
2020-06-09 18:13:24 +02:00
xoto10 902309020a join scale_factor, initiative and mg+eg reduction
Merging this code into one function `winnable()`.
Should allow common concepts used to adjust the eg value,
either by addition or scaling, to be combined more effectively.

Improve trace function.

closes https://github.com/official-stockfish/Stockfish/pull/2710

No functional change.
2020-06-09 18:11:44 +02:00
Stefan Geschwentner d1ec10cd4f Give bonus for bishops that are alligned with enemy kingring.
Inspired by the succesful patch "Give bonus for rooks that are alligned with enemy kingring" from Vizvezdenec,
this idea has been reused for bishops. Here, we only consider attacks that are not blocked by any pawn.
Also we have a 50% higher bonus than for the rooks.

STC:
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 68960 W: 13495 L: 13202 D: 42263
Ptnml(0-2): 1213, 8018, 15802, 8157, 1290
https://tests.stockfishchess.org/tests/view/5ed27495042fa6d77c3553aa

LTC:
LLR: 2.96 (-2.94,2.94) {0.25,1.75}
Total: 54560 W: 7105 L: 6780 D: 40675
Ptnml(0-2): 379, 4986, 16254, 5253, 408
https://tests.stockfishchess.org/tests/view/5ed30375596e6dc1e1f97425

closes https://github.com/official-stockfish/Stockfish/pull/2708

Bench: 4860021
2020-06-01 17:35:02 +02:00
protonspring a5e3b4edde Consolidate all attacks bitboards
This is a non-functional simplification that simplifies getting attacks bitboards.

* consolidates all attacks to attacks_bb (remove Position::attacks_from(..)).
* attacks_bb<PieceType>(square) gets pseudo attacks
* attacks_bb<PieceType>(square, bitboard) gets attacks considering occupied squares in the bitboard).
* pawn_attacks_bb(Color, Square) gets pawn attacks like other pawn attack bitboards.
* Wraps all access to PawnAttacks arrays and PseudoAttacks arrays and adds asserts as appropriate.

Passed STC
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 90208 W: 17533 L: 17482 D: 55193
Ptnml(0-2): 1412, 10232, 21798, 10217, 1445
https://tests.stockfishchess.org/tests/view/5ece996275787cc0c05d9790

closes https://github.com/official-stockfish/Stockfish/pull/2703

No functional change
2020-05-30 20:30:31 +02:00
Vizvezdenec d40d04c17c Give bonus for rooks that are alligned with enemy kingring
The idea of this patch is that if rooks are not directly attacking the opponent king,
they can support king attacks staying behind pawns or minor pieces and be really
deadly if position slightly opens up at enemy king ring ranks. Loosely based on
some stockfish games where it underestimated attacks on it king when enemy has one
or two rooks supporting pawn pushes towards it king.

passed STC
https://tests.stockfishchess.org/tests/view/5ecb093680f2c838b96550f9
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 53672 W: 10535 L: 10265 D: 32872
Ptnml(0-2): 952, 6210, 12258, 6448, 968

passed LTC
https://tests.stockfishchess.org/tests/view/5ecb639f80f2c838b9655117
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 62424 W: 8094 L: 7748 D: 46582
Ptnml(0-2): 426, 5734, 18565, 6042, 445

closes https://github.com/official-stockfish/Stockfish/pull/2700

Bench: 4663220
2020-05-25 22:18:56 +02:00
FauziAkram 86575bcdd8 Queen Mobility Tweak
It's ok to have low mobility values for the Queen in the middlegame, but it's absolutely not ok to have low mobility values for the Queen in the endgame.
Decrease penalty for bad mobility in MG and increase it in EG.

STC:
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 17264 W: 3424 L: 3206 D: 10634
Ptnml(0-2): 279, 2004, 3893, 2132, 324
https://tests.stockfishchess.org/tests/view/5ec8f9c1526edcbe9091eba1

LTC:
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 175016 W: 22071 L: 21404 D: 131541
Ptnml(0-2): 1195, 15796, 52914, 16353, 1250
https://tests.stockfishchess.org/tests/view/5ec9057c404591b2793007df

closes https://github.com/official-stockfish/Stockfish/pull/2697

Bench: 4487054
2020-05-23 22:06:26 +02:00
Joost VandeVondele 383b12e1a5 small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2653

No functional change
2020-05-23 13:27:16 +02:00
Stefan Geschwentner 09c6917d05 Tweak knight mobility
New tuned values for knight mobility in endgames.

STC:
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 112576 W: 21999 L: 21644 D: 68933
Ptnml(0-2): 2009, 13084, 25735, 13463, 1997
https://tests.stockfishchess.org/tests/view/5ec58379377121ac09e10272

LTC:
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 125192 W: 16200 L: 15671 D: 93321
Ptnml(0-2): 891, 11584, 37182, 11983, 956
https://tests.stockfishchess.org/tests/view/5ec5c0b8377121ac09e1028b

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

Bench: 4778956
2020-05-21 14:11:14 +02:00
Stéphane Nicolet 6c1af710d1 A combo of parameters tweaks
This patch is a combinaison of two recent parameters tweaks which had
failed narrowly (yellow) at long time control:

• improvement in move ordering during search by softening the distinction
  between bad captures and good captures during move generation, leading
  to improved awareness of Stockfish of potential piece sacrifices (idea
  by Rahul Dsilva)
• increase in the weight of pawns in the "initiative" part of the evaluation
  function. With this change Stockfish should have more incentive to exchange
  pawns when losing, and to keep pawns when winning.

STC:
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 10704 W: 2178 L: 1974 D: 6552
Ptnml(0-2): 168, 1185, 2464, 1345, 190
https://tests.stockfishchess.org/tests/view/5ec5553b377121ac09e1023d

LTC:
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 60592 W: 7835 L: 7494 D: 45263
Ptnml(0-2): 430, 5514, 18086, 5817, 449
https://tests.stockfishchess.org/tests/view/5ec55ca2377121ac09e10249

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

Bench: 4519117
2020-05-21 14:05:07 +02:00
protonspring 20ceeac8b3 Simplify evaluation for blocked passers.
This is a functional simplification of the evaluation code for blocked passers.
I've also changed a few variable names for clarity.

STC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 141984 W: 27450 L: 27466 D: 87068
Ptnml(0-2): 2414, 16511, 33175, 16461, 2431
https://tests.stockfishchess.org/tests/view/5ec4001b05aa4bc72d9759e7

LTC
LLR: 2.93 (-2.94,2.94) {-1.50,0.50}
Total: 30536 W: 3966 L: 3885 D: 22685
Ptnml(0-2): 216, 2841, 9073, 2922, 216
https://tests.stockfishchess.org/tests/view/5ec4bd0d377121ac09e101b7

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

Bench: 4704681
2020-05-21 13:57:50 +02:00
Stéphane Nicolet cca643669d Move 50 moves counter to initiative.
simplify the usage of the 50 moves counter,
moving it frome the scale factor to initiative.

This patch was inspired by recent games where a blocked or semi-blocked position
was 'blundered', by moving a pawn, into a lost endgame. This patch improves this situation,
finding a more robust move more often.

for example (1s searches with many threads):
```
FEN 8/p3kp2/Pp2p3/1n2PpP1/5P2/1Kp5/8/R7 b - - 68 143

master:
      6 bestmove b5c7
      6 bestmove e7e8
     12 bestmove e7d8
    176 bestmove e7d7
patch:
      3 bestmove b5c7
      5 bestmove e7d8
    192 bestmove e7d7
```

fixes https://github.com/official-stockfish/Stockfish/issues/2620

the patch also tests well

passed STC
LLR: 2.94 (-2.94,2.94) {-1.50,0.50}
Total: 50168 W: 9508 L: 9392 D: 31268
Ptnml(0-2): 818, 5873, 11616, 5929, 848
https://tests.stockfishchess.org/tests/view/5ebb07287dd5693aad4e680b

passed LTC
LLR: 2.93 (-2.94,2.94) {-1.50,0.50}
Total: 7520 W: 981 L: 870 D: 5669
Ptnml(0-2): 49, 647, 2256, 760, 48
https://tests.stockfishchess.org/tests/view/5ebbff747dd5693aad4e6858

closes https://github.com/official-stockfish/Stockfish/pull/2666

Bench: 4395562
2020-05-14 20:34:15 +02:00
xoto10 a91cb9fc1b Penalty for all enemy pawns xrayed by our bishop.
STC:
LLR: 2.93 (-2.94,2.94) {-0.50,1.50}
Total: 159760 W: 30229 L: 29813 D: 99718
Ptnml(0-2): 2659, 18309, 37534, 18713, 2665
https://tests.stockfishchess.org/tests/view/5eb1d5032326444a3b6d33ce

LTC:
LLR: 2.93 (-2.94,2.94) {0.25,1.75}
Total: 26496 W: 3908 L: 3656 D: 18932
Ptnml(0-2): 192, 2512, 7610, 2720, 214
https://tests.stockfishchess.org/tests/view/5eb1e2dd2326444a3b6d33f9

closes https://github.com/official-stockfish/Stockfish/pull/2662

Bench 5185517
2020-05-06 16:20:01 +02:00
Vizvezdenec eb4a124b88 Refine scale factor of opposite colored bishops endgames.
This patch makes it dependant on the count of passed pawns of
the strong side instead of 22/64 in every case.

passed STC
https://tests.stockfishchess.org/tests/view/5ead60966ffeed51f6e32591
LLR: 2.96 (-2.94,2.94) {-0.50,1.50}
Total: 50336 W: 9473 L: 9241 D: 31622
Ptnml(0-2): 570, 5371, 13098, 5515, 614

passed LTC
https://tests.stockfishchess.org/tests/view/5ead6d3b6ffeed51f6e325b0
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 21952 W: 2810 L: 2603 D: 16539
Ptnml(0-2): 101, 1791, 7005, 1958, 121

closes https://github.com/official-stockfish/Stockfish/pull/2658

bench 4247490
2020-05-02 17:30:22 +02:00
Linmiao Xu 7f8166db89 Tuned safe checks and minor piece king protectors
A combination of terms related to king safety one tuned safe check weights,
the other tuned knight and bishop king protector weights separately with
some compensation in the high outpost bonuses given to the minor pieces.

passed STC
LLR: 2.95 (-2.94,2.94) {-0.50,1.50}
Total: 39892 W: 7594 L: 7350 D: 24948
Ptnml(0-2): 643, 4559, 9314, 4771, 659
https://tests.stockfishchess.org/tests/view/5ea49635b908f6dd28f34b82

passed LTC
LLR: 2.94 (-2.94,2.94) {0.25,1.75}
Total: 104934 W: 13300 L: 12834 D: 78800
Ptnml(0-2): 697, 9571, 31514, 9939, 746
https://tests.stockfishchess.org/tests/view/5ea4abf6b908f6dd28f34bcb

closes https://github.com/official-stockfish/Stockfish/pull/2649

Bench 4800754
2020-05-02 17:26:51 +02:00
Joost VandeVondele 353e20674b Small cleanups
closes https://github.com/official-stockfish/Stockfish/pull/2628

No functional change
2020-04-29 17:44:24 +02:00
xoto10 ecac132bca Scale factor in opposite-color bishop endings
This change varies the scale factor with the total number of pieces and pawns on the strongSide.

STC :
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 150920 W: 28828 L: 28422 D: 93670 +0.65 Elo
Ptnml(0-2): 2507, 17548, 35030, 17782, 2593
https://tests.stockfishchess.org/tests/view/5e983eb2c00499c5410f4951

LTC :
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 69238 W: 8810 L: 8446 D: 51982 +1.58 Elo
Ptnml(0-2): 451, 6276, 20879, 6484, 529
https://tests.stockfishchess.org/tests/view/5e985b27c00499c5410f4987

closes https://github.com/official-stockfish/Stockfish/pull/2637

Bench 4821332
2020-04-16 21:40:06 +02:00
Lolligerhans 6f35af7ad3 Increase safe check bonus if multiple safe checks
Add 50% "safe checks" bonus when there are multiple safe checks from the
same piece type.

LTC
LLR: 2.97 (-2.94,2.94) {0.25,1.75}
Total: 128184 W: 16491 L: 15954 D: 95739
Ptnml(0-2): 884, 11793, 38267, 12198, 950
https://tests.stockfishchess.org/tests/view/5e97d1b6c9ada107a0370e03

STC
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 19022 W: 3733 L: 3514 D: 11775
Ptnml(0-2): 338, 2103, 4414, 2314, 342
https://tests.stockfishchess.org/tests/view/5e97c377c9ada107a0370ddf

closes https://github.com/official-stockfish/Stockfish/pull/2636

Bench: 5057329
2020-04-16 21:36:19 +02:00
FauziAkram d87adcc006 Queen and Rook Tuning
Tuning for multiple parameters for Queen and Rook.

passed STC
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 62790 W: 12033 L: 11754 D: 39003
Ptnml(0-2): 1058, 7186, 14666, 7389, 1096
https://tests.stockfishchess.org/tests/view/5e978c66c9ada107a0370d87

passed LTC
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 89780 W: 11460 L: 11036 D: 67284
Ptnml(0-2): 624, 8151, 26951, 8505, 659
https://tests.stockfishchess.org/tests/view/5e979aaec9ada107a0370d93

closes https://github.com/official-stockfish/Stockfish/pull/2634

Bench: 5111578
2020-04-16 21:32:26 +02:00