From aeaadb2896a516814168fd4452c70a158cf99b6d Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 14 Jan 2011 01:35:13 +0100 Subject: [PATCH] Moggy local_2lib_check(): Avoid duplicate 2-lib checks In case of 2-libs, these were occuring a lot and are rather expensive. --- playout/moggy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/playout/moggy.c b/playout/moggy.c index c2a7831..635902a 100644 --- a/playout/moggy.c +++ b/playout/moggy.c @@ -291,10 +291,11 @@ static void local_2lib_check(struct playout_policy *p, struct board *b, struct move *m, struct move_queue *q) { struct moggy_policy *pp = p->data; + group_t group = group_at(b, m->coord), group2 = 0; /* Does the opponent have just two liberties? */ - if (board_group_info(b, group_at(b, m->coord)).libs == 2) { - group_2lib_check(b, group_at(b, m->coord), stone_other(m->color), q, 1<atari_miaisafe, pp->atari_def_no_hopeless); + if (board_group_info(b, group).libs == 2) { + group_2lib_check(b, group, stone_other(m->color), q, 1<atari_miaisafe, pp->atari_def_no_hopeless); #if 0 /* We always prefer to take off an enemy chain liberty * before pulling out ourselves. */ @@ -308,9 +309,10 @@ local_2lib_check(struct playout_policy *p, struct board *b, struct move *m, stru /* Then he took a third liberty from neighboring chain? */ foreach_neighbor(b, m->coord, { group_t g = group_at(b, c); - if (!g || board_group_info(b, g).libs != 2) + if (!g || g == group || g == group2 || board_group_info(b, g).libs != 2) continue; group_2lib_check(b, g, stone_other(m->color), q, 1<atari_miaisafe, pp->atari_def_no_hopeless); + group2 = g; // prevent trivial repeated checks }); if (PLDEBUGL(5)) -- 2.11.4.GIT