GithubHelp home page GithubHelp logo

theblackplague / stocknemo Goto Github PK

View Code? Open in Web Editor NEW
62.0 7.0 7.0 19.14 MB

A C# Chess Engine Finding Good Moves.

License: GNU Lesser General Public License v3.0

C# 98.16% Dockerfile 0.39% Python 1.37% Makefile 0.09%
ai chess terminal chess-ai chess-engine chess-game chessboard

stocknemo's Introduction

StockNemo Banner

C# Neural Network Chess Engine - Finding Good Moves like Stockfish

ReleasesAuthors

Runpod Logo

.NET Docker Image Lichess

Build Status Test Status

Overview

  • Strong, Powerful, and Deep Analysis
  • High Performant and Cross-Compatible
  • Documented Source Code
  • Free and Open Source

Features

  • Engine:
    • Evaluation:
      • Material Development Evaluation
        • Material Evaluation
        • Piece Development Evaluation
      • Bishop Pair Evaluation
      • Tapered Evaluation
        • Early Game
        • Late Game
      • Neural Network Evaluation
        • Tempo Sensitive
        • Perspective Evaluation
    • Move Policy (Move Ordering):
      • Transposition Table Move (Normal Move Generation)
      • Promotion Move
        • Promotion Type
      • Capture Move
        • Most Valuable Victim with Least Valuable Attacker (MVVLVA)
    • Search:
      • Cancellation Support
      • Iterative Deepening
        • Depth Data Output
        • Principle Variation Output
      • Aspiration Search
        • Narrow Windows
        • Bound-specific Widening
        • Fallback Threshold
      • Alpha-Beta Negamax
        • Three-fold Repetition Pruning
        • Mate Distance Pruning
        • Material Draw Pruning
          • KvK
          • NKvK and KvNK
          • BKvK and KvBK
        • Transposition Table
          • Exact Cutoff
          • Alpha Unchanged Update
          • Beta Cutoff Update
          • Alpha Beta Delta Cutoff
        • Reverse Futility Pruning
          • Up to six-ply
          • None on mate branches
          • Depth and Improving Dependent Margin
        • Razoring
          • QSearch Evaluation
          • Shallow Threshold
        • Null Move Pruning
          • Three-ply Depth Reduction
          • Non-Razoring Depth
        • Check Extension
        • Fail-soft Alpha Beta Pruning
          • Futility Pruning
            • Evaluation Dependent
            • Alpha Dependent
          • Late Move Pruning
            • Post Best Move Found
            • Quiet Move Threshold
            • Non Principle Variation Branches
            • Up to three-ply
          • Late Move Reduction
            • Depth and Moves Played Logarithmic Reduction
            • At least three-ply
          • Principle Variation Search
            • Full Search on First Move
      • Quiescence Search (QSearch) *
        • Static Evaluation
          • Beta Cutoff
          • Alpha Update
        • Deep Capture Only Search
        • Fail-soft Alpha Beta Pruning
          • Static Exchange Evaluation (SEE) Pruning
  • Utility:
    • PERFT (Speeds upto: 168.3B NPS)
      • PERFT-Divide Output
      • Smart Multi-threaded Algorithm
        • Single-threaded (Depth < 5)
        • Multi-threaded (Depth >= 5)
          • Depth-First (Depth > 5)
          • Breath-First (Depth = 5)
      • Large In-Memory Transposition Table (50 GB) [SUPPORTED HARDWARE ONLY]

Building from Source

It is recommended that you do not build from source and instead download a release binary. The master branch, as well as other branches are in no shape, or form, guaranteed to be production-ready or stable.

Given the risks, if you still wish to continue, please note that you require the following:

  • .NET 6 SDK
  • Hardware Compatible with .NET 6 SDK (While .NET 6 is compatible with most hardware, the project does not guarantee compatibility)
  • System RID (Runtime Identifier) from the .NET Docs

In the repository directory, go into the Terminal directory and run:

dotnet publish "Terminal.csproj" -c Release -r <RID> /p:PublishSingleFile=true --self-contained true

You may then find the compiled binary in Terminal/bin/Release/net6.0/<RID>/publish.

Contributing Code and Hardware

Glad you're considering helping the development of StockNemo. Being an opensource-freeware project, it is currently not sponsored by any company, person, or otherwise. StockNemo welcomes all good code contributions (given they follow all necessary code and documentation standards).

To assist development of StockNemo, StockNemo appreciates donate of any compute power. Contributors may donate idle hardware by installing and running a StockNemo Testing Framework worker, which will be assigned distributed tasks to run. The hardware is required to be connected to the internet, and available to run tests (CPU is mostly idle). The Framework currently only utilizes the CPU.

