Wisdom is knowing how

   little we know -- Socrates

About Company

Started in 1980, retired in 2004 REBEL was baptized into ProDeo, latin for gratis according to Dutch tradition.

Other Information

 

    Rybka-ICGA fiasco

 

 

 

 

 

 

 

FRUIT 2.1                                                                                  Rybka 1 RE by Rick Fadden as referred in Watkins 

                                                                                                  document chapter 6.3.2 Time management
 

static void parse_go(char string[]) {

   const char * ptr;
   bool infinite, ponder;
   int depth, mate, movestogo;
   sint64 nodes;
   double binc, btime, movetime, winc, wtime;
   double time, inc;
   double time_max, alloc;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   // init

 

   infinite = false;
   ponder = false;

   depth = -1;
   mate = -1;
   movestogo = -1;

   nodes = -1;

   binc = -1.0;
   btime = -1.0;
   movetime = -1.0;
   winc = -1.0;
   wtime = -1.0;


   // time limit

 

   if (COLOUR_IS_WHITE(SearchInput->board->turn)) {
      time = wtime;
      inc = winc;
   } else {
      time = btime;
      inc = binc;
   }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  if (movestogo <= 0 || movestogo > 30) movestogo = 30;

   if (inc < 0.0)  inc = 0.0;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

   if (movetime >= 0.0) {

      SearchInput->time_is_limited = true;
      SearchInput->time_limit_1 = movetime * 5.0; 
      SearchInput->time_limit_2 = movetime;

 

   } else if (time >= 0.0) {

 

      time_max = time * 0.95 - 1.0;
      if (time_max < 0.0) time_max = 0.0;

 

      SearchInput->time_is_limited = true;

 

      alloc = (time_max + inc * double(movestogo-1)) / double(movestogo);

      alloc *= (option_get_bool("Ponder") ? PonderRatio : NormalRatio);
      if (alloc > time_max) alloc = time_max;
      SearchInput->time_limit_1 = alloc;

 

      alloc = (time_max + inc * double(movestogo-1)) * 0.5;
      if (alloc < SearchInput->time_limit_1) alloc = SearchInput->time_limit_1;
      if (alloc > time_max) alloc = time_max;
      SearchInput->time_limit_2 = alloc;
   }

 

   if (infinite || ponder) SearchInput->infinite = true;

 

   Searching = true;
   Infinite = infinite || ponder;
   Delay = false;

   search();
   search_update_current();

   ASSERT(Searching);
   ASSERT(!Delay);

   Searching = false;
   Delay = Infinite;

   if (!Delay) send_best_move();

void start_go (char string [])
{
  const char *ptr;

double gTimeDouble;
int    time_limit_1, time_limit_2;
int    depthLimit;
int    nodeTickHigh, nodeTickLow;
int    bestMove, moveScore, depthScore;

bool   bad_1, bad2, change, easy, clockFlag;

bool   StopSearch, IgnoreClockFlag, Searching, Infinite, Delay; 

  bool ponder, infinite;
  int  movestogo, movetime, btime, wtime, binc, winc;

  // Initialize global search variables
  // Initialize a global floating point time related variable
  gTimeDouble = 0.0;

  time_limit_1 = -1;
  time_limit_2 = -1;

  ignoreClockFlag = 0;

  depthLimit = 0x7FFFFFFF;   // where in Fruit ???


  stopSearch = 0;

  nodeTickLow = 1024;

  bestMove   = 0;
  moveScore  = 0;
  depthScore = 0;

  bad_1     = 0;
  bad_2     = 0;
  change    = 0;
  easy      = 0;
  clackFlag = 0;

  nodeTickHigh = 1;


  // Initialize local variables


  infinite  = 0;
  ponder    = 0;
  movestogo = 25;
  winc  = 0;
  wtime = 0;
  binc  = 0;
  btime = 0;
  movetime = 0;

 

 


  ptr = strtok (string," ");
  for (ptr = strtok (NULL," "); ptr != NULL; ptr = strtok (NULL," ")) {
    if (!strcmp (ptr,"winc" )) { ptr = strtok (NULL," "); winc  = atoi (ptr); }
    if (!strcmp (ptr,"wtime")) { ptr = strtok (NULL," "); wtime = atoi (ptr); }  // missing -5000 substraction


    if (!strcmp (ptr,"binc" )) { ptr = strtok (NULL," "); binc  = atoi (ptr); }

    if (!strcmp (ptr,"btime")) { ptr = strtok (NULL," "); btime = atoi (ptr); }  // missing -5000 substraction


    if (!strcmp (ptr,"depth")) {
      ptr   = strtok (NULL," ");

      // This is where Rybka adds 2 to the depth that is entered
      // Rybka uses "atoi()" twice, and so the following matches the binary.
      if ((atoi (ptr) + 2) < -1)
        depthLimit = -1;
      } else {
        depthLimit = atoi (ptr) + 2;
      }
    }
    if (!strcmp (ptr,"infinite"))  { infinite = 1; }

 

 

    if (!strcmp (ptr,"movestogo")) {
      ptr = strtok (NULL," ");
      movestogo = atoi (ptr);
      if (movestogo > 30) movestogo = 30;
      if (movestogo <  1) movestogo =  1;
    }
    else if (!strcmp (ptr,"movetime"))  { ptr = strtok (NULL," "); movetime = atoi (ptr); }
    else if (!strcmp (ptr,"ponder"  ))  { ponder = 1; }
  }

  // Temporary variables just used in the following calc of time_limt_1, time_limit_2
  int time, inc, time_max, alloc;

  if ((Board->turn) == 0) { time = wtime; inc = winc; }
  else                    { time = btime; inc = binc; }


  // Rybka compares movetime with a double precision value: 0.0

 


  if (movetime >= 0.0) {     // error, should be > not >=
 
   time_limit_1 =    5 * movetime;
    time_limit_2 = 1000 * movetime; 
 

 

 } else if (time > 0) { 

 

    time_max = time - 5000; 

 

 

 

 

    alloc = (time_max + inc * (movestogo - 1)) / movestogo;
    if (alloc >= time_max) alloc = time_max;
    time_limit_1 = alloc; 

 

 

 

    alloc = (time_max + inc * (movestogo - 1)) / 2;
    if (alloc < time_limit_1) alloc = time_limit_1;  // should be <=
    if (alloc > time_max) alloc = time_max;        // should be >=
    time_limit_2 = alloc;
  } 

 

 

  if (infinite || ponder) ignoreClockFlag = 1;

  Searching = 1;

  Infinite = 0;
  if (infinite || ponder) Infinite = 1;
  Delay = 0;
  start_search ();
  Searching = 0;
  Delay = Infinite;
  if (!Infinite) Send_Best_Move ();
}

Copyright ® 2011 Ed Schröder