From f3f09362b5ba3558b673a5cde330730296acaf49 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 2 Sep 2010 02:53:37 +0200 Subject: [PATCH] setup_nakade_or_snapback(): Warn against stupid no-falsify throwins --- tactics.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tactics.c b/tactics.c index d0edfbc..82fbb09 100644 --- a/tactics.c +++ b/tactics.c @@ -209,9 +209,24 @@ setup_nakade_or_snapback(struct board *b, enum stone color, coord_t to, struct s /* Now, we must distinguish between nakade and eye * falsification; we must not falsify an eye by more * than two stones. */ - if (s->groupcts[color] < 1 || - (s->groupcts[color] == 1 && group_is_onestone(b, s->groupids[color][0]))) - return false; + if (s->groupcts[color] < 1) + return false; // simple throw-in + if (s->groupcts[color] == 1 && group_is_onestone(b, s->groupids[color][0])) { + /* More complex throw-in - we are in one of + * three situations: + * a O O O O X b O O O X c O O O X + * O . X . O O X . . O . X . + * # # # # # # # # # # # # # + * b is desirable here (since maybe O has no + * backup two eyes); a may be desirable, but + * is tested next in check_throwin(). c is + * never desirable. */ + group_t g2 = s->groupids[color][0]; + assert(board_group_info(b, g2).libs <= 2); + if (board_group_info(b, g2).libs == 1) + return false; // b + goto next_group; // a or c + } /* We would create more than 2-stone group; in that * case, the liberty of our result must be lib2, -- 2.11.4.GIT