Need Help to debug

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Need Help to debug

Post by NaltaP312 »

Hi everyone,

with this nice week end, i continue to debug my program NaltaP.
Base on bitboard and koggestone i have developped some debug tools with the perft function.

All is fine for depth 1, 2 and 3 but 4 i have more moves generated, 197449 nodes generated.
to be exact.
I have debug it and generate a text file, with board display, fen string and list of move generated but i see nothing.

do you see somehting wrong with this ?

rnbqkbnr/pppp1ppp/4p3/8/8/P5P1/1PPPPP1P/RNBQKBNR b KQkq a1 0 1
30 generated moves.
The bkack bishop on f8 capture the white pawn at a3
The black pawn on e6 move to e5
The black pawn on a7 move to a6
The black pawn on a7 move to a5
The black pawn on b7 move to b6
The black pawn on b7 move to b5
The black pawn on c7 move to c6
The black pawn on c7 move to c5
The black pawn on d7 move to d6
The black pawn on d7 move to d5
The black pawn on f7 move to f6
The black pawn on f7 move to f5
The black pawn on g7 move to g6
The black pawn on g7 move to g5
The black pawn on h7 move to h6
The black pawn on h7 move to h5
The black knight on b8 move to a6
The black knight on b8 move to c6
The black knight on g8 move to f6
The black knight on g8 move to h6
The black knight on g8 move to e7
The bkack bishop on f8 move to b4
The bkack bishop on f8 move to c5
The bkack bishop on f8 move to d6
The bkack bishop on f8 move to e7
The black queen on d8 move to h4
The black queen on d8 move to g5
The black queen on d8 move to f6
The black queen on d8 move to e7
The black king on e8 move to e7

Thanks for any idea ;)

Best Regards
Yves :wink:
elpapa
Posts: 211
Joined: Sun Jan 18, 2009 11:27 pm
Location: Sweden
Full name: Patrik Karlsson

Re: Need Help to debug

Post by elpapa »

Have you tried 'divide'? It's a function that loops through the root moves and calls perft for each one. This way you can see where the extra moves are being generated.

This is what the output of that function looks like with my engine from the start position:

Code: Select all

divide 5

move       nodes      caps      ep     p->         +       #    cstl     time
----- ---------- --------- ------- ------- --------- ------- ------- --------
b1c3      234656      4686       0       0      2918       8       0    0.05s
b1a3      198572      2983       0       0      1751       8       0    0.03s
g1h3      198502      2993       0       0       497       8       0    0.03s
g1f3      233491      4676       0       0       432       0       0    0.03s
a2a3      181046      1648       0       0       467       8       0    0.03s
a2a4      217832      2460      19       0       322       8       0    0.03s
b2b3      215255      2505       0       0       353       8       0    0.03s
b2b4      216145      3704      35       0       472       8       0    0.05s
c2c3      222861      3670       0       0      2508      12       0    0.03s
c2c4      240082      4787      38       0      1992      12       0    0.05s
d2d3      328511      5344       0       0       357       8       0    0.06s
d2d4      361790      8307      37       0       686      12       0    0.05s
e2e3      402988      9141       0       0      5835     109       0    0.08s
e2e4      405385     10952      37       0      5784     106       0    0.09s
f2f3      178889      1507       0       0       320       0       0    0.03s
f2f4      198473      3082      38       0       465       8       0    0.03s
g2g3      217210      2546       0       0       893       8       0    0.05s
g2g4      214048      3550      35       0       365       0       0    0.03s
h2h3      181044      1646       0       0       465       8       0    0.03s
h2h4      218829      2532      19       0       469       8       0    0.03s
Now, if you have too many (or few) moves generated in one branch, you make that move and then call divide again from that position, reducing depth by one. This way you are able to hone in on the problem. Of course you need a bugfree engine with a divide function to compare it with. Mine is not public yet, but I think most engines have it.
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: Need Help to debug

Post by NaltaP312 »

Hello Patrik,

thanks for this point.
Yes i'm not used divide, so i will implement it.
I like so, your array for debug, i will try to implement it too.
I think like i have discussed with some people, the first thing is to have a generate move without bug : so be patient and step by step.

