From 10055958b65fe9c1be8a86b9b3d2957fc207eb79 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sat, 28 May 2011 21:37:48 +0200 Subject: [PATCH] selfatari_cousin(): Make info on by-group available --- playout/moggy.c | 4 ++-- tactics/2lib.c | 2 +- tactics/selfatari.c | 4 +++- tactics/selfatari.h | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/playout/moggy.c b/playout/moggy.c index 5bb13ae..797b855 100644 --- a/playout/moggy.c +++ b/playout/moggy.c @@ -791,7 +791,7 @@ playout_moggy_assess_one(struct playout_policy *p, struct prior_map *map, coord_ return; /* If we can play on the other liberty of the * endangered group, do! */ - coord = selfatari_cousin(b, map->to_play, coord); + coord = selfatari_cousin(b, map->to_play, coord, NULL); if (is_pass(coord)) return; if (PLDEBUGL(5)) @@ -854,7 +854,7 @@ playout_moggy_permit(struct playout_policy *p, struct board *b, struct move *m) stone2str(m->color), coord2sstr(m->coord, b)); if (pp->selfatari_other) { /* Ok, try the other liberty of the atari'd group. */ - coord_t c = selfatari_cousin(b, m->color, m->coord); + coord_t c = selfatari_cousin(b, m->color, m->coord, NULL); if (is_pass(c)) return false; if (PLDEBUGL(5)) fprintf(stderr, "___ Redirecting to other lib %s\n", diff --git a/tactics/2lib.c b/tactics/2lib.c index ab39cc6..d2e941e 100644 --- a/tactics/2lib.c +++ b/tactics/2lib.c @@ -143,7 +143,7 @@ can_atari_group(struct board *b, group_t group, enum stone owner, /* Okay! We are attacker; maybe we just need * to connect a false eye before atari - this * is very common in the corner. */ - coord = selfatari_cousin(b, to_play, lib); + coord = selfatari_cousin(b, to_play, lib, NULL); } if (is_pass(coord)) continue; diff --git a/tactics/selfatari.c b/tactics/selfatari.c index 816a918..c70efa6 100644 --- a/tactics/selfatari.c +++ b/tactics/selfatari.c @@ -511,7 +511,7 @@ is_bad_selfatari_slow(struct board *b, enum stone color, coord_t to) coord_t -selfatari_cousin(struct board *b, enum stone color, coord_t coord) +selfatari_cousin(struct board *b, enum stone color, coord_t coord, group_t *bygroup) { group_t groups[4]; int groups_n = 0; foreach_neighbor(b, coord, { @@ -529,5 +529,7 @@ selfatari_cousin(struct board *b, enum stone color, coord_t coord) coord_t lib2 = board_group_other_lib(b, group, coord); if (is_bad_selfatari(b, color, lib2)) return pass; + if (bygroup) + *bygroup = group; return lib2; } diff --git a/tactics/selfatari.h b/tactics/selfatari.h index 2e3c812..087cfd6 100644 --- a/tactics/selfatari.h +++ b/tactics/selfatari.h @@ -15,10 +15,11 @@ static bool is_bad_selfatari(struct board *b, enum stone color, coord_t to); /* Move (color, coord) is a selfatari; this means that it puts a group of * ours in atari; i.e., the group has two liberties now. Return the other - * liberty of such a troublesome group if that one is not a self-atari. + * liberty of such a troublesome group (optionally stored at *bygroup) + * if that one is not a self-atari. * (In case (color, coord) is a multi-selfatari, consider a randomly chosen * candidate.) */ -coord_t selfatari_cousin(struct board *b, enum stone color, coord_t coord); +coord_t selfatari_cousin(struct board *b, enum stone color, coord_t coord, group_t *bygroup); bool is_bad_selfatari_slow(struct board *b, enum stone color, coord_t to); -- 2.11.4.GIT