Computer Chess Club Archives


Search

Terms

Messages

Subject: Repetitions: is this code correct?

Author: Vladimir Medvedev

Date: 05:08:20 07/12/02


How to handle position repetitions during search?

I use the following method:

(pseudo-code)

int CountSearchRepetitions[MAXSIZE];
int CountHistoryRepetitions[MAXSIZE];

int AlphaBeta(Position pos, int alpha, int beta)
{
    if( current_ply > 0 && CountHistoryRepetitions[ pos.GetHash() % MAXSIZE ]>0
)
    {
       return min( 0, beta );
    }

    if( CountSearchRepetitions[ pos.GetHash() % MAXSIZE ] > 1 )
    {
       return min( 0, beta );
    }

    while( get_next_move() )
    {
        pos.MakeMove();
        SearchRepetition[ pos.GetHash() % MAXSIZE ] ++;
        int eval = - AlphaBeta( pos, -beta, -alpha );
        SearchRepetition[ pos.GetHash() % MAXSIZE ] --;
        pos.UnmakeMove();

        ........

    }
}

Is this correct? Shouldn't I return 0 instead min(0, beta)?
Is it good to add repetitions in game history to repetitions on the current
branch?



This page took 0.15 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.