Answers.Body: <p>Stockfish prints out the game notation for perft divide.</p>
  
  <p>Say you generate all the first moves, store each move as a FEN string. You will then calculate all the moves for each FEN string you then created. Note that for each generated FEN string, you do not change which colour is to move.</p>
  
  <p>Obviusly you cannot store every FEN string generated, as that is a massive memory concern.</p>
  
  <p><a href="https://www.chessprogramming.org/Perft#Divide" rel="nofollow noreferrer">https://www.chessprogramming.org/Perft#Divide</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-10-24T16:53:59.110Z
Answers.LastActivityDate: 2020-04-28T04:11:08.790Z
Answers.LastEditDate: 2020-04-28T04:11:08.790Z
Answers.UserDisplayName: andersfylling
Answers.Body: <p>The number of nodes from your perft results is identical to Stockfish (<code>1486</code>), so I think your implementation is correct.</p>
  
  <p>How you report the individual moves is <strong>unimportant</strong>. The format is <strong>not part</strong> of perft, you can report it any way you want, Stockfish can do it anyway it wants. There is no standard. There is no rule that you have to report the root moves or the leaf nodes. This is <strong>implementation</strong> defined. In my own implementation, I'd just report <code>1486</code>.</p>
  
  <p>You just need to get the number correct.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:42:37.703Z
Answers.Text: When the number is incorrect, I need a way to distinguish which moves are wrong. This is where game notation comes in handy at perft. I just odn't understand how I get the right count, and yet my moves are completely opposite from stockfish.
Answers.UserDisplayName: andersfylling
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:43:52.557Z
Answers.Text: @andersfylling I don't have your code, nobody here does so we can't tell you why you got the right count. How you report your moves is not important. Stockfish did it for root moves, you did it for leaf nodes. Do you understand???
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:44:19.310Z
Answers.Text: @andersfylling Many implementation would just report a single number.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:48:24.330Z
Answers.Text: @andersfylling If you want to reproduce Stockfish, you'll need to do it for root moves. But it's not important as long as you get the number correct.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:50:14.023Z
Answers.Text: If I want the moves for the "root" nodes I can just do perft(1). which won't be anywhere near stockfish. still the number i get would be correct.
  
  It is important. Cause I can't find my issue without comparing moves. Don't tell me that I don't need the moves when the count is correct, but the moves differ. That makes no sense.
