From c9756d62ca9ee5820638f235e7640c9075493480 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Tue, 13 Apr 2010 14:02:24 +0200 Subject: [PATCH] uct_search_stop_early(): Stop immediately if fullmem I have seen Pachi make extremely horrible blunders after memory limit was hit - until we can prune the tree during search, it's better if we stop the search altogether - memory limit hit means that the move should be reasonably well read out anyway. --- uct/search.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/uct/search.c b/uct/search.c index 1c94474..19805a5 100644 --- a/uct/search.c +++ b/uct/search.c @@ -271,8 +271,18 @@ static bool uct_search_stop_early(struct uct *u, struct tree *t, struct board *b, struct time_info *ti, struct time_stop *stop, struct tree_node *best, struct tree_node *best2, - int played) + int played, bool fullmem) { + /* If the memory is full, stop immediately. Since the tree + * cannot grow anymore, some non-well-expanded nodes will + * quickly take over with extremely high ratio since the + * counters are not properly simulated (just as if we use + * non-UCT MonteCarlo). */ + /* (XXX: A proper solution would be to prune the tree + * on the spot.) */ + if (fullmem) + 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 @@ -401,7 +411,7 @@ uct_search_check_stop(struct uct *u, struct board *b, enum stone color, /* Possibly stop search early if it's no use to try on. */ int played = u->played_all + i - s->base_playouts; - if (best && uct_search_stop_early(u, ctx->t, b, ti, &s->stop, best, best2, played)) + if (best && uct_search_stop_early(u, ctx->t, b, ti, &s->stop, best, best2, played, s->fullmem)) return true; /* Check against time settings. */ -- 2.11.4.GIT