From 60f18fc4f4c5f4904957b3b288dd6771994db2a5 Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Sat, 6 Aug 2011 17:27:50 +0200 Subject: [PATCH] UCT: set pass_all_alive if user set the option or when in cleanup phase uctp_generic_choose() was ignoring the cleanup phase. --- uct/internal.h | 3 ++- uct/search.c | 2 +- uct/slave.c | 3 ++- uct/uct.c | 9 ++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 2aefd17..bef1d06 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -30,7 +30,8 @@ struct uct { floating_t resign_threshold, sure_win_threshold; double best2_ratio, bestr_ratio; floating_t max_maintime_ratio; - bool pass_all_alive; + bool pass_all_alive_opt; /* User option */ + bool pass_all_alive; /* Current value */ bool territory_scoring; int expand_p; bool playout_amaf, playout_amaf_nakade; diff --git a/uct/search.c b/uct/search.c index 7bb69bd..7fc035e 100644 --- a/uct/search.c +++ b/uct/search.c @@ -484,7 +484,7 @@ uct_search_result(struct uct *u, struct board *b, enum stone color, /* Make sure enough playouts are simulated. */ while (u->ownermap.playouts < GJ_MINGAMES) uct_playout(u, b, color, u->t); - if (uct_pass_is_safe(u, b, color, u->pass_all_alive || pass_all_alive)) { + if (uct_pass_is_safe(u, b, color, pass_all_alive)) { if (UDEBUGL(0)) fprintf(stderr, "\n", board_official_score(b, NULL) / 2); diff --git a/uct/slave.c b/uct/slave.c index 3906121..6fce644 100644 --- a/uct/slave.c +++ b/uct/slave.c @@ -488,6 +488,7 @@ uct_genmoves(struct engine *e, struct board *b, struct time_info *ti, enum stone { struct uct *u = e->data; assert(u->slave); + u->pass_all_alive |= pass_all_alive; /* Prepare the state if the search is not already running. * We must do this first since we tweak the state below @@ -538,7 +539,7 @@ uct_genmoves(struct engine *e, struct board *b, struct time_info *ti, enum stone best_coord = fbook_check(b); if (best_coord == pass) { keep_looking = !uct_search_check_stop(u, b, color, u->t, ti, &s, played_games); - uct_search_result(u, b, color, pass_all_alive, played_games, s.base_playouts, &best_coord); + uct_search_result(u, b, color, u->pass_all_alive, played_games, s.base_playouts, &best_coord); /* Give heavy weight only to pass, resign and book move: */ if (best_coord > 0) best_coord = 0; diff --git a/uct/uct.c b/uct/uct.c index 3fe55cf..baee743 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -423,6 +423,7 @@ uct_genmove(struct engine *e, struct board *b, struct time_info *ti, enum stone { double start_time = time_now(); struct uct *u = e->data; + u->pass_all_alive |= pass_all_alive; uct_pondering_stop(u); uct_genmove_setup(u, b, color); @@ -432,7 +433,7 @@ uct_genmove(struct engine *e, struct board *b, struct time_info *ti, enum stone coord_t best_coord; struct tree_node *best; - best = uct_search_result(u, b, color, pass_all_alive, played_games, base_playouts, &best_coord); + best = uct_search_result(u, b, color, u->pass_all_alive, played_games, base_playouts, &best_coord); if (UDEBUGL(2)) { double time = time_now() - start_time + 0.000001; /* avoid divide by zero */ @@ -615,7 +616,7 @@ uct_state_init(char *arg, struct board *b) * dead groups were removed from the board; * this is like all genmoves are in fact * kgs-genmove_cleanup. */ - u->pass_all_alive = !optval || atoi(optval); + u->pass_all_alive_opt = !optval || atoi(optval); } else if (!strcasecmp(optname, "territory_scoring")) { /* Use territory scoring (default is area scoring). * An explicit kgs-rules command overrides this. */ @@ -624,7 +625,7 @@ uct_state_init(char *arg, struct board *b) /* Do not count eyes. Nice to teach go to kids. * http://strasbourg.jeudego.org/regle_strasbourgeoise.htm */ b->rules = RULES_STONES_ONLY; - u->pass_all_alive = true; + u->pass_all_alive_opt = true; } else if (!strcasecmp(optname, "banner") && optval) { /* Additional banner string. This must come as the * last engine parameter. */ @@ -964,6 +965,8 @@ uct_state_init(char *arg, struct board *b) } } + u->pass_all_alive = u->pass_all_alive_opt; + if (!u->policy) u->policy = policy_ucb1amaf_init(u, NULL); -- 2.11.4.GIT