From 5bdc095e1453ddabc60a2f04f19a94a774cb50ae Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 15 Jul 2011 13:54:07 +0200 Subject: [PATCH] board_coord_in_symmetry(): Introduce --- board.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/board.h b/board.h index e1546e7..f3c70a4 100644 --- a/board.h +++ b/board.h @@ -331,6 +331,9 @@ static int group_stone_count(struct board *b, group_t group, int max); /* Adjust symmetry information as if given coordinate has been played. */ void board_symmetry_update(struct board *b, struct board_symmetry *symmetry, coord_t c); +/* Check if coordinates are within symmetry base. (If false, they can + * be derived from the base.) */ +static bool board_coord_in_symmetry(struct board *b, coord_t c); /* Returns true if given coordinate has all neighbors of given color or the edge. */ static bool board_is_eyelike(struct board *board, coord_t coord, enum stone eye_color); @@ -533,4 +536,22 @@ group_stone_count(struct board *b, group_t group, int max) return n; } +static inline bool +board_coord_in_symmetry(struct board *b, coord_t c) +{ + if (coord_y(c, b) < b->symmetry.y1 || coord_y(c, b) > b->symmetry.y2) + return false; + if (coord_x(c, b) < b->symmetry.x1 || coord_x(c, b) > b->symmetry.x2) + return false; + if (b->symmetry.d) { + int x = coord_x(c, b); + if (b->symmetry.type == SYM_DIAG_DOWN) + x = board_size(b) - 1 - x; + if (x > coord_y(c, b)) + return false; + } + return true; + +} + #endif -- 2.11.4.GIT