Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Arasan 7.4 64-bit Speedup

Author: Gerd Isenberg

Date: 13:56:47 03/30/04

Go up one level in this thread


// oups, not so easy out of the class context
// two routines i played with some time ago:
// probably not so good to test the compiler ;-)

typedef unsigned __int64 BitBoard;

bool isDeBruijnN(const BitBoard &magic, int n)
{
	bool isdbjn[64*64];
	int bitpos;
	unsigned int deBruijn;

	for (bitpos = 0; bitpos < 64*64; bitpos++)
		isdbjn[bitpos] = false;

	for (bitpos = 0; bitpos < 64; bitpos++)
	{
		deBruijn = (unsigned int) ((magic << bitpos) >> (64-n));
		if ( isdbjn[deBruijn] )
			return false;
		isdbjn[deBruijn] = true;
	}
	return true;
}


// and a recursive one

static unsigned int nodeCount = 0;
static unsigned int foundCount = 0;

void genDeBruijn(BitBoard sequence, int bitpos)
{
	static BitBoard uniqueCheck = 0;
	nodeCount++;
	unsigned int uniqueIdx = (unsigned int) (sequence>>bitpos) & 63;
	BitBoard uniqueBit = (BitBoard)1 << uniqueIdx;

	if ( (uniqueCheck & uniqueBit) == 0 && uniqueIdx != 32 )
	{
		if ( bitpos == 0 )
		{
			foundCount++;
                        // notify(sequence);
		}
		else
		{
			uniqueCheck |= uniqueBit;
			if ( bitpos == 1 )
			{
				genDeBruijn(sequence|1, 0);
			}
			else
			{
				bitpos--;
				genDeBruijn(sequence|((BitBoard)1<<bitpos), bitpos);
				genDeBruijn(sequence, bitpos);
			}
			uniqueCheck &= ~uniqueBit;
		}
	}
}




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.