Simplify promotion move generation closes https://github.com/official-stockfish/Stockfish/pull/4892 No functional change
remove blank line between function and it's description - remove the blank line between the declaration of the function and it's comment, leads to better IDE support when hovering over a function to see it's description - remove the unnecessary duplication of the function name in the functions description - slightly refactored code for lsb, msb in bitboard.h There are still a few things we can be improved later on, move the description of a function where it was declared (instead of implemented) and add descriptions to functions which are behind macros ifdefs closes https://github.com/official-stockfish/Stockfish/pull/4840 No functional change
add clang-format This introduces clang-format to enforce a consistent code style for Stockfish. Having a documented and consistent style across the code will make contributing easier for new developers, and will make larger changes to the codebase easier to make. To facilitate formatting, this PR includes a Makefile target (`make format`) to format the code, this requires clang-format (version 17 currently) to be installed locally. Installing clang-format is straightforward on most OS and distros (e.g. with https://apt.llvm.org/, brew install clang-format, etc), as this is part of quite commonly used suite of tools and compilers (llvm / clang). Additionally, a CI action is present that will verify if the code requires formatting, and comment on the PR as needed. Initially, correct formatting is not required, it will be done by maintainers as part of the merge or in later commits, but obviously this is encouraged. fixes https://github.com/official-stockfish/Stockfish/issues/3608 closes https://github.com/official-stockfish/Stockfish/pull/4790 Co-Authored-By: Joost VandeVondele <Joost.VandeVondele@gmail.com>
Standardize Comments use double slashes (//) only for comments. closes #4820 No functional change.
Reformat some comments and conditions closes https://github.com/official-stockfish/Stockfish/pull/4814 No functional change
Make casting styles consistent Make casting styles consistent with the rest of the code. closes https://github.com/official-stockfish/Stockfish/pull/4793 No functional change
Cleanup includes Reorder a few includes, include "position.h" where it was previously missing and apply include-what-you-use suggestions. Also make the order of the includes consistent, in the following way: 1. Related header (for .cpp files) 2. A blank line 3. C/C++ headers 4. A blank line 5. All other header files closes https://github.com/official-stockfish/Stockfish/pull/4763 fixes https://github.com/official-stockfish/Stockfish/issues/4707 No functional change
Fix capturing underpromotions issue Fix underpromotion captures are generated amongst quiets although dealt with as a capture_stage in search, this makes not skipping them when move count pruning kicks-in consistent with updating their histories amongst captures. Passed STC: https://tests.stockfishchess.org/tests/view/6415579f65775d3b539e7537 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 118896 W: 31678 L: 31553 D: 55665 Ptnml(0-2): 356, 12911, 32793, 13028, 360 Passed LTC: https://tests.stockfishchess.org/tests/view/641633b965775d3b539e9e95 LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 126800 W: 34255 L: 34148 D: 58397 Ptnml(0-2): 57, 12216, 38763, 12291, 73 see also discussion in https://github.com/official-stockfish/Stockfish/pull/4436 closes https://github.com/official-stockfish/Stockfish/pull/4452 bench: 3979409
remove unnecessary variable pinned already has to be true for the bitwise & closes https://github.com/official-stockfish/Stockfish/pull/4381 No functional change
apply if constexpr to additional instances as a form of documentation, and a hint to the compiler. closes https://github.com/official-stockfish/Stockfish/pull/4345 No functional change
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
Simplify Declaration on Pawn Move Generation Removes possible micro-optimization in favor of readability. STC: LLR: 2.95 (-2.94,2.94) <-2.50,0.50> Total: 75432 W: 5824 L: 5777 D: 63831 Ptnml(0-2): 178, 4648, 28036, 4657, 197 https://tests.stockfishchess.org/tests/view/611fa7f84977aa1525c9cb75 LTC: LLR: 2.93 (-2.94,2.94) <-2.50,0.50> Total: 41200 W: 1156 L: 1106 D: 38938 Ptnml(0-2): 13, 981, 18562, 1031, 13 https://tests.stockfishchess.org/tests/view/611fcc694977aa1525c9cb9b Closes https://github.com/official-stockfish/Stockfish/pull/3669 No functional change
Simplify promotion move generator This patch removes Knight promotion checks from Captures. As a consequence, it also removes this underpromotion from qsearch. STC: LLR: 2.93 (-2.94,2.94) <-2.50,0.50> Total: 37776 W: 3113 L: 3023 D: 31640 Ptnml(0-2): 103, 2419, 13755, 2507, 104 https://tests.stockfishchess.org/tests/view/60be6a06457376eb8bcaa775 LTC: LLR: 2.93 (-2.94,2.94) <-2.50,0.50> Total: 39760 W: 1257 L: 1203 D: 37300 Ptnml(0-2): 11, 1079, 17646, 1133, 11 https://tests.stockfishchess.org/tests/view/60beb972457376eb8bcaa7c5 closes https://github.com/official-stockfish/Stockfish/pull/3536 Bench: 5530620
Use if instead of goto This PR inverts the if and removes goto in the generate_all function. closes https://github.com/official-stockfish/Stockfish/pull/3461 No functional change
Simplify pawn moves generator This patch simplifies QUIET_CHECKS pawn move generator by merging discovery check move generator with direct check move generator. It also simplifies emptySquares instantiation. In addition, I added a comment in generate_moves() to clarify Check branches. STC: LLR: 2.95 (-2.94,2.94) <-2.50,0.50> Total: 112648 W: 9952 L: 9945 D: 92751 Ptnml(0-2): 369, 7682, 40195, 7729, 349 https://tests.stockfishchess.org/tests/view/6088226895e7f1852abd2978 LTC: LLR: 2.93 (-2.94,2.94) <-2.50,0.50> Total: 74656 W: 2797 L: 2765 D: 69094 Ptnml(0-2): 38, 2328, 32554, 2380, 28 https://tests.stockfishchess.org/tests/view/60884e5095e7f1852abd2994 closes https://github.com/official-stockfish/Stockfish/pull/3447 No functional change
Merge all move generators Merging `generate<EVASIONS>` and `generate<QUIET_CHECKS>` into `generate_all()`. verified to yield correct perft results, even though bench changes due to different order of generated moves. No regresion playing games: passed STC: LLR: 2.94 (-2.94,2.94) {-1.00,0.20} Total: 161800 W: 14585 L: 14624 D: 132591 Ptnml(0-2): 577, 11681, 56451, 11586, 605 https://tests.stockfishchess.org/tests/view/606532732b2df919fd5f026d passed LTC: LLR: 2.98 (-2.94,2.94) {-0.70,0.20} Total: 188504 W: 6906 L: 6961 D: 174637 Ptnml(0-2): 87, 6272, 81610, 6175, 108 https://tests.stockfishchess.org/tests/view/6065b0772b2df919fd5f02ae closes https://github.com/official-stockfish/Stockfish/pull/3418 Bench: 4536129
Revert previous patch Revert the previous patch about move generation, as it unexpectedly changed the bench. Better to take the time to understand the issue. Bench: 4191632
Merge all move generators Merging `generate<EVASIONS>` and `generate<QUIET_CHECKS>` into `generate_all()`. STC: LLR: 2.94 (-2.94,2.94) {-1.00,0.20} Total: 161800 W: 14585 L: 14624 D: 132591 Ptnml(0-2): 577, 11681, 56451, 11586, 605 https://tests.stockfishchess.org/tests/view/606532732b2df919fd5f026d LTC: LLR: 2.98 (-2.94,2.94) {-0.70,0.20} Total: 188504 W: 6906 L: 6961 D: 174637 Ptnml(0-2): 87, 6272, 81610, 6175, 108 https://tests.stockfishchess.org/tests/view/6065b0772b2df919fd5f02ae ------------ Verified for correctness of `EVASIONS` by running perft: ``` ./stockfish b3nch 16 1 6 default perft (replace 3 by e in b3nch) Nodes searched : 71608931810 ``` Also tested for correctness on Chess960 with a similar code shown here: https://github.com/official-stockfish/Stockfish/pull/3418#issuecomment-816630295 ``` ./stockfish b3nch 16 1 6 fischer.txt perft Nodes searched : 506736009395 ``` ------------ Closes https://github.com/official-stockfish/Stockfish/pull/3418 No functional change
Simplify King Evasion Simplify away the removal of some illegal `KING`-evasion moves during move generation. Verified for correctness by running perft on the following positions: ``` ./stockfish bench 16 1 6 default perft Nodes searched: 71608931810 ./stockfish position fen 4rrk1/1p1nq3/p7/2p1P1pp/3P2bp/3Q1Bn1/PPPB4/1K2R1NR w - - 40 21 go perft 6 Nodes searched: 6136386434 ``` Passed STC: LLR: 2.94 (-2.94,2.94) {-1.00,0.20} Total: 16072 W: 1473 L: 1349 D: 13250 Ptnml(0-2): 57, 1047, 5710, 1159, 63 https://tests.stockfishchess.org/tests/view/60629e7ef183b42957b423b1 Passed LTC: LLR: 2.94 (-2.94,2.94) {-0.70,0.20} Total: 59064 W: 2214 L: 2177 D: 54673 Ptnml(0-2): 26, 1944, 25556, 1979, 27 https://tests.stockfishchess.org/tests/view/6062dce4f183b42957b423de closes https://github.com/official-stockfish/Stockfish/pull/3415 No functional change