Much thanks to:

  • Cozy Chess by Analog Hors for providing necessary information and data regarding Fixed-Shift Black Magic BitBoards.
  • Smallbrain by Disservin for providing necessary information and data regarding constant attack tables and check/pin bitboards. Smallbrain and Disservin have been crucial to the progress made by StockNemo.
  • Stockfish by the Stockfish Team for providing numerous insights and making a brilliant engine, used numerous times to debug StockNemo.
  • OpenBench by Andrew Grant for making an amazing framework that allows distributed testing of StockNemo.
  • Chess Tuning Tools by Karlson Pfannschmidt for being an amazing utility software to tune StockNemo.
  • Runpod by Runpod Team for providing necessary hardware to test StockNemo.
  • Marlinflow by the Marlinflow Team for providing the bulk of what is StockNemo's current neural network trainer.
  • Berserk by Jay for providing an amazing engine that can be used to generate neural network training data for StockNemo.

stocknemo's People

Contributors

hardik-s avatar pgg106 avatar theblackplague avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

stocknemo's Issues

Doesn't see obvious KBvK draw.

It seems like StockNemo sees the position as a draw but then forgets? Better phrased: no longer sees it as a draw.

position fen 8/8/7B/8/4k3/p7/KR6/8 b - - 0 63
go depth 15
info depth 1 score cp -269 nodes 8 nps 533 pv a3b2
info depth 2 score cp -269 nodes 26 nps 1624 pv a3b2 a2b2
info depth 3 score cp 0 nodes 45 nps 2812 pv a3b2 a2b2
info depth 4 score cp -242 nodes 219 nps 11526 pv a3b2 h6g7 b2b1q a2b1
info depth 5 score cp 0 nodes 603 nps 30150 pv a3b2 h6d2 e4d3 a2b2
info depth 6 score cp -45 nodes 1093 nps 54650 pv a3b2 a2b1 e4f5 b1c2 f5g6 h6e3
info depth 7 score cp -228 nodes 3166 nps 150761 pv a3b2 a2b1 e4d4 h6g7 d4d3 g7e5 d3e4
info depth 8 score cp -228 nodes 3908 nps 186095 pv a3b2 a2b1 e4d4 h6g7 d4d3 g7e5 d3e4 e5b2
info depth 9 score cp -228 nodes 7784 nps 353818 pv a3b2 a2b1 e4f5 h6g7 f5g5 g7e5 g5f5 e5d4 f5e4
info depth 10 score cp -228 nodes 9486 nps 412434 pv a3b2 a2b1 e4f5 h6g7 f5e4 g7f6 e4f4 f6d4 f4e4 d4b2
info depth 11 score cp -228 nodes 17785 nps 711400 pv a3b2 a2b1 e4f5 h6g7 f5e4 g7f6 e4f4 f6c3 f4f5 c3d4 f5e4
info depth 12 score cp -231 nodes 29360 nps 1048571 pv a3b2 a2b1 e4f5 h6g7 f5e6 g7d4 e6d5 d4f6 d5c4 f6e5 c4d5 e5b2
info depth 13 score cp -229 nodes 35751 nps 1232793 pv a3b2 a2b1 e4f5 h6g7 f5e6 g7d4 e6d5 d4f6 d5c4 f6e5 c4b4 e5d4 b4c4
info depth 14 score cp -229 nodes 40568 nps 1308645 pv a3b2 a2b1 e4f5 h6g7 f5e6 g7d4 e6d5 d4f6 d5c4 f6e5 c4b4 e5d4 b4c4 d4b2
info depth 15 score cp -229 nodes 54532 nps 1603882 pv a3b2 a2b1 e4d5 h6g7 d5c4 g7e5 c4b4 e5d4 b4b3 d4f6 b3a3 f6g7 a3b3 g7d4 b3c4
bestmove a3b2

Illegal En Passant when Under Check.

Consider the following position: 2r5/1K6/P1B5/8/4p1pp/8/3R1PkP/8 w - - 0 1. After the move f4, putting Black under a discovered check, StockNemo 5.7.0.0 says the best move is exf3. This is, however, illegal since Black is under check even after the move, and White captures Black's king in the following move.

image

Misses tactic at depth 14, finds it at depth 15.

In the game played vs. simpleEval on Lichess, StockNemo missed a critical tactic (possibly only a few ply deep) due to the aggressive pruning from the latest updates:

