Ticket #106: optimist-clock.c.patch

File optimist-clock.c.patch, 1.3 KB (added by alain, 6 years ago)

trivial patch

  • ./engine/clock.c

    old new  
    3838#include "clock.h" 
    3939#include "gg_utils.h" 
    4040#include "board.h" 
     41#include <math.h> 
    4142 
    4243/* Level data */ 
    4344static int level             = DEFAULT_LEVEL; /* current level */ 
     
    333334  double time_for_last_move; 
    334335  double time_left; 
    335336  int stones_left; 
     337  int stones_left_save; 
    336338 
    337339  if (!analyze_time_data(color, &time_for_last_move, &time_left, &stones_left)) 
    338340    return; 
    339341 
     342  /* Let us be optimistic when we have numerous stones_left to play 
     343   * ie spend more time in the beginning of the game/byo-yomi, then progressively hurry up */ 
    340344 
     345  stones_left_save=stones_left; 
     346  if (stones_left_save >= 9) 
     347        stones_left=pow(0.899,stones_left);  
     348         /* change nothing for n<9, 15->11, 20->14, 30->21, 60->39, 120->73 */  
     349   
    341350  /* These rules are both crude and ad hoc. 
    342351   * 
    343352   * FIXME: Use rules with at least some theoretical basis. 
     
    366375  if (level + level_offset > max_level) 
    367376    level_offset = max_level - level; 
    368377 
     378  stones_left=stones_left_save; 
     379 
    369380  DEBUG(DEBUG_TIME, "New level %d (%d %C %f %f %d)\n", level + level_offset, 
    370381        movenum / 2, color, time_for_last_move, time_left, stones_left); 
    371382}