Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: perft weirdness - not castling rights

Author: Peter Fendrich

Date: 01:29:10 01/03/03

Go up one level in this thread


On January 03, 2003 at 03:38:15, Russell Reagan wrote:

>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...

It's hard to see why you should get different results if it's not within
generateLeagalMoves(). One thought, is it possible that firstMove and/or
lastMove in some way are corrupted due to the recursion in perft?
I dont know what they stand for if they are "real" or maybe it's just
pseudocode...
Peter



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.