Ticket #145: board.h.patch

File board.h.patch, 3.3 kB (added by draqo, 2 years ago)
  • gnugo/engine/board.h

    RCS file: /sources/gnugo/gnugo/engine/board.h,v
    retrieving revision 1.34
    diff -u -r1.34 board.h
     
    135135 
    136136/* Note that POS(-1, -1) == 0 
    137137 * DELTA() is defined so that POS(i+di, j+dj) = POS(i, j) + DELTA(di, dj). 
     138 * For details look in the documentation. 
    138139 */ 
    139140#define BOARDSIZE     ((MAX_BOARD + 2) * (MAX_BOARD + 1) + 1) 
    140141#define BOARDMIN      (MAX_BOARD + 2) 
     
    148149#define NS            (MAX_BOARD + 1) 
    149150#define WE            1 
    150151#define SOUTH(pos)    ((pos) + NS) 
    151 #define WEST(pos)     ((pos) - 1) 
     152#define WEST(pos)     ((pos) - WE) 
    152153#define NORTH(pos)    ((pos) - NS) 
    153 #define EAST(pos)     ((pos) + 1) 
    154 #define SW(pos)       ((pos) + NS - 1) 
    155 #define NW(pos)       ((pos) - NS - 1) 
    156 #define NE(pos)       ((pos) - NS + 1) 
    157 #define SE(pos)       ((pos) + NS + 1) 
     154#define EAST(pos)     ((pos) + WE) 
     155#define SW(pos)       ((pos) + NS - WE) 
     156#define NW(pos)       ((pos) - NS - WE) 
     157#define NE(pos)       ((pos) - NS + WE) 
     158#define SE(pos)       ((pos) + NS + WE) 
    158159#define SS(pos)       ((pos) + 2 * NS) 
    159 #define WW(pos)       ((pos) - 2) 
     160#define WW(pos)       ((pos) - 2 * WE) 
    160161#define NN(pos)       ((pos) - 2 * NS) 
    161 #define EE(pos)       ((pos) + 2) 
     162#define EE(pos)       ((pos) + 2 * WE) 
    162163 
    163164#define DIRECT_NEIGHBORS(pos1, pos2)            \ 
    164165  ((pos1) == SOUTH(pos2)                        \ 
     
    175176#define BOARD(i, j)   board[POS(i, j)] 
    176177 
    177178 
     179/* Macro for scanning a board. As a parameter an user should specify 
     180   a code, which would be run for each position on board that isn't 
     181   GRAY, and a name of the variable, which holds position, to use in 
     182   the passed code. 
     183   All lines in _code like "int x,...,y;" has to be changed to 
     184   "int x; int ...; int y;". Otherwise there will be compilation 
     185   error. 
     186   No semicolon is needed on the end. */ 
     187#define scan_board(_pos_var, _code) \ 
     188  { \ 
     189    int __n_, __row_ = 0; \ 
     190        const int __n_fields_ = board_size * board_size; \ 
     191        _pos_var = BOARDMIN - 1; \ 
     192    for (__n_ = 0; __n_ < __n_fields_; ++__n_) \ 
     193    { \ 
     194          if (__row_ == board_size) \ 
     195          { \ 
     196            __row_ = 1; \ 
     197            _pos_var += board_nextrow; \ 
     198          } \ 
     199          else \ 
     200          { \ 
     201            ++__row_; \ 
     202                ++_pos_var; \ 
     203          } \ 
     204          { _code } \ 
     205    } \ 
     206  } 
     207 
     208 
    178209#define MIRROR_MOVE(pos) POS(board_size - 1 - I(pos), board_size - 1 - J(pos)) 
    179210 
    180211/* ================================================================ */ 
     
    183214 
    184215/* The board and the other parameters deciding the current position. */ 
    185216extern int          board_size;             /* board size (usually 19) */ 
     217extern int          board_nextrow;  /* distance (in board array indexes) from 
     218                                                                           end of one row to begining of next row; 
     219                                                                           used for faster scanning of the board 
     220                                                                           array */ 
    186221extern Intersection board[BOARDSIZE];       /* go board */ 
    187222extern int          board_ko_pos; 
    188223extern int          black_captured;   /* num. of black stones captured */ 
     
    271306void restore_board(struct board_state *state); 
    272307 
    273308/* Information about the permanent board. */ 
    274 int get_last_move(void); 
     309inline int get_last_move(void); 
    275310int get_last_player(void); 
    276311int get_last_opponent_move(int color); 
    277312int stones_on_board(int color);