1

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?

  • What's EGN in chess? – SmallChess Oct 24 '17 at 14:14
  • 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 – andersfylling Oct 24 '17 at 14:15
  • 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. – SmallChess Oct 24 '17 at 14:17
  • White moves, and then at next depth black moves? – andersfylling Oct 24 '17 at 14:18
  • Perft 2 counts moves up to depth 2. That includes depth 1 and 2. That doesn't mean Black to move in your position. – SmallChess Oct 24 '17 at 14:20
1

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.

  • 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. – andersfylling Oct 24 '17 at 14:42
  • @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??? – SmallChess Oct 24 '17 at 14:43
  • @andersfylling Many implementation would just report a single number. – SmallChess Oct 24 '17 at 14:44
  • @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. – SmallChess Oct 24 '17 at 14:48
  • 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. – andersfylling Oct 24 '17 at 14:50
0

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://chessprogramming.wikispaces.com/Perft#Divide

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.