From cd556bcca36976d878209f3383deae96502270d4 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 1 Oct 2009 19:47:18 +0200 Subject: [PATCH] coord_is_adjecent(): Introduce --- board.c | 3 +-- move.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/board.c b/board.c index aa8f6b2..c45f54a 100644 --- a/board.c +++ b/board.c @@ -1086,8 +1086,7 @@ is_bad_selfatari_slow(struct board *b, enum stone color, coord_t to) return false; /* ...or one liberty, but not lib2. */ if (groupcts[S_NONE] > 0 - && abs(lib2 - to) != 1 - && abs(lib2 - to) != board_size(b)) + && !coord_is_adjecent(lib2, to, b)) return false; /* ...ok, then we can still contribute a liberty diff --git a/move.h b/move.h index 955c33c..36cf8fc 100644 --- a/move.h +++ b/move.h @@ -23,6 +23,8 @@ static coord_t resign = -2; #define coord_xy(board, x, y) ((x) + (y) * board_size(board)) #define coord_xy_otf(x, y, board) coord_xy(board, x, y) // obsolete +#define coord_is_adjecent(c1, c2, b) (abs(c1 - c2) == 1 || abs(c1 - c2) == board_size(b)) + /* dyn allocated */ static coord_t *coord_init(int x, int y, int size); static coord_t *coord_copy(coord_t c); -- 2.11.4.GIT