[Event "Casual Bullet game"]
[Site "https://lichess.org/lTyfwOgc"]
[Date "2022.07.19"]
[White "StockNemo"]
[Black "simpleEval"]
[Result "0-1"]
[UTCDate "2022.07.19"]
[UTCTime "17:46:14"]
[WhiteElo "2143"]
[BlackElo "2068"]
[WhiteTitle "BOT"]
[BlackTitle "BOT"]
[Variant "Standard"]
[TimeControl "60+2"]
[ECO "E60"]
[Opening "King's Indian Defense: Fianchetto Variation, Immediate Fianchetto"]
[Termination "Normal"]
[Annotator "lichess.org"]

1. d4 Nf6 2. c4 g6 3. g3 { E60 King's Indian Defense: Fianchetto Variation, Immediate Fianchetto } c5 4. d5 b5 5. cxb5 a6 
6. bxa6 d6 7. Nc3 Nxa6 8. Nf3 h6 9. Bg2 Bg7 10. O-O O-O 
11. e4 Nh7 12. Be3 Nf6 13. h3 g5 14. a3 Rb8 15. Qc2 e6 
16. Rad1 exd5 17. exd5 Nc7 18. Nd2 Ba6 19. Rfe1 Nd7 20. a4 Ne5 
21. Nf3 Nxf3+ 22. Bxf3 Bc4 23. Rd2 f5 24. Ne2 Bxe2 25. Rdxe2 Rxb2 
26. Qd1 Rb4 27. Bc1 Bc3 28. Bd2 Bxd2 29. Rxd2 Qd7 30. a5 g4 
31. hxg4 fxg4 32. Bg2 Qf5 33. Qa1 h5 34. a6 h4 35. gxh4 Qh7 
36. Rde2 Qxh4 37. Qa5 g3 38. fxg3 Qxg3 39. Re3 Rf3 40. Qa2 Rxe3 
41. Rf1 Rh4 42. a7 Qh2+ 43. Kf2 Ree4 44. a8=Q+ Nxa8 45. Qd2 Rhg4 
46. Qe3 Qxg2+ 47. Ke1 Rxe3+ 48. Kd1 Qxf1+ 49. Kd2 Qe2+ 50. Kc1 Rg1# { Black wins by checkmate. } 0-1

The issue happens in 37. Qa5. It's a major blunder with a CP loss of 800, according to Stockfish, and was game losing. The correct move is 37. a7.

According to a manual search done on StockNemo for the FEN, 5rk1/2n5/P2p4/2pP4/1r4pq/8/4RPB1/Q3R1K1 w - - 0 37:

position fen 5rk1/2n5/P2p4/2pP4/1r4pq/8/4RPB1/Q3R1K1 w - - 0 37
go depth 16
info depth 1 score cp 199 nodes 88 nps 4631 pv a6a7
info depth 2 score cp 165 nodes 859 nps 45210 pv a6a7 b4f4
info depth 3 score cp 163 nodes 2938 nps 146900 pv a6a7 b4f4 a1b2
info depth 4 score cp 149 nodes 4569 nps 228450 pv a6a7 b4d4 e1d1 f8f4
info depth 5 score cp 165 nodes 14710 nps 612916 pv a1a5 f8c8 a6a7 b4d4 a7a8q
info depth 6 score cp 148 nodes 32890 nps 1134138 pv a6a7 b4d4 a1a5 f8c8
info depth 7 score cp 148 nodes 79774 nps 1813045 pv a6a7 b4d4 a1a5 f8c8 a5b6 c7d5 b6d6
info depth 8 score cp 177 nodes 301763 nps 2624026 pv a6a7 g4g3 f2g3 h4g3 a1a5 b4b7 e2e7 f8f2
info depth 9 score cp 177 nodes 471354 nps 2740430 pv a1a5 f8c8 a6a7 g4g3 f2g3 h4g3 e2e3 g3g5 a5a2
info depth 10 score cp 143 nodes 663341 nps 2834790 pv a1a5 f8c8 a6a7 g4g3 f2g3 h4g3 e2e3 g3g5 a5a2 b4f4
info depth 11 score cp 193 nodes 1006560 nps 2892414 pv a1a5 f8c8 a6a7 b4b7 e2e7 c8f8 e7c7 h4f2 g1h1 b7c7
info depth 12 score cp 176 nodes 2183785 nps 2991486 pv a1a5 c7a8 a6a7 a8b6 a5a2 b4f4 a2b1 b6c4 b1g6 g8h8 e1f1 f8d8
info depth 13 score cp 179 nodes 3450351 nps 2959134 pv a1a5 c7a8 a6a7 g4g3 f2g3 h4g3 a5a2 b4f4 e2e8 a8b6 e8f8 f4f8 e1e7
info depth 14 score cp 172 nodes 4600382 nps 2947073 pv a1a5 c7a8 a6a7 g4g3 f2g3 h4g3 e1f1 f8f1 g1f1 b4b1 e2e1 g3d3 f1g1 a8b6
info depth 15 score cp 133 nodes 10825238 nps 2909228 pv a6a7 g4g3 f2g3 h4g3 e1f1 f8a8 e2e7 c7d5 a1e1 g3g6 e1e6 g6e6 e7e6 d5c7 e6g6
info depth 16 score cp 136 nodes 15586150 nps 2922585 pv a6a7 g4g3 f2g3 h4g3 e1f1 f8a8 e2e7 c7d5 a1e1 g3g6 e1e6 g6e6 e7e6 d5c7 e6g6 g8h7
bestmove a6a7

It seems StockNemo finds the correct move at depth 15 and onwards but does not at depth 14. Ideally, these moves should be found earlier (possibly at the tactical ply), but they're sometimes missed due to pruning.

Not working with some Cutechess binaries.

Hi!

What is needed to run the StockNemo engine?

My PC (Windows) supports AVX, AVX2, BMI2, POP, SS3,SS4, but unfortunately none of the versions released worked here.

How should I proceed?

Low depth search leads to miscalculation on long mates.

Hi, I did some test games with current release version.

I should mention that this was played on an old quadcore from 2009 ;-)
(to possibly excuse the low depths in that fast games)

