From 5069a9af0771951f8ab320faba20ea034efedf4d Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 4 Aug 2014 03:39:51 +0200 Subject: [PATCH] selfatari_cousin(): Suggest counter-captures When looking for alternatives of a self-atari move, aside of the other liberty also look if we can counter-capture an opponent's group. This improves handling of some false-eyeish corner situations, where we will more often capture the falsifying opponent stones rather than connecting the pseudo-false eye (which can be fatal to the status of the group). --- tactics/selfatari.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tactics/selfatari.c b/tactics/selfatari.c index 5ef3fd1..f75fd10 100644 --- a/tactics/selfatari.c +++ b/tactics/selfatari.c @@ -5,7 +5,9 @@ #define DEBUG #include "board.h" #include "debug.h" +#include "mq.h" #include "random.h" +#include "tactics/1lib.h" #include "tactics/selfatari.h" @@ -556,11 +558,19 @@ found:; int gnm = gn % groups_n; group_t group = groups[gnm]; - coord_t lib2 = board_group_other_lib(b, group, coord); - if (board_is_one_point_eye(b, lib2, board_at(b, group))) - continue; - if (is_bad_selfatari(b, color, lib2)) - continue; + coord_t lib2; + /* Can we get liberties by capturing a neighbor? */ + struct move_queue ccq; ccq.moves = 0; + if (can_countercapture(b, color, group, color, &ccq, 0)) { + lib2 = mq_pick(&ccq); + + } else { + lib2 = board_group_other_lib(b, group, coord); + if (board_is_one_point_eye(b, lib2, board_at(b, group))) + continue; + if (is_bad_selfatari(b, color, lib2)) + continue; + } if (bygroup) *bygroup = group; return lib2; -- 2.11.4.GIT