Author: Joost Buijs
Date: 14:36:35 03/16/04
Go up one level in this thread
Your perft function seems to be rather slow indeed.
On a machine comparable to yours my program runs perft at ~6 million moves/sec.
The only difference as far as I can see is that you have to update your
attack-boards. Are they needed for move generation?
Notice that I use rotated bitboards in my move generator, this method is
probably slow compared to others.
I generate all moves, also illegal ones, and check afterwards if they are legal.
In the move generator move-ordering is done using SEE and piece/square tables.
This is slowing things down somewhat.
At the moment I'm using the Intel C++ compiler v. 7.1. In the past I also tried
the Borland C++ builder, this gave me a perft performance of ~4 million moves
/sec.
UINT64 Perft(POSITION *p, int depth)
{
static int ply = 0;
INT64 n = 0;
double start_time, current_time;
MOVE movelist[MAXMOVES], *moves, *move;
UNDO undo;
if (ply == 0) start_time = PrecisionTime();
ply++;
moves = GenAllMoves(p, movelist);
for (move = movelist; move < moves; move++) {
DoMove(p, move, &undo);
if (!Attacked(p, p->king[Opposite(p->wtm)], p->wtm)) {
if (depth > 1) n += Perft(p, depth - 1);
else n++;
}
UndoMove(p, move , &undo);
}
ply --;
switch (ply) {
case 0: current_time = PrecisionTime();
fprintf(stdout, "\nNumber of moves = %I64d\n", n);
fprintf(stdout, "Elapsed time = %0.2f seconds\n", current_time -
start_time);
if (current_time - start_time > 0.0)
fprintf(stdout, "Moves per second = %0.0f\n", (double)n / (current_time -
start_time));
break;
case 1: fprintf(stdout, "."); break;
}
return n;
}
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.