From f859984b87a7630cca806af6388764b17b03cab3 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 10 Feb 2010 04:05:23 +0100 Subject: [PATCH] time_stop_conditions(): Get estimated moves left only once --- timeinfo.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/timeinfo.c b/timeinfo.c index d8d828c..90c5ca6 100644 --- a/timeinfo.c +++ b/timeinfo.c @@ -138,15 +138,12 @@ time_stop_conditions(struct time_info *ti, struct board *b, int fuseki_end, int /*** Transform @ti to TT_MOVE and set up recommended/max time and * net lag information. */ - int moves_left; + int moves_left = board_estimated_moves_left(b); + assert(moves_left > 0); - if (ti->period == TT_TOTAL) { - moves_left = board_estimated_moves_left(b); - assert(moves_left > 0); - if (ti->dim == TD_GAMES) { - ti->period = TT_MOVE; - ti->len.games /= moves_left; - } + if (ti->period == TT_TOTAL && ti->dim == TD_GAMES) { + ti->period = TT_MOVE; + ti->len.games /= moves_left; } if (ti->period == TT_NULL || ti->dim != TD_WALLTIME) goto setup_limits; @@ -242,7 +239,7 @@ setup_limits: if (b->moves < yose_start) { int moves_to_yose = (yose_start - b->moves) / 2; // ^- /2 because we only consider the moves we have to play ourselves - int left_at_yose_start = board_estimated_moves_left(b) - moves_to_yose; + int left_at_yose_start = moves_left - moves_to_yose; if (left_at_yose_start < MIN_MOVES_LEFT) left_at_yose_start = MIN_MOVES_LEFT; double longest_time = ti->len.t.max_time / left_at_yose_start; -- 2.11.4.GIT