Computer Chess Club Archives


Search

Terms

Messages

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

Author: Michel Langeveld

Date: 12:15:49 11/09/00

Go up one level in this thread


Thank you very much for your response.
You had a very similiar post of the idea I was thinking about.
Although I have still some questions about your code additions...

>My suggestion inserted:

I have marked out your code changes and added some questions in it.

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

   //ML: changed this draw line a bit to make clear
   //what with this function is meant
   if ( stale_mate(board) || to_less_material(board) )
   {
      return 0;
   }

   hash_entry = obtain_hash_entry ( board, h );

   //what do you mean by isvalid.
   //is it possible that a an hashentry is not valid??

   //ML: Is it necesarry to put this line above the mate??
   if ( is_valid(hash_entry) && hash_entry.seen_before == 1 )
   {
      return 0;
   }

   if ( mate(board) )
   {
      return 9999;   //ML: removed the minus
   }

   if ( depth == 0 )  //ML: added a depth == 0 the stop the recursion
   {
      return evaluate();
   }

   TMovelist m = makemovelist(board);

   for (int i=0; i<movecount; i++)
   {
       make_move(movelist[i], board);

       hash_entry.seen_before = 1;        //ML: Is it necesarry to put this line
                                          //here or can it be also above to for?

                                          //ML: we have made a move... so the
                                          //hash_entry can't be the right value,
                                          //isn't it? Because the
                                          //hash_value, was one before
                                          //the move.

       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 */

                                   //ML: behint the next } ??
       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.