Stockfish giving contradictory results on perft funtion

408 views Asked by At

I'm working on a Unity chess program and I'm using stockfish to debug my moves generation algorithm by comparing the perft function results.

On this position (8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1) with a depth of 2, Stockfish gives this result:

f3f2: 20
d6d5: 22
c7c6: 23
c7c5: 7
f3e2: 18
f3g2: 18
h5b5: 5
h5c5: 20
h5d5: 22
h5e5: 22
h5f5: 22
h5g5: 22
h5h6: 22
h5h7: 22
h5h8: 22
h4g3: 20
h4g5: 22
h4g4: 21

Nodes searched: 350

Then, if I try to apply the move c7c5 by changing the fen string to this (8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1) and the depth to 1, Stockfish only gives 6 outputs:

b4a3: 1
b4b3: 1
b4c3: 1
b4a4: 1
b4c4: 1
b4a5: 1

Nodes searched: 6

So it's giving an output of 6 instead of 7, as it had said at a depth of 2 (c7c5: 7 means that after the move c7c5 there are 7 possible opponent responses). Why is this happening?

position fen 8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
d

 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   | 8
 +---+---+---+---+---+---+---+---+
 |   |   | p |   |   |   |   |   | 7
 +---+---+---+---+---+---+---+---+
 |   |   |   | p |   |   |   |   | 6
 +---+---+---+---+---+---+---+---+
 |   | P |   |   |   |   |   | r | 5
 +---+---+---+---+---+---+---+---+
 |   | K |   |   |   |   |   | k | 4
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   | p |   |   | 3
 +---+---+---+---+---+---+---+---+
 |   |   |   |   | P |   | P |   | 2
 +---+---+---+---+---+---+---+---+
 |   | R |   |   |   |   |   |   | 1
 +---+---+---+---+---+---+---+---+
   a   b   c   d   e   f   g   h

Fen: 8/2p5/3p4/1P5r/1K5k/5p2/4P1P1/1R6 b - - 0 1
Key: EF2C6A67E054E287
Checkers:
go perft 2
f3f2: 20
d6d5: 22
c7c6: 23
c7c5: 7
f3e2: 18
f3g2: 18
h5b5: 5
h5c5: 20
h5d5: 22
h5e5: 22
h5f5: 22
h5g5: 22
h5h6: 22
h5h7: 22
h5h8: 22
h4g3: 20
h4g5: 22
h4g4: 21

Nodes searched: 350

position fen 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
d

 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   | 8
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   |   |   |   | 7
 +---+---+---+---+---+---+---+---+
 |   |   |   | p |   |   |   |   | 6
 +---+---+---+---+---+---+---+---+
 |   | P | p |   |   |   |   | r | 5
 +---+---+---+---+---+---+---+---+
 |   | K |   |   |   |   |   | k | 4
 +---+---+---+---+---+---+---+---+
 |   |   |   |   |   | p |   |   | 3
 +---+---+---+---+---+---+---+---+
 |   |   |   |   | P |   | P |   | 2
 +---+---+---+---+---+---+---+---+
 |   | R |   |   |   |   |   |   | 1
 +---+---+---+---+---+---+---+---+
   a   b   c   d   e   f   g   h

Fen: 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - - 0 1
Key: 17EBC3EFE240B12C
Checkers: c5
go perft 1
b4a3: 1
b4b3: 1
b4c3: 1
b4a4: 1
b4c4: 1
b4a5: 1

Nodes searched: 6

This is the full command

1

There are 1 answers

0
Jane Doe On BEST ANSWER

That's a wrong FEN you are using. The FEN string after making the move c7c5 is 8/8/3p4/1Pp4r/1K5k/5p2/4P1P1/1R6 w - c6 0 2. You forgot about the en passant square.