http://talkchess.com/forum3/viewtopic.php?f=6&t=80259

Here is its opponent tested in the CCRL Blitz rating list in > 1000 games
http://ccrl.chessdom.com/ccrl/404/cgi/engine_details.cgi?print=Details&each_game=1&eng=Galjoen%200.33%2064-bit#Galjoen_0_33_64-bit


[Event "Test 2022"]
[Site "RWBC-CAPPUCCINO Win7U64 Q8200 2.33Ghz"]
[Date "2022.07.07"]
[Round "8.1.2"]
[White "StockNemo_2005-64"]
[Black "Galjoen_033-64"]
[Result "1/2-1/2"]
[ECO "A07"]
[GameDuration "00:04:37"]
[GameEndTime "2022-07-07T13:14:49.248 Mitteleuropäische Sommerzeit"]
[GameStartTime "2022-07-07T13:10:11.812 Mitteleuropäische Sommerzeit"]
[Opening "Reti"]
[PlyCount "126"]
[TimeControl "90+1"]
[Variation "King's Indian attack (Barcza system)"]

1. Nf3 {book} d5 {book}
2. g3 {book} c6 {book}
3. c4 {book} Nf6 {book}
4. cxd5 {-0.05/8 4.56} cxd5 {+0.21/9 3.98}
5. Bg2 {-0.05/6 4.37} Nc6 {+0.34/9 3.87}
6. O-O {-0.02/6 4.20} e5 {+0.83/9 3.78}
7. d4 {-0.19/6 4.55} exd4 {+0.57/9 3.66}
8. Nxd4 {+0.22/7 4.37} Bc5 {+0.62/9 3.64}
9. Nxc6 {+0.16/7 4.20} bxc6 {+0.74/8 3.51}
10. Qc2 {+0.16/5 4.04} Qb6 {+0.39/9 3.46}
11. Nc3 {+0.33/6 3.89} Bd4 {+0.30/8 3.36}
12. Bf4 {+0.54/6 3.74} Ba6 {-0.31/8 3.28}
13. Na4 {+0.90/6 3.60} Qb5 {-0.36/8 3.20}
14. Rad1 {+0.97/7 3.47} Bb6 {-0.30/9 3.12}
15. Nxb6 {+0.77/6 3.36} axb6 {-0.27/9 3.03}
16. Rfe1 {+0.84/5 3.24} O-O {-0.18/9 2.99}
17. e3 {+0.69/5 3.12} Rfe8 {+0.07/9 2.95}
18. Bf1 {+0.59/5 3.06} Qc5 {+0.28/8 2.85}
19. Qxc5 {+0.15/8 2.91} bxc5 {+0.48/9 2.81}
20. Bg2 {+0.32/7 2.81} Bc8 {+0.54/9 2.79}
21. a3 {+0.18/6 2.73} Bf5 {+0.44/9 2.72}
22. h3 {+0.03/6 2.64} c4 {+0.35/9 2.64}
23. g4 {-0.02/6 2.56} Bc2 {+0.31/10 2.58}
24. Rc1 {+0.05/7 2.48} Bd3 {+0.40/9 2.54}
25. g5 {+0.06/7 2.41} Nd7 {+0.50/9 2.46}
26. Bd6 {+0.17/5 2.33} f6 {+0.75/10 2.44}
27. h4 {+0.13/7 2.27} Kf7 {+0.72/9 2.43}
28. Rcd1 {+0.28/5 2.21} Ke6 {+0.96/8 2.33}
29. Bb4 {+0.22/6 2.15} c5 {+1.12/9 2.31}
30. Bc3 {+0.40/7 2.08} Kd6 {+0.95/9 2.27}
31. h5 {+0.55/7 2.04} fxg5 {+1.25/9 2.21}
32. Bxg7 {+0.52/7 1.98} Kc6 {+1.24/9 2.21}
33. h6 {+0.47/6 1.93} g4 {+1.26/10 2.16}
34. Kh2 {+0.63/6 1.88} Be4 {+1.08/9 2.12}
35. Bxe4 {+0.68/7 1.84} Rxe4 {+1.23/9 2.08}
36. f3 {+0.53/6 1.81} gxf3 {+2.73/10 2.02}
37. Kg3 {-0.35/7 1.77} Rae8 {+2.50/10 2.04}
38. Kxf3 {-0.22/8 1.73} d4 {+2.42/9 2.00}
39. a4 {-0.64/8 1.68} Nb6 {+3.10/8 1.95}
40. a5 {-0.32/9 1.65} Na4 {+3.52/9 1.89}
41. Rd2 {-0.42/8 1.62} Rxe3+ {+3.32/8 1.85}
42. Rxe3 {-0.82/10 1.58} Rxe3+ {+3.08/8 1.86}
43. Kg4 {-0.83/9 1.55} Nxb2 {+3.02/9 1.80}
44. Rxb2 {+1.85/9 1.53} c3 {+2.64/9 1.80}
45. Ra2 {+1.32/8 1.50} Rd3 {+3.19/9 1.75}
46. a6 {+1.89/8 1.48} Rd2 {+0.67/9 1.76}
47. Ra1 {+4.72/10 1.46} Re2 {+0.56/9 1.74}
48. a7 {+4.62/10 1.43} Re8 {+0.80/9 1.74}
49. a8=Q+ {+4.84/9 1.42} Rxa8 {+2.02/11 1.71}
50. Rxa8 {+4.08/12 1.39} c2 {1.65}
51. Ra6+ {+4.08/10 1.38} Kd7 {+1.51/9 1.66}
52. Ra1 {+4.37/10 1.35} Kd6 {+0.28/8 1.58}
53. Kf3 {+4.42/10 1.34} Kd5 {-2.74/9 1.59}
54. Kf4 {+4.42/9 1.31} c4 {-1.73/7 1.53}
55. Be5 {+4.75/11 1.30} c3 {-2.45/8 1.55}
56. Rc1 {+6.36/13 1.28} d3 {-3.24/9 1.53}
57. Bxc3 {+6.80/12 1.28} Kc4 {-8.47/10 1.52}
58. Bf6 {+7.03/12 1.25} d2 {-4.90/9 1.47}
59. Rxc2+ {+7.03/14 1.25} Kd3 {-4.92/10 1.50}
60. Rc3+ {+7.03/13 1.23} Ke2 {-4.79/11 1.48}
61. Rc2 {+7.03/12 1.23} Kd3 {1.45}
62. Rc3+ {+7.03/14 1.21} Ke2 {1.44}
63. Rc2 {+7.03/13 1.20} Kd3 {-4.93/11 1.43}
{Draw by 3-fold repetition}
1/2-1/2

