perft/divide bug in roce38 and Sharper? [SOLVED]

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

perft/divide bug in roce38 and Sharper? [SOLVED]

Postby thedrunkard » 16 Oct 2013, 17:02

Hello,

I'm relatively new to chessengine programming. Currently I'm trying to squash all the bugs in my movegenerator using perft/divide-functions of other engines (roce38 and sharper). It might be that I still understand something wrong but I think I found a bug/inconsistent behaviour.

The position in question is the following:

rnbqkbnr/1ppppppp/8/8/1p6/P7/2PPPPPP/RNBQKBNR w KQkq - 0 3

Sharper:
Code: Select all
setboard rnbqkbnr/1ppppppp/8/8/1p6/P7/2PPPPPP/RNBQKBNR w KQkq - 0 3
divide 2
b1c3 26
c1b2 25
a1a2 25
g1h3 25
g1f3 25
c2c3 26
c2c4 26
d2d3 25
d2d4 25
e2e3 25
e2e4 25
f2f3 25
f2f4 25
g2g3 25
g2g4 25
h2h3 25
h2h4 25
a3a4 23
a3b4 25
Nodes: 476
Moves: 19


roce38:
Code: Select all
roce: setboard rnbqkbnr/1ppppppp/8/8/1p6/P7/2PPPPPP/RNBQKBNR w KQkq - 0 3

roce: divide 2
a3a4 23
a3b4 25
c2c3 26
c2c4 26
d2d3 25
d2d4 25
e2e3 25
e2e4 25
f2f3 25
f2f4 25
g2g3 25
g2g4 25
h2h3 25
h2h4 25
a1a2 25
b1c3 26
c1b2 25
g1h3 25
g1f3 25
Moves: 19
Nodes: 476


Both engines give (c2c4 26). My engine however gives (c2c4 25). So, naturally, I try the position with c2c4 played with (divide 1) and to my surprise both engines now give 25:

Sharper:
Code: Select all
setboard rnbqkbnr/1ppppppp/8/8/1pP5/P7/3PPPPP/RNBQKBNR b KQkq - 0 3
divide 1
b7b6 1
b7b5 1
c7c6 1
c7c5 1
d7d6 1
d7d5 1
e7e6 1
e7e5 1
f7f6 1
f7f5 1
g7g6 1
g7g5 1
h7h6 1
h7h5 1
a8a7 1
a8a6 1
a8a5 1
a8a4 1
a8a3 1
b8c6 1
b8a6 1
b4b3 1
b4a3 1
g8h6 1
g8f6 1
Nodes: 25
Moves: 25


roce38:
Code: Select all
roce: setboard rnbqkbnr/1ppppppp/8/8/1pP5/P7/3PPPPP/RNBQKBNR b KQkq - 0 3

roce: divide 1

b7b6 1
b7b5 1
c7c6 1
c7c5 1
d7d6 1
d7d5 1
e7e6 1
e7e5 1
f7f6 1
f7f5 1
g7g6 1
g7g5 1
h7h6 1
h7h5 1
b4b3 1
b4a3 1
a8a7 1
a8a6 1
a8a5 1
a8a4 1
a8a3 1
b8a6 1
b8c6 1
g8f6 1
g8h6 1
Moves: 25


Is this really a bug or am I crazy? ;)
I hope someone could verify this or enlighten me.
Thank you very much in advance!
Last edited by thedrunkard on 17 Oct 2013, 00:15, edited 2 times in total.
thedrunkard
 
Posts: 3
Joined: 16 Oct 2013, 14:00

Re: perft/divide bug in roce38 and Sharper?

Postby Robert Pope » 16 Oct 2013, 22:20

When you created the setboard for after c2c4, you didn't set the ep flag.

b4c3 is a legal response to c2c4, which is why 26 is correct. But in the subsequent setboard, since it doesn't have the ep flag set, b4c3 is not a legal move.
Robert Pope
 
Posts: 39
Joined: 08 Apr 2006, 17:27

Re: perft/divide bug in roce38 and Sharper?

Postby thedrunkard » 16 Oct 2013, 22:45

Ah, damnit! I'm crazy at last ;D
If I hadn't been too lazy to check the number of moves by hand I might have even found this by myself x)
Thank you very much!
thedrunkard
 
Posts: 3
Joined: 16 Oct 2013, 14:00

Re: perft/divide bug in roce38 and Sharper?

Postby thedrunkard » 17 Oct 2013, 00:09

Maybe this might be helpful for someone else: The bug was within my makemove() routine: When a move is played I check wether the moved piece is a pawn and if it is a double pawnpush. There I actually only checked wether it is a black pawn due to a upper and lower case mistake.
thedrunkard
 
Posts: 3
Joined: 16 Oct 2013, 14:00


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 27 guests