Remove classical evaluation since the introduction of NNUE (first released with Stockfish 12), we have maintained the classical evaluation as part of SF in frozen form. The idea that this code could lead to further inputs to the NN or search did not materialize. Now, after five releases, this PR removes the classical evaluation from SF. Even though this evaluation is probably the best of its class, it has become unimportant for the engine's strength, and there is little need to maintain this code (roughly 25% of SF) going forward, or to expend resources on trying to improve its integration in the NNUE eval. Indeed, it had still a very limited use in the current SF, namely for the evaluation of positions that are nearly decided based on material difference, where the speed of the classical evaluation outweights its inaccuracies. This impact on strength is small, roughly 2Elo, and probably decreasing in importance as the TC grows. Potentially, removal of this code could lead to the development of techniques to have faster, but less accurate NN evaluation, for certain positions. STC https://tests.stockfishchess.org/tests/view/64a320173ee09aa549c52157 Elo: -2.35 ± 1.1 (95%) LOS: 0.0% Total: 100000 W: 24916 L: 25592 D: 49492 Ptnml(0-2): 287, 12123, 25841, 11477, 272 nElo: -4.62 ± 2.2 (95%) PairsRatio: 0.95 LTC https://tests.stockfishchess.org/tests/view/64a320293ee09aa549c5215b Elo: -1.74 ± 1.0 (95%) LOS: 0.0% Total: 100000 W: 25010 L: 25512 D: 49478 Ptnml(0-2): 44, 11069, 28270, 10579, 38 nElo: -3.72 ± 2.2 (95%) PairsRatio: 0.96 VLTC SMP https://tests.stockfishchess.org/tests/view/64a3207c3ee09aa549c52168 Elo: -1.70 ± 0.9 (95%) LOS: 0.0% Total: 100000 W: 25673 L: 26162 D: 48165 Ptnml(0-2): 8, 9455, 31569, 8954, 14 nElo: -3.95 ± 2.2 (95%) PairsRatio: 0.95 closes https://github.com/official-stockfish/Stockfish/pull/4674 Bench: 1444646
Update copyright years Happy New Year! closes https://github.com/official-stockfish/Stockfish/pull/4315 No functional change
Update copyright years Happy New Year! closes https://github.com/official-stockfish/Stockfish/pull/3881 No functional change
Add Stockfish namespace. fixes #3350 and is a small cleanup that might make it easier to use SF in separate projects, like a NNUE trainer or similar. closes https://github.com/official-stockfish/Stockfish/pull/3370 No functional change.
Update copyright years No functional change
Remove piece lists This patch removes the incrementally updated piece lists from the Position object. This has been tried before but always failed. My reasons for trying again are: * 32-bit systems (including phones) are now much less important than they were some years ago (and are absent from fishtest); * NNUE may have made SF less finely tuned to the order in which moves were generated. STC: LLR: 2.94 (-2.94,2.94) {-1.25,0.25} Total: 55272 W: 5260 L: 5216 D: 44796 Ptnml(0-2): 208, 4147, 18898, 4159, 224 https://tests.stockfishchess.org/tests/view/5fc2986a42a050a89f02c926 LTC: LLR: 2.96 (-2.94,2.94) {-0.75,0.25} Total: 16600 W: 673 L: 608 D: 15319 Ptnml(0-2): 14, 533, 7138, 604, 11 https://tests.stockfishchess.org/tests/view/5fc2f98342a050a89f02c95c closes https://github.com/official-stockfish/Stockfish/pull/3247 Bench: 3940967
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
Corrects a functional change in a cleanup patch. This corrects a functional change in https://github.com/official-stockfish/Stockfish/commit/ddcbacd04d1c860e808202ce8c1206c8acdca627 changing evaluation of KPPvK. Bench remains unchanged at low depth With this patch, 8/8/5k1p/8/7p/7K/8/8 b - - 1 11 is again correctly evaluated as a draw. closes https://github.com/official-stockfish/Stockfish/pull/2807 Bench: 4366686
denormalize KRKP. a non-functional code style change that denormalizes the KRKP endgame, making it somewhat easier to read. closes https://github.com/official-stockfish/Stockfish/pull/2786 No functional change
Small cleanups closes https://github.com/official-stockfish/Stockfish/pull/2756 No functional change
Make endgames consistent Changes variable names and occasionally consolidated variable declarations. Piece squares are consistently prefixed with "weak" or "strong." passed STC LLR: 2.94 (-2.94,2.94) {-1.50,0.50} Total: 29008 W: 5532 L: 5416 D: 18060 Ptnml(0-2): 355, 2983, 7723, 3077, 366 https://tests.stockfishchess.org/tests/view/5eea88d3563bc7aa75600689 closes https://github.com/official-stockfish/Stockfish/pull/2752 No functional change
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
remove KNPK endgame code In more than 100k local KNPK games, there is no discernible difference between master and master with this endgame removed: master:42971, patch:42973, draws: 3969. Removal does not seem to regress in normal games. STC LLR: 2.94 (-2.94,2.94) {-1.50,0.50} Total: 46390 W: 8998 L: 8884 D: 28508 Ptnml(0-2): 707, 5274, 11163, 5300, 751 https://tests.stockfishchess.org/tests/view/5e83b18ee42a5c3b3ca2ef02 LTC LLR: 2.94 (-2.94,2.94) {-1.50,0.50} Total: 44768 W: 5863 L: 5814 D: 33091 Ptnml(0-2): 251, 3918, 14028, 3905, 282 https://tests.stockfishchess.org/tests/view/5e84a82a4411759d9d0984f4 In tests with a book of endgames that can convert into KNPK, no significant difference can be seen either ``` TC 1.0+0.01 Score of patch vs master: 6131 - 6188 - 27681 [0.499] 40000 Elo difference: -0.5 +/- 1.9, LOS: 30.4 %, DrawRatio: 69.2 % TC 2.0+0.02 Score of patch vs master: 5740 - 5741 - 28519 [0.500] 40000 Elo difference: -0.0 +/- 1.8, LOS: 49.6 %, DrawRatio: 71.3 % `` closes https://github.com/official-stockfish/Stockfish/pull/2611 Bench 4512059
Remove KNPKB endgame. This is a functional simplification that removes the KNPKB endgame. Testing on only KNPKB positions suggests that this removal actually gains Elo: Score of patch vs master: 3380 - 3035 - 33585 [0.504] 40000 Elo difference: 3.0 +/- 1.4, LOS: 100.0 %, DrawRatio: 84.0 % Score of patch vs master: 290 - 36 - 39674 [0.503] 40000 Elo difference: 2.2 +/- 0.3, LOS: 100.0 %, DrawRatio: 99.2 % removal also doesn't cause a regression with the standard book: STC LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 71376 W: 13794 L: 13719 D: 43863 Ptnml(0-2): 1066, 8092, 17290, 8181, 1059 https://tests.stockfishchess.org/tests/view/5e76c3d5e42a5c3b3ca2e8be LTC LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 28394 W: 3731 L: 3662 D: 21001 Ptnml(0-2): 167, 2339, 9116, 2408, 167 https://tests.stockfishchess.org/tests/view/5e76e5eae42a5c3b3ca2e8d3 closes https://github.com/official-stockfish/Stockfish/pull/2594 Bench 5480811
Small cleanups closes https://github.com/official-stockfish/Stockfish/pull/2567 No functional change.
Equations for edges and corners. This is a functional simplification that removes the large arrays in endgames.cpp. It also fixes a recently introduced bug (960d59d54143d84aab26deae65279a611fc989f4) in KNBvK, now using flip_file() instead of ~. One fen added to bench to increase endgame coverage. STC LLR: 2.94 (-2.94,2.94) {-1.50,0.50} Total: 174724 W: 33325 L: 33404 D: 107995 Ptnml(0-2): 2503, 19607, 43181, 19608, 2463 http://tests.stockfishchess.org/tests/view/5e6448ffe42a5c3b3ca2e287 LTC LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 35640 W: 4679 L: 4621 D: 26340 Ptnml(0-2): 189, 2991, 11424, 3005, 211 http://tests.stockfishchess.org/tests/view/5e650b24e42a5c3b3ca2e2d8 closes https://github.com/official-stockfish/Stockfish/pull/2577 Bench: 5527957
Remove KRPPKRPScaleFactors array Fucntional simplification that removes the KRPPKRPScaleFactors array. STC LLR: 2.94 (-2.94,2.94) {-1.50,0.50} Total: 47374 W: 9159 L: 9049 D: 29166 Ptnml(0-2): 707, 5325, 11560, 5341, 754 http://tests.stockfishchess.org/tests/view/5e5ff464e42a5c3b3ca2e156 LTC LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 31268 W: 4064 L: 3995 D: 23209 Ptnml(0-2): 173, 2734, 9764, 2777, 186 http://tests.stockfishchess.org/tests/view/5e61be6ce42a5c3b3ca2e1c1 closes https://github.com/official-stockfish/Stockfish/pull/2575 Bench 5123316
Cleanup KBPsK endgame * Clarify distinction between strong side pawns and all pawns. * Simplify and speed-up determination of pawns on the same file. * Clarify comments. * more_than_one() is probably faster than pos.count. Passed STC: LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 40696 W: 7856 L: 7740 D: 25100 Ptnml(0-2): 584, 4519, 10054, 4579, 612 http://tests.stockfishchess.org/tests/view/5e6153b1e42a5c3b3ca2e1a9 closes https://github.com/official-stockfish/Stockfish/pull/2574 No functional change.
Use equations for PushAway and PushClose A functional simplification replacing the corresponding arrays. Tested in two variants, also the simpler one performs well, even though differences to master should be minimal. STC LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 57864 W: 11092 L: 11001 D: 35771 Ptnml(0-2): 826, 6458, 14320, 6455, 873 http://tests.stockfishchess.org/tests/view/5e5da5b6e42a5c3b3ca2e05c LTC LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 7198 W: 982 L: 883 D: 5333 Ptnml(0-2): 33, 575, 2296, 650, 45 http://tests.stockfishchess.org/tests/view/5e5df13ae42a5c3b3ca2e077 LTC (This exact version. . . more simplified) LLR: 2.95 (-2.94,2.94) {-1.50,0.50} Total: 5392 W: 729 L: 631 D: 4032 Ptnml(0-2): 23, 405, 1751, 485, 32 http://tests.stockfishchess.org/tests/view/5e5ead99e42a5c3b3ca2e0e4 closes https://github.com/official-stockfish/Stockfish/pull/2570 Bench 5123316
Consolidate Square Flipping Add a flip_rank() and flip_file() so that all of the square flipping can be consolidated. STC LLR: 2.94 (-2.94,2.94) {-1.50,0.50} Total: 57234 W: 11064 L: 10969 D: 35201 Ptnml(0-2): 822, 6562, 13801, 6563, 869 http://tests.stockfishchess.org/tests/view/5e5d2f2aafe6254521f2ffaa closes https://github.com/official-stockfish/Stockfish/pull/2568 No functional change.