Moderator: Andres Valverde
Patrice Duhamel wrote:Thanks for your answer,
I have a "divide" function to enumerate the partial counts for each moves, and I solved some bugs with it.
But, how could I check that transposition table and other engine features are working ?
H.G.Muller wrote:Unfortunately there are no standard node counts available for an alpha-beta tree. The problem is that the number of nodes visited depends on the evaluation function and on the move ordering. ...
Tord Romstad wrote:[*]Extend the UCI/XBoard command set with a few commands of your own for use in debugging.
Tord Romstad wrote:[*] Whenever you add some non-trivial new function to your program, try to write two versions: One which is very slow and stupid, but almost certainly correct, and one which is highly optimised. Verify on a huge number of positions that they give the same results. Remove the slow version only when you feel 100% sure that the fast version is correct.
Ryan Benitez wrote:Tord Romstad wrote:[*]Extend the UCI/XBoard command set with a few commands of your own for use in debugging.
Yes, this has been very helpful to me.
I also think every program should have a showboard command.
H.G.Muller wrote:By the way, did you make sure that you only count hash hits that match both in position and depth? Unlike in search, a larger depth is not upward compatible in perft!
//////////////////////////////////////////////////////////////////////////////////
int findPerftHashNode(HashKey key, int depth, ChessPerftHashNode *pn)
{
ChessPerftHashNode *hash = &perftHashTable[key % HASH_TABLE_SIZE];
if (hash->key == key) {
if (hash->depth >= depth) {
pn = hash;
return 1;
}
}
return 0;
}
//////////////////////////////////////////////////////////////////////////////////
void addPerftHashNode(HashKey key, unsigned char depth)
{
ChessPerftHashNode *hash = &perftHashTable[key % HASH_TABLE_SIZE];
hash->depth = depth;
hash->key = key;
hash->node = node;
}
//////////////////////////////////////////////////////////////////////////////////
void ChessBoard::perft(int depth, int startmove)
{
// find score in hash table
ChessPerftHashNode phnode;
if (findPerftHashNode(_board.hashKey, depth, &phnode)) {
perftNode[depth].node += phnode.node;
return;
}
// generate moves
unsigned int nbMoves = 0;
_board.generateMoves(possibleMoves + startmove, &nbMoves);
for (int n=0; n<nbMoves; n++) {
// make move
if (_board.makeMove(possibleMoves[startmove + n])) {
perftNode[depth].node++;
if (depth > 1) {
perft(depth - 1, startmove + nbMoves);
}
}
// unmake move
_board.unMakeMove(possibleMoves[startmove + n]);
}
// add score in hash table
addPerftHashNode(_board.hashKey, depth, perftNode[depth].node);
}
Patrice Duhamel wrote:H.G.Muller wrote:By the way, did you make sure that you only count hash hits that match both in position and depth? Unlike in search, a larger depth is not upward compatible in perft!
I don't know if my problem is with the transposition table,
or in the use of the transposition table in my perft function.
I'm not sure where I should add the count in the transposition table for perft,
someone can tell me what's wrong in my code ?
(perft function gives good results without the transposition table)
- Code: Select all
//////////////////////////////////////////////////////////////////////////////////
int findPerftHashNode(HashKey key, int depth, ChessPerftHashNode *pn)
{
ChessPerftHashNode *hash = &perftHashTable[key % HASH_TABLE_SIZE];
if (hash->key == key) {
if (hash->depth >= depth) {
pn = hash;
return 1;
}
}
return 0;
}
u64 count;
void perft(int depth)
{
u64 oldcount=count;
if(HASH_HIT && HASH->depth == depth)
{count += HASH->count; return;}
for(ALL_MOVES)
{
if(depth==1) count++; else
{
Make();
perft(depth-1);
UnMake();
}
}
HASH->count = count - oldcount;
HASH->depth = depth;
}
Return to Programming and Technical Discussions
Users browsing this forum: No registered users and 4 guests