Body: <p>I am developing a chess engine to improve my Cpp. It works, which means it generates legal moves and it can play them out. I optimized a bit and now achieve ~20k N / s, which is way better than my original 100 N /s</p>
  <p>But Stockfish does 1MK/s, which is beyond my conception. This is about 1 Node within 100 clocks. Even if I use an evaluation function, which just returns a constant, I will not get beyond 100kN/s. So how is this pure speed achieved?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-14T19:45:55.407Z
Comments.Text: By applying *all* the optimizations people have thought of over many decades of chess engine programming. I feel this question is much too broad for the SE format, you'll have more luck reading everything at the chess programming wiki ( https://www.chessprogramming.org/Main_Page ) and the Stockfish source code ( https://github.com/official-stockfish/Stockfish/tree/master/src ).
Comments.UserDisplayName: RemcoGerlich
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-15T09:49:00.070Z
Comments.Text: You mention: *Even if I use an evaluation function, which just returns a constant, I will not get beyond 100kN/s*. Perhaps you need to improve your move generator then, which may be slowing you down greatly. Ideally, in a fast chess engine, the move generation should take up no more than 5-10% of the total cycles.
Comments.UserDisplayName: Nihar Karve
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-16T21:06:29.280Z
Comments.Text: 100 clocks? No way. i5 is already GHz. As Nihar mentioned, you generate nodes too slowly. Ideally, at each move you already know the possible next moves, and can just update that set upon each move/unmove.
Comments.UserDisplayName: user21820
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-16T22:23:05.463Z
Comments.Text: 1 GHZ = 1 Billion Clocks / s => 1000 Clocks per Node ... srry
Comments.UserDisplayName: Niclas
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-16T22:24:03.137Z
Comments.Text: You are totally right!
Comments.UserDisplayName: Niclas
Tags: <engines><programming>
Title: How engines accomplish calculation speeds of 1000kN/s per Core and above?
ThreadText: # How engines accomplish calculation speeds of 1000kN/s per Core and above?
  
  (Asked by: username_0 on 2021-07-14)
  
  I am developing a chess engine to improve my Cpp. It works, which means it generates legal moves and it can play them out. I optimized a bit and now achieve ~20k N / s, which is way better than my original 100 N /s
  
  But Stockfish does 1MK/s, which is beyond my conception. This is about 1 Node within 100 clocks. Even if I use an evaluation function, which just returns a constant, I will not get beyond 100kN/s. So how is this pure speed achieved?
  
  **Tags:** engines, programming
  
  > **Comments:**
  > **username_1**: By applying *all* the optimizations people have thought of over many decades of chess engine programming. I feel this question is much too broad for the SE format, you'll have more luck reading everything at the chess programming wiki ( https://www.chessprogramming.org/Main_Page ) and the Stockfish source code ( https://github.com/official-stockfish/Stockfish/tree/master/src ).  
  > **username_2**: You mention: *Even if I use an evaluation function, which just returns a constant, I will not get beyond 100kN/s*. Perhaps you need to improve your move generator then, which may be slowing you down greatly. Ideally, in a fast chess engine, the move generation should take up no more than 5-10% of the total cycles.  
  > **username_3**: 100 clocks? No way. i5 is already GHz. As username_2 mentioned, you generate nodes too slowly. Ideally, at each move you already know the possible next moves, and can just update that set upon each move/unmove.  
  > **username_0**: 1 GHZ = 1 Billion Clocks / s => 1000 Clocks per Node ... srry  
  > **username_0**: You are totally right!  
  
  ---
  
  ## 0 answers
  
  