[Event "Test 2022"]
[Site "RWBC-CAPPUCCINO Win7U64 Q8200 2.33Ghz"]
[Date "2022.07.07"]
[Round "6.1.2"]
[White "StockNemo_2005-64"]
[Black "Galjoen_033-64"]
[Result "0-1"]
[ECO "B23"]
[GameDuration "00:01:04"]
[GameEndTime "2022-07-07T12:53:38.549 Mitteleuropäische Sommerzeit"]
[GameStartTime "2022-07-07T12:52:34.167 Mitteleuropäische Sommerzeit"]
[Opening "Sicilian"]
[PlyCount "26"]
[TimeControl "90+1"]
[Variation "Closed"]

1. e4 {book} c5 {book}
2. Nc3 {book} e6 {book}
3. Nf3 {book} a6 {book}
4. Bd3 {+0.49/6 4.56} Nc6 {-0.15/9 3.98}
5. O-O {+0.34/6 4.38} g5 {+0.30/9 3.88}
6. Be2 {+0.81/7 4.21} g4 {+0.43/9 3.77}
7. Ne1 {+0.40/8 4.56} h5 {+0.69/9 3.70}
8. f3 {+0.40/6 4.36} Bd6 {+0.30/9 3.56}
9. Nd3 {+0.40/7 4.20} Bxh2+ {+1.82/8 3.50}
10. Kxh2 {+3.30/7 4.05} Qh4+ {+M1/3 0.055}
11. Kg1 {-M7/10 3.88} g3
12. Re1 {-M7/8 3.74} Qh2+
13. Kf1 {-M3/8 3.60} Qh1# {Black mates}
0-1

