From d2cf8f60af172edc85af62770e7bf1b0cd7aaa38 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 12 Feb 2010 01:00:34 +0100 Subject: [PATCH] uct_search_stop_early(): Assume best is non-NULL --- uct/uct.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uct/uct.c b/uct/uct.c index cfb01d2..1d0a7e4 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -451,15 +451,15 @@ uct_search_stop_early(struct uct *u, struct tree *t, struct board *b, int base_playouts, int i) { /* Early break in won situation. */ - if (best && ((best->u.playouts >= 2000 && tree_node_get_value(t, 1, best->u.value) >= u->loss_threshold) - || (best->u.playouts >= 500 && tree_node_get_value(t, 1, best->u.value) >= 0.95))) + if ((best->u.playouts >= 2000 && tree_node_get_value(t, 1, best->u.value) >= u->loss_threshold) + || (best->u.playouts >= 500 && tree_node_get_value(t, 1, best->u.value) >= 0.95)) return true; /* Break early if we estimate the second-best move cannot * catch up in assigned time anymore. We use all our time * if we are in byoyomi with single stone remaining in our * period, however. */ - if (best && best2 && ti->dim == TD_WALLTIME + if (best2 && ti->dim == TD_WALLTIME && (ti->len.t.main_time > 0 || ti->len.t.byoyomi_stones > 1)) { double elapsed = time_now() - ti->len.t.timer_start; double remaining = stop->worst.time - elapsed; @@ -550,7 +550,7 @@ uct_search(struct uct *u, struct board *b, struct time_info *ti, enum stone colo best = u->policy->choose(u->policy, ctx->t->root, b, color, resign); best2 = u->policy->choose(u->policy, ctx->t->root, b, color, best->coord); - if (uct_search_stop_early(u, ctx->t, b, ti, &stop, best, best2, base_playouts, i)) + if (best && uct_search_stop_early(u, ctx->t, b, ti, &stop, best, best2, base_playouts, i)) break; /* We want to stop simulating, but are willing to keep trying -- 2.11.4.GIT