Thanks for your help.
Regards
Yves
Richard Allbert
Posts: 792
Joined: Wed Jul 19, 2006 9:58 am

Re: Need Help to debug

Post by Richard Allbert »

Sharper is an example of an engine with a divide function. It also is a fast move generator, so doesn't take too long :)

I used it for perft debugging.

Richard
elpapa
Posts: 211
Joined: Sun Jan 18, 2009 11:27 pm
Location: Sweden
Full name: Patrik Karlsson

Re: Need Help to debug

Post by elpapa »

NaltaP312 wrote:I think like i have discussed with some people, the first thing is to have a generate move without bug : so be patient and step by step.
Absolutely, I think it's essential to have a working move generator before programming the search routines.

Btw, I tried a couple of engines and divide did not work. Maybe they don't have it or they call it by a different name. The engine I used to compare mine to is called Roce. Google 'roce chess' and you can find more info there.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Need Help to debug

Post by sje »

Your FEN has a couple of errors. A version that works is:
[D] r1bqkbnr/pppp1ppp/4p3/8/8/P5P1/1PPPPP1P/RNBQKBNR b KQkq - 0 1

Code: Select all

[] sf r1bqkbnr/pppp1ppp/4p3/8/8/P5P1/1PPPPP1P/RNBQKBNR b KQkq - 0 1
Available move count: twenty-nine
[] dm
Bb4 Bc5 Bd6 Be7 Bxa3 Ke7 Ne7 Nf6 Nh6 Qe7 Qf6 Qg5 Qh4 Rb8 a5 a6 b5 b6 c5 c6 d5 d6 e5 f5 f6 g5 g6 h5 h6
[] empbulk 2
Bb4 18
Bc5 20
Bd6 20
Be7 20
Bxa3 22
Ke7 20
Ne7 20
Nf6 20
Nh6 20
Qe7 20
Qf6 20
Qg5 20
Qh4 20
Rb8 20
a5 20
a6 20
b5 20
b6 20
c5 20
c6 20
d5 20
d6 20
e5 20
f5 20
f6 20
g5 20
g6 20
h5 20
h6 20
Depth: 2   Count: 580   Elapsed: 0.160866  (3605.49 Hz / 0.000277355 s)
[] empbulk 3
Bb4 584
Bc5 658
Bd6 619
Be7 539
Bxa3 662
Ke7 440
Ne7 440
Nf6 539
Nh6 559
Qe7 539
Qf6 733
Qg5 857
Qh4 800
Rb8 579
a5 599
a6 579
b5 600
b6 599
c5 561
c6 619
d5 640
d6 540
e5 580
f5 580
f6 499
g5 560
g6 599
h5 599
h6 559
Depth: 3   Count: 17,261   Elapsed: 0.160912  (107270 Hz / 9.32229e-06 s)
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: Need Help to debug

Post by NaltaP312 »

Hello,

yes you have right, the en passant is false in the fen.
many thanks for your example, i will examine your generation move with mine.

Best regards
Yves
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: Need Help to debug

Post by NaltaP312 »

Hi,

yes, i have found too, mediocre.
so now i have some way and example about how to work to debug.

Thanks , now i'm not alone in this wondefull country of engine chess development.

Regards
Yves
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Need Help to debug

Post by sje »

Some good tests can be found here:

http://www.chessbox.de/Compu/schachzahl4_e.html

For each position, the FEN can be had by examining the position image properties.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Self tests

Post by sje »

These are the movepath enumeration positions, with counts for depths one through four, that Symbolic checks each time the program starts:

Code: Select all

"2qrr1n1/3b1kp1/2pBpn1p/1p2PP2/p2P4/1BP5/P3Q1PP/4RRK1 w - - 0 1", 44, 833, 35770, 766147
"7k/8/8/8/8/8/8/K7 w - - 0 1", 3, 9, 54, 324
"8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1", 14, 191, 2812, 43238
"8/3K4/2p5/p2b2r1/5k2/8/8/1q6 b - - 0 1", 50, 279, 13310, 54703
"8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 1", 5, 117, 3293, 67197
"8/PPP4k/8/8/8/8/4Kppp/8 w - - 0 1", 18, 290, 5044, 89363
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1", 48, 2039, 97862, 4085603
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", 20, 400, 8902, 197281