Answers.Body: <p>On my old laptop with an i5 processor, running on a single thread, a recent version of Stockfish (written in CPP) makes around 1 million nodes per second (1Mnps). You must take into account that these nodes are not just the move generator, but the engine is also using its evaluation, so Stockfish's move generator should be much faster than that</p>
  <p>My very simple chess engine (written in C), whose move generator is not optimized can make around 4.5Mnps also on a single thread (with no evaluation, just the move generator working. This is what in chess programming is called a <a href="https://www.chessprogramming.org/Perft" rel="nofollow noreferrer">perft test</a>).</p>
  <p>So at first glance something like some thousands of positions per second seems like very poor performance.</p>
  <p>Of course part of this poor performance can be due to the language you've chosen to write your engine, but unless you've made a really weird choice, it seems like there's something odd about your program. My educated guess is either the move generator is buggy or its design is (very) sub-optimal.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-26T22:06:47.193Z
Answers.Text: My educated guess is either the move generator is buggy or its design is (very) sub-optimal.
  
  xxxxx
  
  Where exactly can I find tips? The only one "general" things is that I found to put everything (regarding moves) into one class and to use long integers rather than arrays, but everything else about chess programming is kinda all over the place.
Answers.UserDisplayName: Ferazhu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-02T08:31:26.953Z
Answers.Text: You asked about how much nps your program should make, and that was the content of my answer (by the way, would you consider to mark your post as answered?).
  I think if you want to ask a question about how to program a good move generator (which sounds like an interesting one) you should do it opening a new post.