Answers.UserDisplayName: andersfylling
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:51:16.953Z
Answers.Text: I mean do perft(n) but report the results like Stockfish. You don't have to do that. You don't have to copy Stockfish. You get no prize for doing that. @andersfylling
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:51:33.017Z
Answers.Text: Cause at perft(3) the number is incorrect as well. Which makes just the count, useless.
Answers.UserDisplayName: andersfylling
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:52:08.787Z
Answers.Text: @andersfylling Then you'll change your code to report like Stockfish.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T16:55:02.083Z
Answers.Text: I found out what the difference was. Stockfish doesn't record the game notations in a normal perft. It uses divide.
Answers.UserDisplayName: andersfylling
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T14:40:41.330Z
Answers.LastActivityDate: 2017-10-24T14:40:41.330Z
Answers.UserDisplayName: SmallChess
Body: <p>I'm debugging my engine using Stockfish, and I suddenly notice a massive difference between mine and Stockfish.</p>
  
  <p>Board and fen string</p>
  
  <pre><code> +---+---+---+---+---+---+---+---+
   | r | n | b | q |   | k |   | r |
   +---+---+---+---+---+---+---+---+
   | p | p |   | P | b | p | p | p |
   +---+---+---+---+---+---+---+---+
   |   |   | p |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   |   |   | B |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   | P | P | P |   | N | n | P | P |
   +---+---+---+---+---+---+---+---+
   | R | N | B | Q | K |   |   | R |
   +---+---+---+---+---+---+---+---+
  
  Fen: rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8
  </code></pre>
  
  <p>The results from Stockfish:</p>
  
  <pre><code>go perft 2
  a2a3: 34
  b2b3: 34
  c2c3: 34
  g2g3: 34
  h2h3: 34
  a2a4: 34
  b2b4: 33
  g2g4: 34
  h2h4: 34
  d7c8q: 31
  d7c8r: 31
  d7c8b: 41
  d7c8n: 41
  e2g1: 34
  e2c3: 34
  e2g3: 34
  e2d4: 34
  e2f4: 34
  b1d2: 34
  b1a3: 34
  b1c3: 34
  c4b3: 34
  c4d3: 34
  c4b5: 34
  c4d5: 35
  c4a6: 33
  c4e6: 35
  c4f7: 32
  c1d2: 34
  c1e3: 34
  c1f4: 34
  c1g5: 32
  c1h6: 31
  h1f1: 34
  h1g1: 34
  d1d2: 34
  d1d3: 34
  d1d4: 34
  d1d5: 35
  d1d6: 28
  e1f1: 34
  e1d2: 34
  e1f2: 28
  e1g1: 34
  
  Nodes searched: 1486
  </code></pre>
  
  <p>The result from my engine:</p>
  
  <pre><code>a7a5: 43
  a7a6: 43
  b7a6: 1
  b7b5: 43
  b7b6: 44
  b8a6: 44
  b8d7: 44
  c6b5: 1
  c6c5: 44
  c6d5: 2
  c8d7: 40
  d8a5: 42
  d8b6: 42
  d8c7: 42
  d8c8: 4
  d8d1: 2
  d8d2: 2
  d8d3: 2
  d8d4: 2
  d8d5: 2
  d8d6: 2
  d8d7: 42
  d8e8: 44
  e7a3: 42
  e7b4: 43
  e7c5: 43
  e7d6: 44
  e7f6: 43
  e7g5: 43
  e7h4: 42
  f2d1: 43
  f2d3: 43
  f2e4: 43
  f2g4: 43
  f2h1: 43
  f2h3: 43
  f7e6: 1
  f7f5: 43
  f7f6: 43
  f8e8: 4
  f8f7: 1
  f8g8: 43
  g7g5: 42
  g7g6: 43
  g7h6: 1
  h7h5: 43
  h7h6: 43
  h8g8: 44
  
  Nodes searched: 1486
  </code></pre>
  
  <p>Now I know my engine does something incorrect, but why does Stockfish do game notation as if it's white moving on perft 2? Since white starts at perft 1, shouldn't black move at perft 2?</p>
  
  <p>Does white move for every single depth?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:14:28.147Z
