From a58b7f88cef02dcaf674603d3c90c4ad2a9ffe6a Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Tue, 10 Aug 2010 04:38:09 +0200 Subject: [PATCH] Selfatari: Fix a false nakade detection --- t-unit/sar.t | 32 +++++++++++++++++++++++++++++++- tactics.c | 23 ++++++++++------------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/t-unit/sar.t b/t-unit/sar.t index 1771678..c16f612 100644 --- a/t-unit/sar.t +++ b/t-unit/sar.t @@ -119,6 +119,36 @@ sar w d2 1 sar b e3 0 sar w e3 1 +% Eyeshape-avoidance nakade 1 +boardsize 4 +XXXX +XO.X +XX.X +XXXX +sar w c3 0 +sar w c2 1 + +% Eyeshape-avoidance nakade 2 +boardsize 4 +XXXX +XO.O +XX.X +XXXX +sar w c3 0 +sar w c2 1 + +% False nakade +boardsize 5 +X.XX. +XOOXX +XOOX. +X.OXX +XOOXX +sar w b2 1 +sar b b2 1 +sar w b5 0 # We consider "splitting block-nakade" ok, since it should certainly destroy eyeshape anyway +sar b b5 0 + % Not-quite-snapback boardsize 5 XXXXO @@ -159,4 +189,4 @@ XXOXXXXXO .XOXXX..X XXXO..XXX XO..O...O -sar w j8 0 # 1: but we think we nakade b group, we don't examine all w group neighbors; KNOWN PROBLEM +sar w j8 0 # 1: but we think we nakade b group, we don''t examine all w group neighbors; KNOWN PROBLEM diff --git a/tactics.c b/tactics.c index 57c27b5..d0edfbc 100644 --- a/tactics.c +++ b/tactics.c @@ -151,7 +151,7 @@ setup_nakade_or_snapback(struct board *b, enum stone color, coord_t to, struct s * (ii) filling it to capture our group will not gain * safety */ - /* Let's look at the other liberty neighbors: */ + /* Let's look at neighbors of the other liberty: */ int lib2 = board_group_other_lib(b, g, to); foreach_neighbor(b, lib2, { /* This neighbor of course does not contribute @@ -174,24 +174,21 @@ setup_nakade_or_snapback(struct board *b, enum stone color, coord_t to, struct s int g2 = group_at(b, c); /* If the neighbor is of our color, it must - * be our group; if it is a different group, - * it must not be in atari. */ + * be also a 2-lib group. If it is more, + * we CERTAINLY want that liberty to be played + * first, what if it is an alive group? If it + * is in atari, we want to extend from it to + * prevent eye-making capture. However, if it + * is 2-lib, it is selfatari connecting two + * nakade'ing groups! */ /* X X X X We will not allow play on 'a', * X X a X because 'b' would capture two * X O b X different groups, forming two * X X X X eyes. */ if (board_at(b, c) == color) { - if (board_group_info(b, group_at(b, c)).libs > 1) + if (board_group_info(b, group_at(b, c)).libs == 2) continue; - /* Our group == one of the groups - * we (@to) are connected to. */ - int j; - for (j = 0; j < 4; j++) - if (s->groupids[color][j] == g2) - break; - if (j == 4) - goto next_group; - continue; + goto next_group; } /* The neighbor is enemy color. It's ok if -- 2.11.4.GIT