Engine crashes due to plyFromRoot > 63 when check extensions are in play.

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Backend.Engine.MoveSearch.AbSearch(Backend.Engine.EngineBoard, Int32, Int32, Int32, Int32)
   at Backend.Engine.MoveSearch.IterativeDeepening(Int32)
   at Terminal.Uci.UniversalChessInterface+<>c__DisplayClass15_0.<HandleGo>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(System.Object)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

This is due to the PrincipleVariationTable, KillerMoveTable, and LogarithmicReductionTable all having sizes of 64.

Version number

Please include version number in exe name and UCI id.

Gabor Szots
CCRL

Illegal last move of PV.

Occasionally, the last move of the PV line provided by StockNemo is illegal.

2022-09-14T03:35:25.591841155Z Warning: PV: Qe8+ Kf6 Qf8+ Ke6 Re3+ Kd7 Qe8+ Kd6 Qc6# d6d5
2022-09-14T03:35:26.557568712Z Warning: Illegal PV move c8b8 from StockNemo-050F4C13 (41)
2022-09-14T03:35:26.557654072Z Warning: PV: Kd6 Rd3+ Ke6 Re3+ Kd7 Qd5+ Kc8 Re8# c8b8
2022-09-14T03:35:26.557666225Z Warning: Illegal PV move c8b8 from StockNemo-050F4C13 (41)
2022-09-14T03:35:26.557675943Z Warning: PV: Kd6 Rd3+ Ke6 Re3+ Kd7 Qd5+ Kc8 Re8# c8b8
2022-09-14T03:35:26.557691112Z Warning: Illegal PV move c8b8 from StockNemo-050F4C13 (41)
2022-09-14T03:35:26.557696823Z Warning: PV: Kd6 Rd3+ Ke6 Re3+ Kd7 Qd5+ Kc8 Re8# c8b8
2022-09-14T03:35:26.754645336Z Warning: Illegal PV move c8d7 from StockNemo-C65102A3 (40)
2022-09-14T03:35:26.754734313Z Warning: PV: Qf4+ Ke6 Re3+ Kd7 Qd4+ Kc8 Re8# c8d7
2022-09-14T03:35:27.695710477Z Warning: Illegal PV move c8c7 from StockNemo-050F4C13 (41)
2022-09-14T03:35:27.695791910Z Warning: PV: Kc8 Qe8# c8c7

Performance regression on AMD Ryzen 3XXX.

There is a constant performance regression on AMD Ryzen 3XXX CPUs. Speeds going below 900K NPS.

Note following bench command run on AMD Ryzen 3950X: 13214802 nodes 892333 nps.

Comparing this with i9-11900H: 13214802 nodes 1916950 nps.

Connection stalls with 1s on the clock.

The following PGN was secured:

[Event "?"]
[Site "?"]
[Date "2022.09.13"]
[Round "1"]
[White "StockNemo-C65102A3"]
[Black "StockNemo-master"]
[Result "1-0"]
[FEN "1r1qkb1r/ppp2ppp/2n1p3/3n3b/3P1B2/1QN1PP2/PP4PP/R3KBNR w KQk - 0 1"]
[GameDuration "00:05:38"]
[GameEndTime "2022-09-13T05:15:04.046 W. Europe Daylight Time"]
[GameStartTime "2022-09-13T05:09:25.173 W. Europe Daylight Time"]
[PlyCount "149"]
[SetUp "1"]
[Termination "stalled connection"]
[TimeControl "95.57+0.96"]

