Author: Andrew Williams
Date: 14:20:56 03/16/04
Go up one level in this thread
On March 16, 2004 at 16:32:45, Andrew Williams wrote:
>Hi Matthias,
>
>PM seems to get a different node count for the first position at ply 3?
>
>Andrew
>
>On March 16, 2004 at 15:04:53, Matthias Gemuh wrote:
>
>>
>>
>>
>>I am trying to find out why my engine is 6...10 times slower than others at
>>runtime (got no profiler). Is the speed of this Perft() acceptable on 2.0 GHz ?
>>Note that attack boards and hash keys are also calculated/updated.
>>
>>
>>
>>void Perft(int nPerft, int nPly, *nCount, nSideToMove, ChsStrct, nMethod)
>>{
>> if (nPerft <= 0) return;
>> CalculateAttackBoards(ChsStrct, &AtkInfo1);
>> GenerateMoves(ChsStrct, nSideToMove, nMoveOffset, &AtkInfo1);
>> for (i= 0; i < ChsStrct->MoveCount; i++) {
>> Move = ChsStrct->MoveList[nMoveOffset+i];
>> if (!MiniMakeMove(ChsStrct, Move, true)) continue;
>> *nCount += 1;
>> Perft(nPerft-1, nPly+1, nCount, nOtherSide, ChsStrct, nMethod);
>> MiniUnmakeMove(ChsStrct, Move);
>> }
>>}
>>
>>
>>rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
>>PerftPly = 3
>>nCount = 9322
>>nps = 932200
>
>nCount: 8902 ??????????
>PM nps: 445100
Hi Matt.
I've looked more closely at your code and it seems you're counting all nodes
instead of just the leaves. Not to worry. When I count all nodes I get the same
total.
I've made a quick change to PM's approach - I was sorting the nodes, which of
course is not required. Furthermore, I forgot about the Athlon 64's habit of
"throttling back" the clock speed when it's not busy. And even furthermore, my
timer is in hundredths for this and I can't be bothered to change it, so the
perft 3 for that position is too fast to measure properly. So here is my figure
for perft 5 from the starting position:
> rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
> PerftPly = 5
> nCount = 5072212
> nps = 1249313
I get the same nodes this time and a speed of: 2354934 nps
My perft looks like this now (qNodes = perft, abNodes = tot nodes [ie the same
as your measure]):
int perft(int ply, int depth) {
int legalPosition;
int mvNum;
move mv;
int inCheck;
abNodes++;
if(ply > depth) qNodes++;
if(ply > depth || ply >= MAX_DEPTH) {
return 0;
}
plystart[ply+1] = plystart[ply];
inCheck = in_check(whoseTurn);
if(inCheck) {
legalPosition = get_me_out_of_check(ply);
} else {
legalPosition = generate_moves(whoseTurn, ply);
}
if(legalPosition == FALSE) return -ILLEGAL_POSITION;
// sort_tree(ply);
mvNum = plystart[ply];
while(mvNum < plystart[ply+1]) {
mv = tree[mvNum].mv;
if(ply == 1) {
print_move(mv);
fprintf(logFile, "\n");
}
make_move(mv);
if(in_check(OTHERSIDE(whoseTurn))) {
unmake_move();
mvNum++;
continue;
}
tree[mvNum].score = -perft(ply+1, depth);
unmake_move();
mvNum++;
}
return 0;
}
Cheers
Andrew
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.