user14600: 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?

user14600: 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

user825: 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.

14600: <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>
 14600: <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>
 825: <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>
