Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question regarding: Aspiraton Window Search (a correction)

Author: Dann Corbit

Date: 16:48:47 05/31/02

Go up one level in this thread


On May 31, 2002 at 18:50:18, Omid David wrote:

>I forgot to change "negascout" to "AlphaBeta" in 7th line for better
>illustration. Here is the correction:
>
>int AspWin(int estimate, int delta, int depth)
>{
>int alpha = estimate - delta;
>int beta = estimate + delta;
>int best;
>
>best = AlphaBeta(alpha, beta, depth);
>
>/* re-search */
>if(best <= alpha)
>best = AlphaBeta(-10000, beta, depth);
>else if(best >= beta)
>best = AlphaBeta(alpha, 10000, depth);
>
>/* is there any better way to handle this very rare case? */
>if(best >= beta || best <= alpha)
>best = AlphaBeta(-10000, 10000, depth);
>
>return best;
>}

Faile:

move_s think(void) {

   /* think() is simply a function to do iterative deepening, as well as
      some time management. */

   double time_used = 0;
   double elapsed = 0, time_given = 0;
   time_t start;
   move_s comp_move={0}, last_move;
   int i_max, j = 0, i;
   int boardt[144];
   char coord_move[6];

   current_score = -100000;

   /* before we do anything, check to see if we can make a move from book! */
   if (book_ply < 20) {
      comp_move = choose_book_move();
      /* if choose_book_move() didn't return a junk move indicating that
         no book move was found, play the book move! :) */
      if (comp_move.from != 0) {
         printf("0 0 0 0 (Book Move)\n");
         return comp_move;
      }
   }

   nodes = 0;
   qnodes = 0;

   start = time(0);

   time_for_move = allocate_time();
   time_given = time_for_move;

   /* if we have <= 10 seconds left, and allocate_time() didn't see fit
      to add any time via increment, we better start moving fast! :) */
   if (time_left <= 10 && time_for_move == 1.0) i_max = lightning_depth;
   else i_max = Maxdepth;

   memcpy (boardt, board, sizeof(boardt));

   memset (history_h, 0, sizeof(history_h));

   memcpy (pv, pv_empty, sizeof(pv_empty));

   time_failure = FALSE;

   init_eval();

   for (i = 0; i < 100; i++) {
      killer1[i] = junk_move;
      killer2[i] = junk_move;
      killer_scores[i] = -100000;
   }

   /* go deeper, iteratively: */

   for (iterative_depth = 1; iterative_depth <= i_max; iterative_depth++) {
      /* if we've used more than 2/3 of time_given, don't go deeper: */
      elapsed = difftime(time(0), start);
      time_used += (elapsed - time_used);

      if (time_used > (2.0/3.0 * time_given)  &&
          iterative_depth > lightning_depth) break;
      if (time_used > time_given && iterative_depth > 1) break;
      time_for_move = time_given - time_used;

      searching_pv = TRUE;

      last_move = search_root (-100000, 100000, iterative_depth);

      /* If the search was stabalized in time, comp_move is set: */
      if (!time_failure || iterative_depth == 1) {
         comp_move = last_move;
         if (iterative_depth >= lightning_depth && post) {
            /* post search output: */
            elapsed = difftime(time(0), start);
            printf("%d ", iterative_depth);
            printf("%d ", current_score);
            printf("%0.0f ", elapsed * 100);
            printf("%li ", nodes);
            for (j = 1; j < pv_length[1]; j++) {
               comp_to_coord(pv[1][j], coord_move);
               printf("%s ", coord_move);
            }
            printf("\n");
         }
      }

      /* I must account for en_passant pieces which are left over if made
         on the last node, since make_move was not called, as well as putting
         back an en_passant piece that may have been present before search,
         but was removed by a call of make_move: */

      memcpy (board, boardt, sizeof(boardt));

      /* reset the killer scores, so that we can determine if we can get
         better killers, but leave the killer moves themselves intact to
         use them for move ordering */

      for (i = 0; i < 100; i++)
         killer_scores[i] = -100000;
   }

   qnodes_perc = (double)qnodes / (double)nodes * 100;

   elapsed = difftime(time(0), start);
   time_cushion += time_for_move - elapsed;

   /* let allocate_time use increment for games with a moves_to_tc, via
      the time cushion, but this way, we ensure it's added only after
      we've moved: */
   if (moves_to_tc > 0 && increment)
     time_cushion += increment;

   return comp_move;

}




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.