jhonnold / berserk

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

Berserk NNUE Bug #491

Closed ginkgo20 closed 1 year ago

ginkgo20 commented 1 year ago
position fen 5rk1/p1p1q1pp/bp6/2b1pn2/Q7/2P2N2/PPBN1PPP/4R1K1 b - - 0 1
eval
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |       |   r   |   k   |       |
|       |       |       |       |       |   -631|       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   p   |       |   p   |       |   q   |       |   p   |   p   |
|    -94|       |   -106|       |   -974|       |   -131|   -155|
+-------+-------+-------+-------+-------+-------+-------+-------+
|   b   |   p   |       |       |       |       |       |       |
|   -477|   -143|       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |   b   |       |   p   |   n   |       |       |
|       |       |   -504|       |    -95|   -412|       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   Q   |       |       |       |       |       |       |       |
|  +1107|       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |   P   |       |       |   N   |       |       |
|       |       |   +174|       |       |   +433|       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   P   |   P   |   B   |   N   |       |   P   |   P   |   P   |
|    +96|   +160|   +538|   +409|       |   +369|   +291|   +114|
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |   R   |       |   K   |       |
|       |       |       |       |   +576|       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
Score: 146cp (white)
jhonnold commented 1 year ago

Static evaluation and search work together.

position fen 5rk1/p1p1q1pp/bp6/2b1pn2/Q7/2P2N2/PPBN1PPP/4R1K1 b - - 0 1
eval
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |       |   r   |   k   |       |
|       |       |       |       |       |   -572|       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   p   |       |   p   |       |   q   |       |   p   |   p   |
|    -96|       |   -101|       |   -931|       |   -126|   -148|
+-------+-------+-------+-------+-------+-------+-------+-------+
|   b   |   p   |       |       |       |       |       |       |
|   -428|   -148|       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |   b   |       |   p   |   n   |       |       |
|       |       |   -499|       |    -75|   -364|       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   Q   |       |       |       |       |       |       |       |
|   +993|       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |   P   |       |       |   N   |       |       |
|       |       |   +170|       |       |   +480|       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   P   |   P   |   B   |   N   |       |   P   |   P   |   P   |
|    +81|   +146|   +537|   +389|       |   +330|   +253|   +104|
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |   R   |       |   K   |       |
|       |       |       |       |   +583|       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
Score: 123cp (white)
go depth 20
info string time -1 start 278605968 alloc 0 max 2147483647 depth 20 timeset 0 searchmoves 0
info depth 1 seldepth 1 multipv 1 score cp -163 wdl 6 200 794 nodes 82 nps 82000 hashfull 0 tbhits 0 time 1 pv a6b7
info depth 2 seldepth 2 multipv 1 score cp -163 wdl 6 200 794 nodes 125 nps 125000 hashfull 0 tbhits 0 time 1 pv a6b7 e1e5
info depth 3 seldepth 3 multipv 1 score cp -506 wdl 0 0 1000 nodes 334 nps 334000 hashfull 0 tbhits 0 time 1 pv f5d6 a4a6 g7g6
info depth 4 seldepth 4 multipv 1 score cp -497 wdl 0 0 1000 nodes 425 nps 425000 hashfull 0 tbhits 0 time 1 pv f5d6 a4a6 g7g6 e1e5
info depth 5 seldepth 5 multipv 1 score cp -496 wdl 0 0 1000 nodes 809 nps 809000 hashfull 0 tbhits 0 time 1 pv f5d6 a4a6 e5e4
info depth 6 seldepth 8 multipv 1 score cp -299 wdl 0 17 983 nodes 1030 nps 1030000 hashfull 0 tbhits 0 time 1 pv e5e4
info depth 7 seldepth 10 multipv 1 score cp -498 wdl 0 0 1000 nodes 2779 nps 2779000 hashfull 1 tbhits 0 time 1 pv e7f6 a4a6 f5h4 b2b4 h4f3 d2f3 c5d6
info depth 8 seldepth 10 multipv 1 score cp -249 wdl 1 44 955 nodes 4056 nps 253500 hashfull 2 tbhits 0 time 16 pv e5e4
info depth 9 seldepth 12 multipv 1 score cp 203 wdl 894 103 3 nodes 6181 nps 386312 hashfull 2 tbhits 0 time 16 pv c5f2
info depth 10 seldepth 10 multipv 1 score cp 324 wdl 990 10 0 nodes 6731 nps 420687 hashfull 2 tbhits 0 time 16 pv c5f2
info depth 11 seldepth 15 multipv 1 score cp 344 wdl 993 7 0 nodes 9403 nps 587687 hashfull 3 tbhits 0 time 16 pv c5f2 g1h1 f2e1 f3e1 a6e2 a4a7 e7c5 c2f5
info depth 12 seldepth 17 multipv 1 score cp 378 wdl 996 4 0 nodes 22796 nps 712375 hashfull 8 tbhits 0 time 32 pv c5f2 g1h1 f2e1 f3e1 a6c8 a4a7 f5d6 e1f3 e5e4
info depth 13 seldepth 18 multipv 1 score cp 313 wdl 987 13 0 nodes 44470 nps 946170 hashfull 18 tbhits 0 time 47 pv c5f2 g1f2 e7c5 f3d4 f5d4 f2g3 d4e2 e1e2 a6e2 a4e4 c5f2 g3h3 f8f4 e4e5 g8h8 e5e8 f4f8
info depth 14 seldepth 22 multipv 1 score cp 360 wdl 995 5 0 nodes 47704 nps 1014978 hashfull 18 tbhits 0 time 47 pv c5f2 g1f2 e7c5 f3d4 f5d4 f2g3 d4e2 e1e2 a6e2 h2h3 c5e3 g3h2 g8h8
info depth 15 seldepth 24 multipv 1 score cp 363 wdl 995 5 0 nodes 82528 nps 1309968 hashfull 41 tbhits 0 time 63 pv c5f2 g1f2 e7c5 f3d4 f5d4 f2g3 d4e2 e1e2 a6e2 a4e4 c5f2 g3h3 f8f4 e4a8 g8f7 a8d5 f7e7 d2f3 e2f3 d5e5
info depth 16 seldepth 27 multipv 1 score cp 387 wdl 997 3 0 nodes 159592 nps 1697787 hashfull 63 tbhits 0 time 94 pv c5f2 g1f2 e7c5 f3d4 f5d4 f2g3 d4e2 e1e2 a6e2 a4e4 c5f2 g3h3 e2g4 e4g4 f2d2 g4e4 d2h6 h3g3
info depth 17 seldepth 25 multipv 1 score cp 394 wdl 997 3 0 nodes 438094 nps 1864229 hashfull 204 tbhits 0 time 235 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 f5d6 a6e2 g7g6 e2e3 g8g7 h1g1 e5e4 e3d4 e7f6 d4f6 f8f6 d2e4 f6e6 e4d6
info depth 18 seldepth 28 multipv 1 score cp 399 wdl 998 2 0 nodes 791400 nps 2024040 hashfull 359 tbhits 0 time 391 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 e7g5 a6e2 g8h8 h1g1 g5e3 e2e3 f5e3 c2b3 g7g6 d2f3 e5e4 f3d2 f8e8 g1f2 e3f5 f2e2 e8e7 b3d5 e4e3 d2f3
info depth 19 seldepth 30 multipv 1 score cp 410 wdl 998 2 0 nodes 1168770 nps 2075968 hashfull 481 tbhits 0 time 563 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 e7g5 a6e2 g8h8 h1g1 g5e3 e2e3 f5e3 c2e4 g7g6 g2g3 e3g4 h2h3 f8d8 d2f3 d8d1 g1g2 g4f6
info depth 20 seldepth 32 multipv 1 score cp 406 wdl 998 2 0 nodes 1315213 nps 2104340 hashfull 526 tbhits 0 time 625 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 e7g5 a6e2 g8h8 h1g1 g5e3 e2e3 f5e3 c2b3 g7g5 h2h3 g5g4 h3g4 e3g4 d2f3 f8d8 g1f1 h8g7 f3g5 g7f6 g5h7 f6f5
bestmove c5f2 ponder g1h1
jhonnold commented 1 year ago

