From 97261c5ff18676e6b1756cfc2488f382c955cdfa Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 2 Oct 2009 13:17:24 +0200 Subject: [PATCH] board_stone_radar(): Move to tactics.* --- board.c | 24 ------------------------ board.h | 3 --- tactics.c | 26 ++++++++++++++++++++++++++ tactics.h | 3 +++ uct/tree.c | 1 + 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/board.c b/board.c index 970cf6a..2baa46b 100644 --- a/board.c +++ b/board.c @@ -1002,27 +1002,3 @@ board_official_score(struct board *board) return board->komi + board->handicap + scores[S_WHITE] - scores[S_BLACK]; } - - -bool -board_stone_radar(struct board *b, coord_t coord, int distance) -{ - int bounds[4] = { - coord_x(coord, b) - distance, - coord_y(coord, b) - distance, - coord_x(coord, b) + distance, - coord_y(coord, b) + distance - }; - for (int i = 0; i < 4; i++) - if (bounds[i] < 1) - bounds[i] = 1; - else if (bounds[i] > board_size(b) - 2) - bounds[i] = board_size(b) - 2; - for (int x = bounds[0]; x <= bounds[2]; x++) - for (int y = bounds[1]; y <= bounds[3]; y++) - if (board_atxy(b, x, y) != S_NONE) { - //fprintf(stderr, "radar %d,%d,%d: %d,%d (%d)\n", coord_x(coord, b), coord_y(coord, b), distance, x, y, board_atxy(b, x, y)); - return true; - } - return false; -} diff --git a/board.h b/board.h index 433361b..44a6699 100644 --- a/board.h +++ b/board.h @@ -217,9 +217,6 @@ float board_fast_score(struct board *board); /* Tromp-Taylor scoring. */ float board_official_score(struct board *board); -/* Checks if there are any stones in n-vincinity of coord. */ -bool board_stone_radar(struct board *b, coord_t coord, int distance); - /** Iterators */ diff --git a/tactics.c b/tactics.c index a6d2176..12a340e 100644 --- a/tactics.c +++ b/tactics.c @@ -288,3 +288,29 @@ invalid_throwin:; * is a bad self-atari! */ return true; } + + +bool +board_stone_radar(struct board *b, coord_t coord, int distance) +{ + int bounds[4] = { + coord_x(coord, b) - distance, + coord_y(coord, b) - distance, + coord_x(coord, b) + distance, + coord_y(coord, b) + distance + }; + for (int i = 0; i < 4; i++) + if (bounds[i] < 1) + bounds[i] = 1; + else if (bounds[i] > board_size(b) - 2) + bounds[i] = board_size(b) - 2; + for (int x = bounds[0]; x <= bounds[2]; x++) + for (int y = bounds[1]; y <= bounds[3]; y++) + if (board_atxy(b, x, y) != S_NONE) { + /* fprintf(stderr, "radar %d,%d,%d: %d,%d (%d)\n", + coord_x(coord, b), coord_y(coord, b), + distance, x, y, board_atxy(b, x, y)); */ + return true; + } + return false; +} diff --git a/tactics.h b/tactics.h index ce0d414..3c70422 100644 --- a/tactics.h +++ b/tactics.h @@ -12,6 +12,9 @@ * or throw-ins. */ static bool is_bad_selfatari(struct board *b, enum stone color, coord_t to); +/* Checks if there are any stones in n-vincinity of coord. */ +bool board_stone_radar(struct board *b, coord_t coord, int distance); + bool is_bad_selfatari_slow(struct board *b, enum stone color, coord_t to); static inline bool diff --git a/uct/tree.c b/uct/tree.c index 9fea5af..4c56ba8 100644 --- a/uct/tree.c +++ b/uct/tree.c @@ -11,6 +11,7 @@ #include "engine.h" #include "move.h" #include "playout.h" +#include "tactics.h" #include "uct/internal.h" #include "uct/prior.h" #include "uct/tree.h" -- 2.11.4.GIT