Answers.UserDisplayName: emdio
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-26T19:10:19.830Z
Answers.LastActivityDate: 2020-07-26T19:10:19.830Z
Answers.UserDisplayName: emdio
Answers.Body: <p>I benchmarked my home made chess engine. It can play 600 000 moves per second in debug mode. It can calculate 80 000 - 100 000 legal moves per second in debug mode (which means that it can calculate and then play around 70 000 legal moves per second in debug mode). However, when running my engine in release mode it is over 10 times faster than in debug mode, meaning that in release mode it can calculate and then play 700 000 legal moves per second.
  I made my engine in Rust (if you wrote your engine in Python maybe that's why it is slow), I store the chess position by having an array of chess pieces that store their position. When calculating legal moves I first create another representation of the chessboard, this time I make an 8 by 8 array where every number represents a chess square (this way I can check whether a piece is in the way of another piece in O(1) time instead of in O(n) time).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-26T00:23:53.787Z
Answers.LastActivityDate: 2023-01-26T00:26:38.393Z
Answers.LastEditDate: 2023-01-26T00:26:38.393Z
Answers.UserDisplayName: catloverxx
Body: <p>My program prints time spent on executing a function for doing/retracting move, and both take together an average of 00.0002 seconds. That means my engine can analyze at most 5000 positions per second, right? That doesn't seem to be good, given the branching factor of 30.</p>
  <p>How bad is that, and what average/maximum speed could I expect with optimizations (on normal char[64] board) ?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-25T13:07:06.607Z
Comments.Text: Surely the answer depends in part on your hardware and what language you are using.
Comments.UserDisplayName: John Coleman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-25T14:06:12.750Z
Comments.Text: To be fair those are very impressive figures for a Sinclair ZX81 Spectrum (https://www.amazon.co.uk/Original-Sinclair-ZX81-Spectrum-Programming/dp/B00D8ZNBMI).
Comments.UserDisplayName: Brian Towers
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-25T19:47:00.580Z
Comments.Text: I know that it depends on many factors, but how good engine do you "expect" to make if you could make one?
Comments.UserDisplayName: Ferazhu
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-25T22:27:43.917Z
Comments.Text: Download and run Stockfish, the strongest conventional program right now, and see how much nps Stockfish gets. That's a good number to compare against.
Comments.UserDisplayName: Allure
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-26T15:07:08.377Z
Comments.Text: it's not that much about number of positions analized, but aobut the quality of the analysis
Comments.UserDisplayName: David
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-30T18:15:33.537Z
Comments.Text: Disagree with that - depth 3 is 35^3 move sequences already. If a computer cannot minimax brute-force that in less than 1 second, I cannot hope for more than depth 6 (with optimalizations), including quisce search.
Comments.UserDisplayName: Ferazhu
Tags: <engines>
Title: How many positions per second should my homemade engine calculate?
ThreadText: # How many positions per second should my homemade engine calculate?
  
  (Asked by: username_0 on 2020-07-25)
  
  My program prints time spent on executing a function for doing/retracting move, and both take together an average of 00.0002 seconds. That means my engine can analyze at most 5000 positions per second, right? That doesn't seem to be good, given the branching factor of 30.
  
  How bad is that, and what average/maximum speed could I expect with optimizations (on normal char[64] board) ?
  
  **Tags:** engines
  
  > **Comments:**
  > **username_1**: Surely the answer depends in part on your hardware and what language you are using.  
  > **username_2**: To be fair those are very impressive figures for a Sinclair ZX81 Spectrum (https://www.amazon.co.uk/Original-Sinclair-ZX81-Spectrum-Programming/dp/B00D8ZNBMI).  
  > **username_0**: I know that it depends on many factors, but how good engine do you "expect" to make if you could make one?  
  > **username_3**: Download and run Stockfish, the strongest conventional program right now, and see how much nps Stockfish gets. That's a good number to compare against.  
  > **username_4**: it's not that much about number of positions analized, but aobut the quality of the analysis  
  > **username_0**: Disagree with that - depth 3 is 35^3 move sequences already. If a computer cannot minimax brute-force that in less than 1 second, I cannot hope for more than depth 6 (with optimalizations), including quisce search.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_5 on 2020-07-26. Score: 1
  
  On my old laptop with an i5 processor, running on a single thread, a recent version of Stockfish (written in CPP) makes around 1 million nodes per second (1Mnps). You must take into account that these nodes are not just the move generator, but the engine is also using its evaluation, so Stockfish's move generator should be much faster than that
  
  My very simple chess engine (written in C), whose move generator is not optimized can make around 4.5Mnps also on a single thread (with no evaluation, just the move generator working. This is what in chess programming is called a [perft test](https://www.chessprogramming.org/Perft)).
  
  So at first glance something like some thousands of positions per second seems like very poor performance.
  
  Of course part of this poor performance can be due to the language you've chosen to write your engine, but unless you've made a really weird choice, it seems like there's something odd about your program. My educated guess is either the move generator is buggy or its design is (very) sub-optimal.
  
  > **Comments:**
  > **username_0**: My educated guess is either the move generator is buggy or its design is (very) sub-optimal.  xxxxx  Where exactly can I find tips? The only one "general" things is that I found to put everything (regarding moves) into one class and to use long integers rather than arrays, but everything else about chess programming is kinda all over the place.  
  > **username_5**: You asked about how much nps your program should make, and that was the content of my answer (by the way, would you consider to mark your post as answered?). I think if you want to ask a question about how to program a good move generator (which sounds like an interesting one) you should do it opening a new post.  
  
  ---
  
  ### Answer by username_6 on 2023-01-26. Score: 1
  
  I benchmarked my home made chess engine. It can play 600 000 moves per second in debug mode. It can calculate 80 000 - 100 000 legal moves per second in debug mode (which means that it can calculate and then play around 70 000 legal moves per second in debug mode). However, when running my engine in release mode it is over 10 times faster than in debug mode, meaning that in release mode it can calculate and then play 700 000 legal moves per second.
  I made my engine in Rust (if you wrote your engine in Python maybe that's why it is slow), I store the chess position by having an array of chess pieces that store their position. When calculating legal moves I first create another representation of the chessboard, this time I make an 8 by 8 array where every number represents a chess square (this way I can check whether a piece is in the way of another piece in O(1) time instead of in O(n) time).
  
  
  ---
  
  