SF Dev.

position fen 5rk1/p1p1q1pp/bp6/2b1pn2/Q7/2P2N2/PPBN1PPP/4R1K1 b - - 0 1
eval
info string NNUE evaluation using nn-cd2ff4716c34.nnue enabled

 Contributing terms for the classical eval:
+------------+-------------+-------------+-------------+
|    Term    |    White    |    Black    |    Total    |
|            |   MG    EG  |   MG    EG  |   MG    EG  |
+------------+-------------+-------------+-------------+
|   Material |  ----  ---- |  ----  ---- | -0.27 -0.27 |
|  Imbalance |  ----  ---- |  ----  ---- | -0.09 -0.08 |
|      Pawns |  0.18 -0.02 |  0.14 -0.12 |  0.04  0.10 |
|    Knights | -0.03 -0.08 | -0.08 -0.08 |  0.04  0.00 |
|    Bishops |  0.01 -0.19 | -0.22 -0.30 |  0.23  0.11 |
|      Rooks |  0.05  0.02 |  0.10  0.02 | -0.05  0.00 |
|     Queens |  0.00  0.00 | -0.17 -0.06 |  0.17  0.06 |
|   Mobility |  0.57  1.03 |  0.57  0.90 |  0.00  0.12 |
|King safety |  0.07 -0.16 | -0.31 -0.19 |  0.39  0.03 |
|    Threats |  1.19  1.09 |  0.35  0.45 |  0.84  0.65 |
|     Passed |  0.00  0.00 |  0.00  0.00 |  0.00  0.00 |
|      Space |  0.13  0.00 |  0.17  0.00 | -0.04  0.00 |
|   Winnable |  ----  ---- |  ----  ---- |  0.00 -0.02 |
+------------+-------------+-------------+-------------+
|      Total |  ----  ---- |  ----  ---- |  1.27  0.70 |
+------------+-------------+-------------+-------------+

 NNUE derived piece values:
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |       |   r   |   k   |       |
|       |       |       |       |       | -4.72 |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   p   |       |   p   |       |   q   |       |   p   |   p   |
| -0.65 |       | -0.88 |       | -5.58 |       | -1.23 | -1.23 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   b   |   p   |       |       |       |       |       |       |
| -3.61 | -1.20 |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |   b   |       |   p   |   n   |       |       |
|       |       | -4.03 |       | -0.92 | -3.01 |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   Q   |       |       |       |       |       |       |       |
| +8.69 |       |       |       |       |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |   P   |       |       |   N   |       |       |
|       |       | +1.45 |       |       | +5.51 |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+
|   P   |   P   |   B   |   N   |       |   P   |   P   |   P   |
| +0.58 | +1.34 | +5.38 | +4.34 |       | +3.56 | +2.37 | +0.86 |
+-------+-------+-------+-------+-------+-------+-------+-------+
|       |       |       |       |   R   |       |   K   |       |
|       |       |       |       | +6.54 |       |       |       |
+-------+-------+-------+-------+-------+-------+-------+-------+

 NNUE network contributions (Black to move)