Comments.Text: What's EGN in chess?
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:15:18.863Z
Comments.Text: A move created by combining chess board indexes: `f2h1`. Showing from and to. Edit: That weird moment you have no idea where you got EGN from. This is smith notation
Comments.UserDisplayName: andersfylling
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:17:52.003Z
Comments.Text: I don't understand your question. Your FEN gives white to move. Why would your engine return black moves? It's WHITE TO MOVE.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:18:38.033Z
Comments.Text: White moves, and then at next depth black moves?
Comments.UserDisplayName: andersfylling
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:20:39.443Z
Comments.Text: Perft 2 counts moves up to depth 2. That includes depth 1 and 2. That doesn't mean Black to move in your position.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:22:15.317Z
Comments.Text: Perft should only count leaf nodes. Which means, moves at a certain depth.
Comments.UserDisplayName: andersfylling
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:23:01.923Z
Comments.Text: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/67586/discussion-between-andersfylling-and-smallchess).
Comments.UserDisplayName: andersfylling
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:32:16.757Z
Comments.Text: I have to admit I read your question several times, but I still don't understand why. The Stockfish outputs mean the number of leaf nodes for each possible legal move given a depth. There's nothing wrong with that. Your outputs are Black moves, Apple and Orange.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:36:25.947Z
Comments.Text: Perft(2) => depth1: white moves, for every move white did, every move black can do is generated (then black moves at depth 2). Right?
Comments.UserDisplayName: andersfylling
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:37:21.350Z
Comments.Text: Yes. But that doesn't answer the anything.
Comments.UserDisplayName: SmallChess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-24T14:39:22.890Z
Comments.Text: It definetly does. Since perft counts every leaf node (moves at a certain depth), and black does the last move. it should count black moves. Since white moves first, then black moves, black would be leaf nodes.
Comments.UserDisplayName: andersfylling
Tags: <stockfish><perft>
Title: Stockfish perft displays reversed game notation?
ThreadText: # Stockfish perft displays reversed game notation?
  
  (Asked by: username_0 on 2017-10-24)
  
  I'm debugging my engine using Stockfish, and I suddenly notice a massive difference between mine and Stockfish.
  
  Board and fen string
  
  ```
   +---+---+---+---+---+---+---+---+
   | r | n | b | q |   | k |   | r |
   +---+---+---+---+---+---+---+---+
   | p | p |   | P | b | p | p | p |
   +---+---+---+---+---+---+---+---+
   |   |   | p |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   |   |   | B |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
   | P | P | P |   | N | n | P | P |
   +---+---+---+---+---+---+---+---+
   | R | N | B | Q | K |   |   | R |
   +---+---+---+---+---+---+---+---+
  
  Fen: rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8
  
  ```
  
  The results from Stockfish:
  
  ```
  go perft 2
  a2a3: 34
  b2b3: 34
  c2c3: 34
  g2g3: 34
  h2h3: 34
  a2a4: 34
  b2b4: 33
  g2g4: 34
  h2h4: 34
  d7c8q: 31
  d7c8r: 31
  d7c8b: 41
  d7c8n: 41
  e2g1: 34
  e2c3: 34
  e2g3: 34
  e2d4: 34
  e2f4: 34
  b1d2: 34
  b1a3: 34
  b1c3: 34
  c4b3: 34
  c4d3: 34
  c4b5: 34
  c4d5: 35
  c4a6: 33
  c4e6: 35
  c4f7: 32
  c1d2: 34
  c1e3: 34
  c1f4: 34
  c1g5: 32
  c1h6: 31
  h1f1: 34
  h1g1: 34
  d1d2: 34
  d1d3: 34
  d1d4: 34
  d1d5: 35
  d1d6: 28
  e1f1: 34
  e1d2: 34
  e1f2: 28
  e1g1: 34
  
  Nodes searched: 1486
  
  ```
  
  The result from my engine:
  
  ```
  a7a5: 43
  a7a6: 43
  b7a6: 1
  b7b5: 43
  b7b6: 44
  b8a6: 44
  b8d7: 44
  c6b5: 1
  c6c5: 44
  c6d5: 2
  c8d7: 40
  d8a5: 42
  d8b6: 42
  d8c7: 42
  d8c8: 4
  d8d1: 2
  d8d2: 2
  d8d3: 2
  d8d4: 2
  d8d5: 2
  d8d6: 2
  d8d7: 42
  d8e8: 44
  e7a3: 42
  e7b4: 43
  e7c5: 43
  e7d6: 44
  e7f6: 43
  e7g5: 43
  e7h4: 42
  f2d1: 43
  f2d3: 43
  f2e4: 43
  f2g4: 43
  f2h1: 43
  f2h3: 43
  f7e6: 1
  f7f5: 43
  f7f6: 43
  f8e8: 4
  f8f7: 1
  f8g8: 43
  g7g5: 42
  g7g6: 43
  g7h6: 1
  h7h5: 43
  h7h6: 43
  h8g8: 44
  
  Nodes searched: 1486
  
  ```
  
  Now I know my engine does something incorrect, but why does Stockfish do game notation as if it's white moving on perft 2? Since white starts at perft 1, shouldn't black move at perft 2?
  
  Does white move for every single depth?
  
  **Tags:** stockfish, perft
  
  > **Comments:**
  > **username_1**: What's EGN in chess?  
  > **username_0**: A move created by combining chess board indexes: `f2h1`. Showing from and to. Edit: That weird moment you have no idea where you got EGN from. This is smith notation  
  > **username_1**: I don't understand your question. Your FEN gives white to move. Why would your engine return black moves? It's WHITE TO MOVE.  
  > **username_0**: White moves, and then at next depth black moves?  
  > **username_1**: Perft 2 counts moves up to depth 2. That includes depth 1 and 2. That doesn't mean Black to move in your position.  
  > **username_0**: Perft should only count leaf nodes. Which means, moves at a certain depth.  
  > **username_0**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/67586/discussion-between-username_0-and-username_1).  
  > **username_1**: I have to admit I read your question several times, but I still don't understand why. The Stockfish outputs mean the number of leaf nodes for each possible legal move given a depth. There's nothing wrong with that. Your outputs are Black moves, Apple and Orange.  
  > **username_0**: Perft(2) => depth1: white moves, for every move white did, every move black can do is generated (then black moves at depth 2). Right?  
  > **username_1**: Yes. But that doesn't answer the anything.  
  > **username_0**: It definetly does. Since perft counts every leaf node (moves at a certain depth), and black does the last move. it should count black moves. Since white moves first, then black moves, black would be leaf nodes.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-10-24. Score: 2 | Accepted answer
  
  Stockfish prints out the game notation for perft divide.
  
  Say you generate all the first moves, store each move as a FEN string. You will then calculate all the moves for each FEN string you then created. Note that for each generated FEN string, you do not change which colour is to move.
  
  Obviusly you cannot store every FEN string generated, as that is a massive memory concern.
  
  <https://www.chessprogramming.org/Perft#Divide>
  
  
  ---
  
  ### Answer by username_1 on 2017-10-24. Score: 2
  
  The number of nodes from your perft results is identical to Stockfish (`1486`), so I think your implementation is correct.
  
  How you report the individual moves is **unimportant**. The format is **not part** of perft, you can report it any way you want, Stockfish can do it anyway it wants. There is no standard. There is no rule that you have to report the root moves or the leaf nodes. This is **implementation** defined. In my own implementation, I'd just report `1486`.
  
  You just need to get the number correct.
  
  > **Comments:**
  > **username_0**: When the number is incorrect, I need a way to distinguish which moves are wrong. This is where game notation comes in handy at perft. I just odn't understand how I get the right count, and yet my moves are completely opposite from stockfish.  
  > **username_1**: @username_0 I don't have your code, nobody here does so we can't tell you why you got the right count. How you report your moves is not important. Stockfish did it for root moves, you did it for leaf nodes. Do you understand???  
  > **username_1**: @username_0 Many implementation would just report a single number.  
  > **username_1**: @username_0 If you want to reproduce Stockfish, you'll need to do it for root moves. But it's not important as long as you get the number correct.  
  > **username_0**: If I want the moves for the "root" nodes I can just do perft(1). which won't be anywhere near stockfish. still the number i get would be correct.  It is important. Cause I can't find my issue without comparing moves. Don't tell me that I don't need the moves when the count is correct, but the moves differ. That makes no sense.  
  > **username_1**: I mean do perft(n) but report the results like Stockfish. You don't have to do that. You don't have to copy Stockfish. You get no prize for doing that. @username_0  
  > **username_0**: Cause at perft(3) the number is incorrect as well. Which makes just the count, useless.  
  > **username_1**: @username_0 Then you'll change your code to report like Stockfish.  
  > **username_0**: I found out what the difference was. Stockfish doesn't record the game notations in a normal perft. It uses divide.  
  
  ---
  
  