Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Request for code snippet for checking repetative moves

Author: Sven Reichard

Date: 07:52:22 11/09/00

Go up one level in this thread


My suggestion inserted:

On November 08, 2000 at 05:45:42, Michel Langeveld wrote:

>Does someone know a way to check for repetative moves in the correct way.
>To help a bit I added this piece of code.
>
>THashTable h;
>
>int negamax(int depth)
>{
>   int best = -MAXINT;
>   int score;
>
>   if ( draw(board) )
>   {
>      return 0;
>   }
/**/hash_entry = obtain_hash_entry ( board, h );
/**/if ( is_valid(hash_entry) && hash_entry.seen_before == 1 )
       return 0;
>
>   if ( mate(board) )
>   {
>      return -9999;
>   }
>
>   TMovelist m = makemovelist(board);
>
>   for (int i=0; i<movecount; i++)
>   {
>       make_move(movelist[i], board);
/**/    hash_entry.seen_before = 1;
>       score = -negamax(depth-1)
>       if (score > best)
>       {
>           best = score;
>       }
/**/    hash_entry.seen_before = 0; /* if it had been seen before we wouldn't
/**/                                 * get to this point */
>       undo_move(movelist[i], board);
>   }
>   return best;
>}

The idea behind this is that if we can force the opponent into a two-fold
repetition, we can also force her into a three-fold repetition. The only case
that is missed is a position that has occured twice before in the actual game,
so this needs to be taken care of separately.
W/o transposition tables it is virtually impossible to check for repetitions.

Sven



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.