jhonnold / berserk

UCI Chess Engine written in C
GNU General Public License v3.0
200 stars 30 forks source link

Calculate threats for every MakeMove #509

Closed jhonnold closed 10 months ago

jhonnold commented 10 months ago

Bench: 4309182

Threats started mostly as a part of search and history, but also have speed optimizations in move generation. By taking the threatened bit board - castles and king moves can be generated even faster. This showed an approximate 1% speedup locally.

               master               |             threatened             |
        mu              sigma       |        mu              sigma       |   Sp(1)/Sp(2)      3*sigma   
------------------------------------+------------------------------------+------------------------------------
       1817488.000             0.000|       1845656.000             0.000|      -1.526 %  +/-  0.000 %
       1823591.500          8631.652|       1844063.000          2252.842|      -1.110 %  +/-  1.767 %
       1822541.000          6368.937|       1844475.667          1746.004|      -1.189 %  +/-  1.315 %
       1822925.750          5256.841|       1844859.250          1618.919|      -1.189 %  +/-  1.074 %
       1823853.400          5002.844|       1845160.400          1555.355|      -1.155 %  +/-  0.958 %
       1824188.333          4549.268|       1845849.833          2187.970|      -1.173 %  +/-  0.868 %
       1822846.857          5462.915|       1845847.429          1997.345|      -1.246 %  +/-  0.979 %

ELO | 1.55 +- 1.67 (95%) SPRT | 4.0+0.04s Threads=1 Hash=8MB LLR | 1.34 (-2.94, 2.94) [0.00, 3.00] GAMES | N: 81728 W: 20207 L: 19843 D: 41678 http://chess.grantnet.us/test/33617/

ELO | 5.91 +- 14.33 (95%) CONF | 4.0+0.04s Threads=8 Hash=64MB GAMES | N: 1000 W: 230 L: 213 D: 557 http://chess.grantnet.us/test/33632/

Note the OB test should've been a regression, since I knew it was faster, but the bench change needed some validation. SMP was to sanity check the pseudo legal code.