1. Nxd5 {+0.42/18 5.3s} exd5 {-0.45/18 4.8s} 2. Rc1 {+0.57/17 4.6s}
Be7 {-0.51/17 4.7s} 3. Ne2 {+1.00/19 4.4s} f6 {-0.85/17 3.8s}
4. Ng3 {+0.84/18 4.3s} Bg6 {-0.96/18 4.3s} 5. Kf2 {+0.93/18 4.1s}
O-O {-1.00/18 4.1s} 6. h4 {+0.86/19 4.4s} h6 {-1.02/19 4.5s}
7. a3 {+0.90/18 4.3s} Bh7 {-0.87/17 3.8s} 8. Bd3 {+1.09/18 3.5s}
Qd7 {-1.03/18 4.1s} 9. Be4 {+1.27/18 3.5s} Rfd8 {-1.34/20 3.3s}
10. Bxh7+ {+1.29/18 3.9s} Kxh7 {-1.26/19 3.9s} 11. Qd3+ {+1.58/19 3.6s}
Kh8 {-1.22/18 4.9s} 12. Nf5 {+1.37/20 3.0s} a6 {-1.29/16 3.5s}
13. g4 {+1.43/21 3.1s} Rf8 {-1.48/19 3.4s} 14. Nxe7 {+1.53/21 2.7s}
Qxe7 {-1.51/19 3.1s} 15. g5 {+1.84/19 2.9s} Qf7 {-1.53/17 3.2s}
16. Rcg1 {+1.58/18 3.2s} Rg8 {-1.60/18 3.1s} 17. gxh6 {+1.41/18 3.0s}
g6 {-1.38/20 2.6s} 18. Rg4 {+1.45/17 2.9s} Rbc8 {-1.55/18 2.4s}
19. Rhg1 {+1.38/17 2.8s} Ne7 {-1.73/17 2.4s} 20. e4 {+1.63/17 2.3s}
dxe4 {-1.58/17 2.7s} 21. fxe4 {+1.32/16 2.7s} c6 {-1.58/16 2.1s}
22. Kg3 {+1.61/16 2.3s} Qe6 {-1.42/16 2.6s} 23. Kh2 {+1.40/16 2.2s}
Kh7 {-1.49/17 2.0s} 24. h5 {+1.50/16 2.5s} Rcd8 {-1.43/17 2.5s}
25. Bd2 {+1.50/17 2.4s} b6 {-1.46/15 2.4s} 26. Bc3 {+1.60/16 2.3s}
Qd6+ {-1.70/15 2.3s} 27. R4g3 {+1.83/13 2.2s} f5 {-1.68/16 2.1s}
28. e5 {+2.05/17 2.2s} Qe6 {-1.98/18 2.2s} 29. Qe3 {+1.87/17 2.1s}
Rdf8 {-1.63/18 1.7s} 30. Qf4 {+1.75/16 2.1s} Rf7 {-1.61/17 2.1s}
31. Bb4 {+1.65/18 1.7s} gxh5 {-1.98/18 1.7s} 32. Bxe7 {+1.85/20 2.0s}
Rxg3 {-1.76/19 1.8s} 33. Rxg3 {+1.77/20 1.6s} Qxe7 {-1.85/19 1.9s}
34. Rb3 {+1.71/18 1.9s} b5 {-1.85/18 1.9s} 35. Rg3 {+1.60/18 1.7s}
Qe6 {-1.66/18 1.9s} 36. Qg5 {+1.84/20 1.8s} Re7 {-1.70/19 1.8s}
37. b4 {+1.71/19 1.6s} Rd7 {-1.63/19 1.8s} 38. Rg1 {+1.61/16 1.7s}
h4 {-2.03/16 1.5s} 39. Rg2 {+2.15/18 1.7s} h3 {-2.29/17 1.7s}
40. Rg3 {+2.12/19 1.7s} Re7 {-2.18/19 1.4s} 41. Rxh3 {+2.18/18 1.6s}
Qa2+ {-2.18/17 1.6s} 42. Qg2 {+2.31/18 1.3s} Qxg2+ {-2.55/19 1.6s}
43. Kxg2 {+3.50/18 1.6s} Re6 {-3.34/18 1.6s} 44. Kf2 {+4.66/20 1.5s}
Rg6 {-4.45/19 1.5s} 45. Rh5 {+4.69/21 1.5s} Rg4 {-4.75/20 1.4s}
46. Rxf5 {+4.75/20 1.3s} Kxh6 {-4.68/20 1.5s} 47. Ke3 {+4.99/21 1.5s}
Kg7 {-4.91/18 1.5s} 48. Rf6 {+4.99/19 1.5s} Rg3+ {-5.30/19 1.4s}
49. Kf4 {+5.07/20 1.4s} Rc3 {-4.73/19 1.2s} 50. Kf5 {+5.54/21 1.4s}
Rf3+ {-5.15/20 1.4s} 51. Ke6 {+5.55/20 1.2s} Rxa3 {-5.91/19 1.4s}
52. Ke7 {+5.73/21 1.4s} a5 {-5.62/19 1.4s} 53. bxa5 {+5.96/21 1.3s}
Rxa5 {-5.90/20 1.3s} 54. Rxc6 {+5.88/21 1.3s} Ra7+ {-5.88/19 1.1s}
55. Kd8 {+5.88/21 1.3s} Ra8+ {-5.72/19 1.3s} 56. Kc7 {+6.15/20 1.2s}
Re8 {-5.84/21 1.3s} 57. e6 {+6.77/20 1.1s} Kf6 {-6.98/19 1.2s}
58. d5 {+6.94/22 1.1s} Re7+ {-6.25/20 1.3s} 59. Kd6 {+7.18/21 1.3s}
Re8 {-7.43/20 1.2s} 60. Rb6 {+7.43/24 1.3s} Rd8+ {-5.72/22 1.0s}
61. Kc6 {+7.82/20 1.2s} Re8 {-8.57/22 1.2s} 62. Kd7 {+8.22/21 1.2s}
Re7+ {-8.94/22 1.2s} 63. Kd6 {+9.00/21 1.2s} Ra7 {-9.05/21 1.2s}
64. Rxb5 {+8.68/22 1.2s} Ra6+ {-9.22/17 1.2s} 65. Kd7 {+9.99/20 1.2s}
Ra7+ {-9.53/18 1.2s} 66. Kc6 {+9.61/21 1.2s} Re7 {-9.29/19 1.2s}
67. Kd6 {+10.04/21 1.2s} Re8 {-10.01/19 0.99s} 68. Rb7 {+11.26/19 0.93s}
Rd8+ {-10.85/20 0.98s} 69. Rd7 {+11.34/20 1.2s} Rf8 {-10.75/20 1.2s}
70. Rf7+ {+11.75/21 1.0s} Rxf7 {-12.02/40 1.1s} 71. exf7 {+11.90/35 0.97s}
Kxf7 {-12.02/53 0.97s} 72. Kc7 {+12.02/36 1.1s} Kf6 {-12.02/56 0.93s}
73. d6 {+12.34/33 1.0s} Ke5 {-12.02/55 0.97s} 74. d7 {+12.45/28 1.1s}
Kf4 {-12.02/58 1.0s} 75. d8=Q {+M26/38 1.1s, Black's connection stalls} 1-0

Please consider implementing the hasfull info

According to the UCI protocol,

	* hashfull 
		the hash is x permill full, the engine should send this info regularly

where permill (per mille) means 1/1000th part https://en.wikipedia.org/wiki/Per_mille

StockNemo has an option option name Hash type spin default 16 min 4 max 512 but the information sent by the engine does not contain the hashfull values:

info depth 33 seldepth 54 score cp 314 nodes 617801559 nps 617641 pv c6c7 f5f6 d6d5 f6f5 d5d4 f5f4 d4d3 f7g7 c7c8q f4f6 c8c7 f6f7 c7d8 f7f8 d8d7 g7g6 d3c4 f8f7 d7c8 f7f6 c8g8 g6h5 c4b4 f6g6 g8c8 h5g5 c8c5 g5g4 b4c4 g6g5 c5c8 g4g3 c8h8 g3g2 c4d4 g2f3 d4d3

The information should be sent "whenever one of the info has changed", for example:

info depth 37 seldepth 42 multipv 1 score cp 304 nodes 9521265 nps 911300 hashfull 964 tbhits 0 time 10448 pv c6c7 f5f6 d6d5 f6f5 d5d4 f5f4 d4d3 f4f3 d3d2 f3f2 d2d1 f2f1 d1c2 f7g6 c7c8q f1f7 c8a6 g6g5 a6c4 f7f5 c4g8 g5h6 c2d3 f5g5 g8d8 g5g4 d3e3 g4g7 e3d4 h6g6

Please consider implementing sending the hashfull information.

help: support for android

Firstly apprectiations to all the developers of stockNemo for this awesome project.

I was researching since a quite long time for a chess engine which can be integrated in Unity for Android.

As usual stockfish is great but can't be used for android unless it is a shared library. and unfortunately it is not.

Do StockNemo provides support for Android? if yes, how i can use it in my unity C# project which will be built for android platforms.

any starting guide will be great for me

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.