From 32f8c138b0287905a0a42bb2ef9246e2b9d43672 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 17 Sep 2008 21:28:26 +0200 Subject: [PATCH] Board: Introduce optional BOARD_SIZE for constant board size Should allow for better optimization if enabled. --- board.c | 4 ++++ board.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/board.c b/board.c index 757eba5..93f2b7e 100644 --- a/board.c +++ b/board.c @@ -89,8 +89,12 @@ board_done(struct board *board) void board_resize(struct board *board, int size) { +#ifdef BOARD_SIZE + assert(board_size(*board) == size + 2); +#else board_size(*board) = size + 2 /* S_OFFBOARD margin */; board_size2(*board) = board_size(*board) * board_size(*board); +#endif if (board->b) free(board->b); diff --git a/board.h b/board.h index bc737df..15e713d 100644 --- a/board.h +++ b/board.h @@ -14,6 +14,7 @@ /* The board implementation has bunch of optional features. * Turn them on below: */ #define WANT_BOARD_C // required by playout_moggy +//#define BOARD_SIZE 9 // constant board size, allows better optimization /* Allow board_play_random_move() to return pass even when @@ -105,8 +106,14 @@ struct board { hash_t hash; }; +#ifdef BOARD_SIZE +/* Avoid unused variable warnings */ +#define board_size(b_) ((&(b_) == &(b_)) ? BOARD_SIZE + 2 : 0) +#define board_size2(b_) (board_size(b_) * board_size(b_)) +#else #define board_size(b_) ((b_).size) #define board_size2(b_) ((b_).size2) +#endif #define board_at(b_, c) ((b_)->b[coord_raw(c)]) #define board_atxy(b_, x, y) ((b_)->b[(x) + board_size(b_) * (y)]) -- 2.11.4.GIT