RCS file: /sources/gnugo/gnugo/engine/board.h,v
retrieving revision 1.34
diff -u -r1.34 board.h
|
|
|
|
| 135 | 135 | |
| 136 | 136 | /* Note that POS(-1, -1) == 0 |
| 137 | 137 | * DELTA() is defined so that POS(i+di, j+dj) = POS(i, j) + DELTA(di, dj). |
| | 138 | * For details look in the documentation. |
| 138 | 139 | */ |
| 139 | 140 | #define BOARDSIZE ((MAX_BOARD + 2) * (MAX_BOARD + 1) + 1) |
| 140 | 141 | #define BOARDMIN (MAX_BOARD + 2) |
| … |
… |
|
| 148 | 149 | #define NS (MAX_BOARD + 1) |
| 149 | 150 | #define WE 1 |
| 150 | 151 | #define SOUTH(pos) ((pos) + NS) |
| 151 | | #define WEST(pos) ((pos) - 1) |
| | 152 | #define WEST(pos) ((pos) - WE) |
| 152 | 153 | #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) |
| 158 | 159 | #define SS(pos) ((pos) + 2 * NS) |
| 159 | | #define WW(pos) ((pos) - 2) |
| | 160 | #define WW(pos) ((pos) - 2 * WE) |
| 160 | 161 | #define NN(pos) ((pos) - 2 * NS) |
| 161 | | #define EE(pos) ((pos) + 2) |
| | 162 | #define EE(pos) ((pos) + 2 * WE) |
| 162 | 163 | |
| 163 | 164 | #define DIRECT_NEIGHBORS(pos1, pos2) \ |
| 164 | 165 | ((pos1) == SOUTH(pos2) \ |
| … |
… |
|
| 175 | 176 | #define BOARD(i, j) board[POS(i, j)] |
| 176 | 177 | |
| 177 | 178 | |
| | 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 | |
| 178 | 209 | #define MIRROR_MOVE(pos) POS(board_size - 1 - I(pos), board_size - 1 - J(pos)) |
| 179 | 210 | |
| 180 | 211 | /* ================================================================ */ |
| … |
… |
|
| 183 | 214 | |
| 184 | 215 | /* The board and the other parameters deciding the current position. */ |
| 185 | 216 | extern int board_size; /* board size (usually 19) */ |
| | 217 | extern 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 */ |
| 186 | 221 | extern Intersection board[BOARDSIZE]; /* go board */ |
| 187 | 222 | extern int board_ko_pos; |
| 188 | 223 | extern int black_captured; /* num. of black stones captured */ |
| … |
… |
|
| 271 | 306 | void restore_board(struct board_state *state); |
| 272 | 307 | |
| 273 | 308 | /* Information about the permanent board. */ |
| 274 | | int get_last_move(void); |
| | 309 | inline int get_last_move(void); |
| 275 | 310 | int get_last_player(void); |
| 276 | 311 | int get_last_opponent_move(int color); |
| 277 | 312 | int stones_on_board(int color); |