+------------+------------+------------+------------+
|   Bucket   |  Material  | Positional |   Total    |
|            |   (PSQT)   |  (Layers)  |            |
+------------+------------+------------+------------+
|  0         |  -  0.31   |  -  2.19   |  -  2.49   |
|  1         |  +  0.24   |  -  1.89   |  -  1.65   |
|  2         |  +  0.23   |  -  1.76   |  -  1.53   |
|  3         |  +  0.21   |  -  1.48   |  -  1.27   |
|  4         |  +  0.19   |  -  1.57   |  -  1.38   |
|  5         |  +  0.18   |  -  1.62   |  -  1.44   | <-- this bucket is used
|  6         |  +  0.17   |  -  1.55   |  -  1.38   |
|  7         |  +  0.20   |  -  1.59   |  -  1.39   |
+------------+------------+------------+------------+

Classical evaluation   +1.12 (white side)
NNUE evaluation        +1.44 (white side)
Final evaluation       +1.54 (white side) [with scaled NNUE, hybrid, ...]

go depth 20
info string NNUE evaluation using nn-cd2ff4716c34.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 470 nodes 52 nps 17333 hashfull 0 tbhits 0 time 3 pv c5f2 g1h1
info depth 2 seldepth 2 multipv 1 score cp 470 nodes 99 nps 19800 hashfull 0 tbhits 0 time 5 pv c5f2 g1h1
info depth 3 seldepth 4 multipv 1 score cp 470 nodes 151 nps 30200 hashfull 0 tbhits 0 time 5 pv c5f2 g1h1 f2e1 a4a6
info depth 4 seldepth 5 multipv 1 score cp 470 nodes 213 nps 35500 hashfull 0 tbhits 0 time 6 pv c5f2 g1h1 f2e1 a4a6 e1d2
info depth 5 seldepth 6 multipv 1 score cp 470 nodes 272 nps 38857 hashfull 0 tbhits 0 time 7 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2
info depth 6 seldepth 7 multipv 1 score cp 470 nodes 336 nps 42000 hashfull 0 tbhits 0 time 8 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8
info depth 7 seldepth 7 multipv 1 score cp 470 nodes 408 nps 51000 hashfull 0 tbhits 0 time 8 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8
info depth 8 seldepth 9 multipv 1 score cp 470 nodes 501 nps 55666 hashfull 0 tbhits 0 time 9 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 h2h3 e7g5
info depth 9 seldepth 11 multipv 1 score cp 470 nodes 624 nps 62400 hashfull 0 tbhits 0 time 10 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 h2h3 e7g5 a6d3 f8d8
info depth 10 seldepth 12 multipv 1 score cp 470 nodes 811 nps 81100 hashfull 0 tbhits 0 time 10 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 h2h3 e7g5 a6d3 f8d8 d3f3
info depth 11 seldepth 14 multipv 1 score cp 470 nodes 1157 nps 89000 hashfull 0 tbhits 0 time 13 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 h2h3 e7g5 a6d3 f8d8 d3f3 d8d2 c2f5
info depth 12 seldepth 15 multipv 1 score cp 470 nodes 1494 nps 106714 hashfull 0 tbhits 0 time 14 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 h2h3 e7g5 a6d3 f8d8 d3f3 d8d2 c2f5
info depth 13 seldepth 18 multipv 1 score cp 470 nodes 4036 nps 252250 hashfull 2 tbhits 0 time 16 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 a6e2 f5d6
info depth 14 seldepth 20 multipv 1 score cp 479 nodes 22114 nps 670121 hashfull 9 tbhits 0 time 33 pv c5f2 g1h1 f2e1 a4a6 e1d2 f3d2 g8h8 g2g3 g7g6 a6a7 e7d8 d2f1 d8d5 h1g1 d5c5 g1g2 e5e4 c2e4 c5e5
info depth 15 seldepth 22 multipv 1 score cp 473 nodes 53246 nps 934140 hashfull 25 tbhits 0 time 57 pv c5f2 g1h1 f2e1 c2f5 e1d2 f5e4 a6e2 f3d2 g8h8 e4b1 e2h5 b1h7 e7g5
info depth 16 seldepth 25 multipv 1 score cp 468 nodes 152950 nps 1204330 hashfull 74 tbhits 0 time 127 pv c5f2 g1h1 f2e1 f3e1 a6b7 c2f5 f8f5 a4a7 b7d5 a7a4 e5e4 a4b5 e4e3 d2f3 e3e2 b5d3
info depth 17 seldepth 19 multipv 1 score cp 465 nodes 169297 nps 1217964 hashfull 83 tbhits 0 time 139 pv c5f2 g1h1 f2e1 f3e1 a6b7 c2f5 f8f5 a4a7 b7d5 a7a6 e5e4 e1c2 e4e3 d2f3 e3e2 a6d3 f5f3
info depth 18 seldepth 23 multipv 1 score cp 465 nodes 206605 nps 1244608 hashfull 102 tbhits 0 time 166 pv c5f2 g1h1 f2e1 f3e1 a6b7 c2f5 f8f5 a4a7 b7d5 a7a6 e5e4 a6e2 e4e3 d2f3 f5f8 e1c2 d5a2 f3d4 c7c5
info depth 19 seldepth 29 multipv 1 score cp 472 nodes 312267 nps 1290359 hashfull 150 tbhits 0 time 242 pv c5f2 g1h1 f2e1 f3e1 a6b7 c2f5 f8f5 a4a7 b7d5 a7a4 e5e4 h1g1 e4e3 d2f3 e3e2 g1f2 e7c5 a4d4 c5d4 c3d4 d5a2
info depth 20 seldepth 31 multipv 1 score cp 488 nodes 605759 nps 1340174 hashfull 260 tbhits 0 time 452 pv c5f2 g1h1 f2e1 f3e1 a6b7 c2f5 f8f5 a4a7 b7d5 a7a4 e5e4 b2b3 f5f8 a4b5 e7g5 d2e4 g5e5 b5d5 e5d5 e4g3 g7g6
bestmove c5f2 ponder g1h1
ginkgo20 commented 1 year ago

Static evaluation and search work together.

@jhonnold Stockfish evaluation is wrong , I created this issue for Stockfish a long time ago , see this:

I want from @vondele , @glinscott , @ddobbelaere to solve this bug.