Author: J. Wesley Cleveland
Date: 19:38:21 03/06/04
Go up one level in this thread
On March 04, 2004 at 05:18:06, Albert Bertilsson wrote:
>Hi!
>
>I don't think you need many positions to verify your movegen, 5-10 will find you
>most of the bugs.
>
>To really iron out bugs in the movegen I suggest the following aproach:
>Have a command that does perft for all the legal positions in a certain
>position, and prints the values like this (initial position):
>Move A2A3 XYZ moves
>Move A2A4 XYZ moves
>...
>
>Then use another engine that also can do this (Sharper has a command "Divide"
>that produce the same list).
>
>Use the positions at Peter's or Sharper's home page and test your engine. When
>you find a bug, find out excactly why it happens and fix it.
>
>/Regards Albert
Here is code I put into crafty to do this: It adds a second parameter 'd' to
perft to give subtotals for each move. The output looks like this:
White(1): perft 5 d
Ng1h3 198502
Ng1f3 233491
Nb1c3 234656
Nb1a3 198572
h2h4 218829
g2g4 214048
f2f4 198473
e2e4 405385
d2d4 361790
c2c4 240082
b2b4 216145
a2a4 217832
h2h3 181044
g2g3 217210
f2f3 178889
e2e3 402988
d2d3 328511
c2c3 222861
b2b3 215255
a2a3 181046
total moves=4865609 time=0.80
Change the call to OptionPerft in option.c to:
if ((nargs == 2) || (*args[2] != 'd'))
OptionPerft(tree, 1, i, wtm);
else
OptionPerftd(tree, 1, i, wtm);
and add this function at the end of option.c
void OptionPerftd(TREE * RESTRICT tree, int ply, int depth, int wtm)
{
int *mv;
int subtotal;
static char line[256], *p[64];
#if defined(TRACE)
static char move[16];
#endif
tree->last[ply] = GenerateCaptures(tree, ply, wtm, tree->last[ply - 1]);
for (mv = tree->last[ply - 1]; mv < tree->last[ply]; mv++)
if (Captured(*mv) == king)
return;
tree->last[ply] = GenerateNonCaptures(tree, ply, wtm, tree->last[ply]);
p[1] = line;
for (mv = tree->last[ply - 1]; mv < tree->last[ply]; mv++) {
subtotal=total_moves;
#if defined(TRACE)
strcpy(move, OutputMove(tree, *mv, ply, wtm));
#endif
MakeMove(tree, ply, *mv, wtm);
#if defined(TRACE)
if (ply <= trace_level) {
strcpy(p[ply], move);
strcpy(line + strlen(line), " ");
p[ply + 1] = line + strlen(line);
if (ply == trace_level)
printf("%s\n", line);
}
#endif
if (depth - 1)
OptionPerft(tree, ply + 1, depth - 1, Flip(wtm));
else if (!Check(wtm))
{
total_moves++;
}
if (subtotal!=total_moves)
printf("%-5s %d\n",OutputMove(tree, *mv, ply, wtm) ,total_moves-subtotal);
UnmakeMove(tree, ply, *mv, wtm);
}
}
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.