Skip to content

Time Pruning

Zixiao Han edited this page May 11, 2021 · 3 revisions

I came up with this idea after watching a game which FoxSEE had +2 advantage but could not (or did not bother to) find a breakthrough in the position. It kept making redudant moves without making any actual progress.

The idea of "Time Pruning" is really simple:

Reduce the score returned from q_search by number of plies from the root.

In pseudo code, it looks like this:

if depth == 0 {
   score = q_search();

   if !on_pv {
      return score;
   }

   time_discount = DISCOUNT_FACTOR * (current_full_move_count - root_full_move_count);

   if score > time_discount {
      score -= time_discount;
   } else if score < time_discount {
      score += time_discount;
   } else {
      score = 0;
   };

   return score;
}

This helps in mainly two aspects:

  1. It encourages FoxSEE to find breakthroughs in the position; otherwise the score for the same position would decay after time.
  2. It helps to cut off branches with redudant moves; this is also the reason why I consider it as a pruning technique.

At the moment, I use DISCOUNT_FACTOR = 1 to be safe. In the longer term, I will use tuning to see if a better value can be found.

Rev 1

Since v7.18.1, I have made a change to the Time Pruning:

if depth == 0 {
   score = q_search();

   if !on_pv {
      return score;
   }

   full_move_discount = current_full_move_count - root_full_move_count;
   half_move_discount = current_half_move_count - root_half_move_count
   time_discount = DISCOUNT_FACTOR * (full_move_discount + half_move_discount);

   if score > time_discount {
      score -= time_discount;
   } else if score < time_discount {
      score += time_discount;
   } else {
      score = 0;
   };

   return score;
}

The reason to add half-move into the time discount is to encourage exchanges/pawn moves when the position is "stuck".

Clone this wiki locally