From 06e16e2d672ff941a491e66184b1692e6978c7bf Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 13 Jan 2011 01:20:47 +0100 Subject: [PATCH] check_group_atari(): Use lumpiness guard only as preference, not for total pruning We would miss many crucial counter-atari simply because the only possible liberty to play was too lumpy. --- tactics/2lib.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/tactics/2lib.c b/tactics/2lib.c index fa0136b..de488bf 100644 --- a/tactics/2lib.c +++ b/tactics/2lib.c @@ -61,12 +61,20 @@ check_group_atari(struct board *b, group_t group, enum stone owner, enum stone to_play, struct move_queue *q, int tag, bool use_def_no_hopeless) { + bool have[2] = { false, false }; + bool preference[2] = { true, true }; for (int i = 0; i < 2; i++) { coord_t lib = board_group_info(b, group).lib[i]; assert(board_at(b, lib) == S_NONE); if (!board_is_valid_play(b, to_play, lib)) continue; + if (DEBUGL(6)) + fprintf(stderr, "checking liberty %s of %s %s, filled by %s\n", + coord2sstr(lib, b), + stone2str(owner), coord2sstr(group, b), + stone2str(to_play)); + /* Don't play at the spot if it is extremely short * of liberties... */ /* XXX: This looks harmful, could significantly @@ -80,14 +88,6 @@ check_group_atari(struct board *b, group_t group, enum stone owner, continue; #endif - /* If the move is too "lumpy", do not play it: - * - * ####### - * ..O.X.X <- always play the left one! - * OXXXXXX */ - if (neighbor_count_at(b, lib, stone_other(owner)) + neighbor_count_at(b, lib, S_OFFBOARD) >= 3) - continue; - /* If we are the defender not connecting out, do not * escape with moves that do not gain liberties anyway * - either the new extension has just single extra @@ -118,6 +118,35 @@ check_group_atari(struct board *b, group_t group, enum stone owner, is_bad_selfatari(b, to_play, lib)) continue; + /* By now, we must be decided we add the move to the + * queue! */ + have[i] = true; + + /* If the move is too "lumpy", prefer the alternative: + * + * ####### + * ..O.X.X <- always play the left one! + * OXXXXXX */ + if (neighbor_count_at(b, lib, stone_other(owner)) + neighbor_count_at(b, lib, S_OFFBOARD) >= 3) + preference[i] = false; + + if (DEBUGL(6)) + fprintf(stderr, "liberty %s ready with preference %d\n", coord2sstr(lib, b), preference[i]); + + /* If we prefer only one of the moves, pick that one. */ + if (i == 1 && have[0] && preference[0] != preference[1]) { + if (!preference[0]) { + if (q->move[q->moves - 1] == board_group_info(b, group).lib[0]) + q->moves--; + /* ...else{ may happen, since we call + * mq_nodup() and the move might have + * been there earlier. */ + } else { + assert(!preference[1]); + continue; + } + } + /* Tasty! Crispy! Good! */ mq_add(q, lib, tag); mq_nodup(q); -- 2.11.4.GIT