Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: perft weirdness - not castling rights

Author: Russell Reagan

Date: 00:38:15 01/03/03

Go up one level in this thread


I re-worked how the castling rights were being handled because they were kind of
duct taped to my program. Anyway, I don't think this is a castling rights
problem. It is doing it in positions where there are no castling rights. Still
reporting perft wrong, but when I do a detailed perft, it reports it correctly.

Maybe I am computing perft wrong or something. Here are perft() and dperft().

unsigned int perft (int n) {
	if (n <= 1)
		return generateLegalMoves();
	generateLegalMoves();
	int nmoves = 0;
	for (move_t * move = firstMove; move != lastMove; ++move) {
		makeMove(move);
		nmoves += perft(n-1);
		undoMove();
	}
	return nmoves;
}

void dPerft (int n) {
	generateLegalMoves();
	unsigned int total = 0;
	for (move_t * move = firstMove; move != lastMove; ++move) {
		makeMove(move);
		unsigned int p = perft(n-1);
		undoMove();
		total += p;
		cout << moveToString(move) << "	" << p << "	" << total << endl;
	}
}

generateLegalMoves() returns the number of legal moves that were generated.

In quite a few positions, if I do perft n (usually n is 4 or higher when the
problem occurs), and it reports back an incorrect value. Then I do dperft n, and
the total it reports back is correct. Anyone have any idea why they would be
different?

I'm not sure what kind of problem this is. Maybe the perft function is wrong.
Maybe something in make/unmake, or maybe move generation, but so far I'm leaning
towards perft() because it gets calculated correctly in dperft(), which suggests
that make/unmake and movegen work correctly, some of the time...



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.