Rev 108 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 154 | pmbaty | 1 | #pragma once |
| 33 | pmbaty | 2 | /* *INDENT-OFF* */ |
| 3 | /*>>> epddefs.h: Extended Position Description definitions */ |
||
| 4 | /* Revised: 1996.06.23 */ |
||
| 5 | /* |
||
| 6 | Copyright (C) 1996 by Steven J. Edwards (sje@mv.mv.com) |
||
| 7 | All rights reserved. This code may be freely redistibuted and used by |
||
| 8 | both research and commerical applications. No warranty exists. |
||
| 9 | */ |
||
| 10 | /* |
||
| 11 | Everything in this source file is independent of the host program. |
||
| 12 | Requests for changes and additions should be communicated to the author |
||
| 13 | via the e-mail address given above. |
||
| 14 | */ |
||
| 15 | /* |
||
| 16 | This file was originally prepared on an Apple Macintosh using the |
||
| 17 | Metrowerks CodeWarrior 6 ANSI C compiler. Tabs are set at every |
||
| 18 | four columns. Further testing and development was performed on a |
||
| 19 | generic PC running Linux 1.3.20 and using the gcc 2.7.0 compiler. |
||
| 20 | */ |
||
| 21 | /* inclusion telltale */ |
||
| 22 | # if (!defined(_epddefs)) |
||
| 23 | # define _epddefs 1 |
||
| 24 | /* subprogram storage class for non-statics (usually empty definition) */ |
||
| 25 | # define nonstatic |
||
| 26 | /* a bit */ |
||
| 27 | # define bit 0x01 |
||
| 28 | /* bit positions */ |
||
| 29 | # define bit_00 (bit << 0) |
||
| 30 | # define bit_01 (bit << 1) |
||
| 31 | # define bit_02 (bit << 2) |
||
| 32 | # define bit_03 (bit << 3) |
||
| 33 | # define bit_04 (bit << 4) |
||
| 34 | # define bit_05 (bit << 5) |
||
| 35 | # define bit_06 (bit << 6) |
||
| 36 | # define bit_07 (bit << 7) |
||
| 37 | # define bit_08 (bit << 8) |
||
| 38 | # define bit_09 (bit << 9) |
||
| 39 | # define bit_10 (bit << 10) |
||
| 40 | # define bit_11 (bit << 11) |
||
| 41 | # define bit_12 (bit << 12) |
||
| 42 | # define bit_13 (bit << 13) |
||
| 43 | # define bit_14 (bit << 14) |
||
| 44 | # define bit_15 (bit << 15) |
||
| 45 | /* bit width constants */ |
||
| 46 | # define nybbW 4 |
||
| 47 | # define byteW 8 |
||
| 48 | /* simple masks */ |
||
| 49 | # define nybbM 0x000f |
||
| 50 | /* useful types */ |
||
| 51 | typedef void *voidptrT; |
||
| 52 | typedef unsigned char byteT, *byteptrT; |
||
| 53 | typedef char *charptrT; |
||
| 54 | typedef short int siT, *siptrT; |
||
| 55 | typedef long int liT, *liptrT; |
||
| 56 | typedef float srT, *srptrT; |
||
| 57 | typedef double lrT, *lrptrT; |
||
| 58 | typedef FILE *fptrT; |
||
| 59 | |||
| 60 | /* text I/O buffer length */ |
||
| 61 | # define tL 256 |
||
| 62 | /* EPD I/O buffer length */ |
||
| 63 | # define epdL 4096 |
||
| 64 | /* the standard algebraic notation character vector type */ |
||
| 65 | # define sanL 16 |
||
| 108 | pmbaty | 66 | /* must be at least 8; extra room for alternatives */ |
| 33 | pmbaty | 67 | typedef char sanT[sanL]; |
| 68 | typedef sanT *sanptrT; |
||
| 69 | |||
| 70 | /* SAN style attributes, priority ordered (used for encoding) */ |
||
| 71 | typedef siT ssaT; |
||
| 72 | |||
| 73 | # define ssaL 12 |
||
| 74 | # define ssa_nil (-1) |
||
| 75 | # define ssa_capt 0 /* 5 way: capture indicator */ |
||
| 76 | # define ssa_case 1 /* 2 way: letter case */ |
||
| 77 | # define ssa_chec 2 /* 3 way: checking */ |
||
| 78 | # define ssa_cast 3 /* 5 way: castling */ |
||
| 79 | # define ssa_prom 4 /* 4 way: promoting */ |
||
| 80 | # define ssa_ptar 5 /* 2 way: pawn target rank skip */ |
||
| 81 | # define ssa_chmt 6 /* 4 way: checkmating */ |
||
| 82 | # define ssa_epct 7 /* 2 way: en passant capture */ |
||
| 83 | # define ssa_draw 8 /* 2 way: drawing */ |
||
| 84 | # define ssa_move 9 /* 2 way: movement indicator */ |
||
| 85 | # define ssa_edcf 10 /* 2 way: extra disambiguating character (file) */ |
||
| 86 | # define ssa_edcr 11 /* 2 way: extra disambiguating character (rank) */ |
||
| 87 | /* SAN style vector */ |
||
| 88 | typedef siT ssavT[ssaL]; |
||
| 89 | |||
| 90 | /* colors (ordering is critical) */ |
||
| 91 | typedef siT cT, *cptrT; |
||
| 92 | |||
| 93 | # define cQ 2 |
||
| 94 | # define cL (bit << cQ) |
||
| 95 | # define rcQ 1 |
||
| 96 | # define rcL (bit << rcQ) |
||
| 97 | # define c_nil (-1) |
||
| 98 | # define c_w 0 |
||
| 108 | pmbaty | 99 | /* white */ |
| 33 | pmbaty | 100 | # define c_b 1 |
| 108 | pmbaty | 101 | /* black */ |
| 33 | pmbaty | 102 | # define c_v 2 |
| 108 | pmbaty | 103 | /* vacant */ |
| 33 | pmbaty | 104 | # define c_x 3 |
| 108 | pmbaty | 105 | /* extra */ |
| 33 | pmbaty | 106 | /* pieces (ordering is critical) */ |
| 107 | typedef siT pT, *pptrT; |
||
| 108 | |||
| 109 | # define pL 8 |
||
| 110 | # define rpL 6 |
||
| 111 | # define p_nil (-1) |
||
| 112 | # define p_p 0 |
||
| 108 | pmbaty | 113 | /* pawn */ |
| 33 | pmbaty | 114 | # define p_n 1 |
| 108 | pmbaty | 115 | /* knight */ |
| 33 | pmbaty | 116 | # define p_b 2 |
| 108 | pmbaty | 117 | /* bishop */ |
| 33 | pmbaty | 118 | # define p_r 3 |
| 108 | pmbaty | 119 | /* rook */ |
| 33 | pmbaty | 120 | # define p_q 4 |
| 108 | pmbaty | 121 | /* queen */ |
| 33 | pmbaty | 122 | # define p_k 5 |
| 108 | pmbaty | 123 | /* king */ |
| 33 | pmbaty | 124 | # define p_v 6 |
| 108 | pmbaty | 125 | /* vacant */ |
| 33 | pmbaty | 126 | # define p_x 7 |
| 108 | pmbaty | 127 | /* extra */ |
| 33 | pmbaty | 128 | /* color piece combinations (ordering is critical) */ |
| 129 | typedef siT cpT; |
||
| 130 | |||
| 131 | # define cpL 16 |
||
| 132 | # define rcpL 12 |
||
| 133 | # define cp_nil (-1) |
||
| 108 | pmbaty | 134 | # define cp_wp 0 /* white pawn */ |
| 135 | # define cp_wn 1 /* white knight */ |
||
| 136 | # define cp_wb 2 /* white bishop */ |
||
| 137 | # define cp_wr 3 /* white rook */ |
||
| 138 | # define cp_wq 4 /* white queen */ |
||
| 139 | # define cp_wk 5 /* white king */ |
||
| 140 | # define cp_bp 6 /* black pawn */ |
||
| 141 | # define cp_bn 7 /* black knight */ |
||
| 142 | # define cp_bb 8 /* black bishop */ |
||
| 143 | # define cp_br 9 /* black rook */ |
||
| 144 | # define cp_bq 10 /* black queen */ |
||
| 145 | # define cp_bk 11 /* black king */ |
||
| 146 | # define cp_v0 12 /* vacant */ |
||
| 147 | # define cp_x0 13 /* extra 0 */ |
||
| 148 | # define cp_x1 14 /* extra 1 */ |
||
| 149 | # define cp_x2 15 /* extra 2 */ |
||
| 33 | pmbaty | 150 | /* ranks */ |
| 151 | typedef siT rankT; |
||
| 152 | |||
| 153 | # define rankM (0x0007) |
||
| 154 | # define rankQ 3 |
||
| 155 | # define rankL (bit << rankQ) |
||
| 156 | # define rank_nil (-1) |
||
| 157 | # define rank_1 0 |
||
| 158 | # define rank_2 1 |
||
| 159 | # define rank_3 2 |
||
| 160 | # define rank_4 3 |
||
| 161 | # define rank_5 4 |
||
| 162 | # define rank_6 5 |
||
| 163 | # define rank_7 6 |
||
| 164 | # define rank_8 7 |
||
| 165 | /* files */ |
||
| 166 | typedef siT fileT; |
||
| 167 | |||
| 168 | # define fileM (0x0007) |
||
| 169 | # define fileQ 3 |
||
| 170 | # define fileL (bit << fileQ) |
||
| 171 | # define file_nil (-1) |
||
| 108 | pmbaty | 172 | # define file_a 0 /* QR */ |
| 173 | # define file_b 1 /* QN */ |
||
| 174 | # define file_c 2 /* QB */ |
||
| 175 | # define file_d 3 /* Q */ |
||
| 176 | # define file_e 4 /* K */ |
||
| 177 | # define file_f 5 /* KB */ |
||
| 178 | # define file_g 6 /* KN */ |
||
| 179 | # define file_h 7 /* KR */ |
||
| 33 | pmbaty | 180 | /* location mappings */ |
| 181 | # define map_sq(r, f) (((r) << fileQ | (f))) |
||
| 182 | # define map_file(sq) ((sq) & 0x07) |
||
| 183 | # define map_rank(sq) ((sq) >> fileQ) |
||
| 184 | /* squares */ |
||
| 185 | typedef siT sqT, *sqptrT; |
||
| 186 | |||
| 187 | # define sqM (0x003f) |
||
| 188 | # define sqQ (rankQ + fileQ) |
||
| 189 | # define sqL (bit << sqQ) |
||
| 190 | # define sq_nil (-1) |
||
| 191 | # define sq_a1 map_sq(rank_1, file_a) |
||
| 192 | # define sq_b1 map_sq(rank_1, file_b) |
||
| 193 | # define sq_c1 map_sq(rank_1, file_c) |
||
| 194 | # define sq_d1 map_sq(rank_1, file_d) |
||
| 195 | # define sq_e1 map_sq(rank_1, file_e) |
||
| 196 | # define sq_f1 map_sq(rank_1, file_f) |
||
| 197 | # define sq_g1 map_sq(rank_1, file_g) |
||
| 198 | # define sq_h1 map_sq(rank_1, file_h) |
||
| 199 | # define sq_a2 map_sq(rank_2, file_a) |
||
| 200 | # define sq_b2 map_sq(rank_2, file_b) |
||
| 201 | # define sq_c2 map_sq(rank_2, file_c) |
||
| 202 | # define sq_d2 map_sq(rank_2, file_d) |
||
| 203 | # define sq_e2 map_sq(rank_2, file_e) |
||
| 204 | # define sq_f2 map_sq(rank_2, file_f) |
||
| 205 | # define sq_g2 map_sq(rank_2, file_g) |
||
| 206 | # define sq_h2 map_sq(rank_2, file_h) |
||
| 207 | # define sq_a3 map_sq(rank_3, file_a) |
||
| 208 | # define sq_b3 map_sq(rank_3, file_b) |
||
| 209 | # define sq_c3 map_sq(rank_3, file_c) |
||
| 210 | # define sq_d3 map_sq(rank_3, file_d) |
||
| 211 | # define sq_e3 map_sq(rank_3, file_e) |
||
| 212 | # define sq_f3 map_sq(rank_3, file_f) |
||
| 213 | # define sq_g3 map_sq(rank_3, file_g) |
||
| 214 | # define sq_h3 map_sq(rank_3, file_h) |
||
| 215 | # define sq_a4 map_sq(rank_4, file_a) |
||
| 216 | # define sq_b4 map_sq(rank_4, file_b) |
||
| 217 | # define sq_c4 map_sq(rank_4, file_c) |
||
| 218 | # define sq_d4 map_sq(rank_4, file_d) |
||
| 219 | # define sq_e4 map_sq(rank_4, file_e) |
||
| 220 | # define sq_f4 map_sq(rank_4, file_f) |
||
| 221 | # define sq_g4 map_sq(rank_4, file_g) |
||
| 222 | # define sq_h4 map_sq(rank_4, file_h) |
||
| 223 | # define sq_a5 map_sq(rank_5, file_a) |
||
| 224 | # define sq_b5 map_sq(rank_5, file_b) |
||
| 225 | # define sq_c5 map_sq(rank_5, file_c) |
||
| 226 | # define sq_d5 map_sq(rank_5, file_d) |
||
| 227 | # define sq_e5 map_sq(rank_5, file_e) |
||
| 228 | # define sq_f5 map_sq(rank_5, file_f) |
||
| 229 | # define sq_g5 map_sq(rank_5, file_g) |
||
| 230 | # define sq_h5 map_sq(rank_5, file_h) |
||
| 231 | # define sq_a6 map_sq(rank_6, file_a) |
||
| 232 | # define sq_b6 map_sq(rank_6, file_b) |
||
| 233 | # define sq_c6 map_sq(rank_6, file_c) |
||
| 234 | # define sq_d6 map_sq(rank_6, file_d) |
||
| 235 | # define sq_e6 map_sq(rank_6, file_e) |
||
| 236 | # define sq_f6 map_sq(rank_6, file_f) |
||
| 237 | # define sq_g6 map_sq(rank_6, file_g) |
||
| 238 | # define sq_h6 map_sq(rank_6, file_h) |
||
| 239 | # define sq_a7 map_sq(rank_7, file_a) |
||
| 240 | # define sq_b7 map_sq(rank_7, file_b) |
||
| 241 | # define sq_c7 map_sq(rank_7, file_c) |
||
| 242 | # define sq_d7 map_sq(rank_7, file_d) |
||
| 243 | # define sq_e7 map_sq(rank_7, file_e) |
||
| 244 | # define sq_f7 map_sq(rank_7, file_f) |
||
| 245 | # define sq_g7 map_sq(rank_7, file_g) |
||
| 246 | # define sq_h7 map_sq(rank_7, file_h) |
||
| 247 | # define sq_a8 map_sq(rank_8, file_a) |
||
| 248 | # define sq_b8 map_sq(rank_8, file_b) |
||
| 249 | # define sq_c8 map_sq(rank_8, file_c) |
||
| 250 | # define sq_d8 map_sq(rank_8, file_d) |
||
| 251 | # define sq_e8 map_sq(rank_8, file_e) |
||
| 252 | # define sq_f8 map_sq(rank_8, file_f) |
||
| 253 | # define sq_g8 map_sq(rank_8, file_g) |
||
| 254 | # define sq_h8 map_sq(rank_8, file_h) |
||
| 255 | /* regular board */ |
||
| 256 | typedef union rbU { |
||
| 108 | pmbaty | 257 | cpT rbm[rankL][fileL]; /* rank/file indexing */ |
| 258 | cpT rbv[sqL]; /* square indexing */ |
||
| 33 | pmbaty | 259 | } rbT, *rbptrT; |
| 260 | |||
| 261 | /* nybble board vector */ |
||
| 262 | # define nbL (sqL / (byteW / nybbW)) |
||
| 263 | typedef byteT nbvT[nbL]; |
||
| 264 | |||
| 265 | /* flanks */ |
||
| 266 | typedef siT flankT; |
||
| 267 | |||
| 268 | # define flankL 2 |
||
| 269 | # define flank_nil (-1) |
||
| 108 | pmbaty | 270 | # define flank_k 0 /* kingside */ |
| 271 | # define flank_q 1 /* queenside */ |
||
| 33 | pmbaty | 272 | /* direction indices */ |
| 273 | typedef siT dxT; |
||
| 274 | |||
| 275 | # define dxQ 4 |
||
| 276 | # define dxL (bit << dxQ) |
||
| 277 | # define dx_nil (-1) |
||
| 278 | # define dx_0 0 |
||
| 279 | # define dx_1 1 |
||
| 280 | # define dx_2 2 |
||
| 281 | # define dx_3 3 |
||
| 282 | # define dx_4 4 |
||
| 283 | # define dx_5 5 |
||
| 284 | # define dx_6 6 |
||
| 285 | # define dx_7 7 |
||
| 286 | # define dx_8 8 |
||
| 287 | # define dx_9 9 |
||
| 288 | # define dx_a 10 |
||
| 289 | # define dx_b 11 |
||
| 290 | # define dx_c 12 |
||
| 291 | # define dx_d 13 |
||
| 292 | # define dx_e 14 |
||
| 293 | # define dx_f 15 |
||
| 294 | /* direction vector displacements */ |
||
| 295 | typedef siT dvT; |
||
| 296 | |||
| 297 | # define dv_0 (( 0 * fileL) + 1) |
||
| 298 | # define dv_1 (( 1 * fileL) + 0) |
||
| 299 | # define dv_2 (( 0 * fileL) - 1) |
||
| 300 | # define dv_3 ((-1 * fileL) - 0) |
||
| 301 | # define dv_4 (( 1 * fileL) + 1) |
||
| 302 | # define dv_5 (( 1 * fileL) - 1) |
||
| 303 | # define dv_6 ((-1 * fileL) - 1) |
||
| 304 | # define dv_7 ((-1 * fileL) + 1) |
||
| 305 | # define dv_8 (( 1 * fileL) + 2) |
||
| 306 | # define dv_9 (( 2 * fileL) + 1) |
||
| 307 | # define dv_a (( 2 * fileL) - 1) |
||
| 308 | # define dv_b (( 1 * fileL) - 2) |
||
| 309 | # define dv_c ((-1 * fileL) - 2) |
||
| 310 | # define dv_d ((-2 * fileL) - 1) |
||
| 311 | # define dv_e ((-2 * fileL) + 1) |
||
| 312 | # define dv_f ((-1 * fileL) + 2) |
||
| 313 | /* extended direction vector offsets */ |
||
| 314 | typedef siT xdvT; |
||
| 315 | |||
| 316 | # define xdv_0 (( 0 * xfileL) + 1) |
||
| 317 | # define xdv_1 (( 1 * xfileL) + 0) |
||
| 318 | # define xdv_2 (( 0 * xfileL) - 1) |
||
| 319 | # define xdv_3 ((-1 * xfileL) - 0) |
||
| 320 | # define xdv_4 (( 1 * xfileL) + 1) |
||
| 321 | # define xdv_5 (( 1 * xfileL) - 1) |
||
| 322 | # define xdv_6 ((-1 * xfileL) - 1) |
||
| 323 | # define xdv_7 ((-1 * xfileL) + 1) |
||
| 324 | # define xdv_8 (( 1 * xfileL) + 2) |
||
| 325 | # define xdv_9 (( 2 * xfileL) + 1) |
||
| 326 | # define xdv_a (( 2 * xfileL) - 1) |
||
| 327 | # define xdv_b (( 1 * xfileL) - 2) |
||
| 328 | # define xdv_c ((-1 * xfileL) - 2) |
||
| 329 | # define xdv_d ((-2 * xfileL) - 1) |
||
| 330 | # define xdv_e ((-2 * xfileL) + 1) |
||
| 331 | # define xdv_f ((-1 * xfileL) + 2) |
||
| 332 | /* extended rank, file, and square types */ |
||
| 333 | typedef siT xrankT; |
||
| 334 | |||
| 335 | # define xrankQ (rankQ + 1) |
||
| 336 | # define xrankL (bit << xrankQ) |
||
| 337 | typedef siT xfileT; |
||
| 338 | |||
| 339 | # define xfileQ (fileQ + 1) |
||
| 340 | # define xfileM 0x0f |
||
| 341 | # define xfileL (bit << xfileQ) |
||
| 342 | typedef siT xsqT, *xsqptrT; |
||
| 343 | |||
| 344 | # define xsqQ (xrankQ + xfileQ) |
||
| 345 | # define xsqL (bit << xsqQ) |
||
| 346 | /* the extended board type */ |
||
| 347 | typedef union xbU { |
||
| 348 | cpT xbm[xrankL][xfileL]; |
||
| 349 | cpT xbv[xsqL]; |
||
| 350 | } xbT, *xbptrT; |
||
| 351 | |||
| 352 | /* extended board mapping macros */ |
||
| 353 | # define map_xrank_xsq(xsq) ((xsq) >> xfileQ) |
||
| 354 | # define map_xfile_xsq(xsq) ((xsq) & xfileM) |
||
| 355 | # define map_xsq_xrank_xfile(xrank, xfile) (((xrank) << xfileQ) | (xfile)) |
||
| 356 | /* extended conversion macros */ |
||
| 357 | # define xbdrL 4 |
||
| 358 | # define map_xfile_file(file) ((file) + xbdrL) |
||
| 359 | # define map_xrank_rank(rank) ((rank) + xbdrL) |
||
| 360 | # define map_file_xfile(xfile) ((xfile) - xbdrL) |
||
| 361 | # define map_rank_xrank(xrank) ((xrank) - xbdrL) |
||
| 362 | # define map_sq_xsq(xsq) \ |
||
| 363 | (((((xsq) >> xfileQ) - xbdrL) << fileQ) | (((xsq) & xfileM) - xbdrL)) |
||
| 364 | # define map_xsq_sq(sq) \ |
||
| 365 | ((((((sq) >> fileQ) & fileM) + xbdrL) << xfileQ) | \ |
||
| 366 | (((sq) & fileM) + xbdrL)) |
||
| 367 | /* castling availability indicators */ |
||
| 368 | typedef siT caiT; |
||
| 369 | |||
| 370 | # define caiL (rcL * flankL) |
||
| 371 | # define cai_nil (-1) |
||
| 372 | # define cai_wk ((c_w * flankL) + flank_k) |
||
| 373 | # define cai_wq ((c_w * flankL) + flank_q) |
||
| 374 | # define cai_bk ((c_b * flankL) + flank_k) |
||
| 375 | # define cai_bq ((c_b * flankL) + flank_q) |
||
| 376 | /* castling index mapper */ |
||
| 377 | # define castim(cai) (bit << (cai)) |
||
| 378 | /* castling flags */ |
||
| 379 | typedef siT castT; |
||
| 380 | typedef castT *castptrT; |
||
| 381 | |||
| 382 | # define cf_wk castim(cai_wk) |
||
| 383 | # define cf_wq castim(cai_wq) |
||
| 384 | # define cf_bk castim(cai_bk) |
||
| 385 | # define cf_bq castim(cai_bq) |
||
| 386 | /* centipawn evaluation */ |
||
| 387 | typedef siT cpevT, *cpevptrT; |
||
| 388 | |||
| 389 | /* some interesting centipawn evaluations */ |
||
| 390 | # define cpev_best ((cpevT) ((((liT) bit) << 15) - 1)) |
||
| 391 | # define cpev_bust (-cpev_best) |
||
| 392 | # define cpev_draw 0 |
||
| 393 | # define cpev_mate cpev_best |
||
| 394 | # define cpev_wrck (cpev_bust - 1) |
||
| 395 | /* mate and loss synthesis macros (fullmove distance argument) */ |
||
| 396 | # define synth_mate(n) (cpev_mate - ((n) * 2) + 1) |
||
| 397 | # define synth_loss(n) (cpev_bust + ((n) * 2)) |
||
| 398 | /* distance to mate/loss macros (mate/loss centipawn argument) */ |
||
| 399 | # define synth_distance_mate(cpev) ((siT) (((cpev_mate - (cpev)) + 1) / 2)) |
||
| 400 | # define synth_distance_loss(cpev) ((siT) (((cpev) - cpev_bust) / 2)) |
||
| 401 | /* maximum distance to mate/loss (fullmove distance count) */ |
||
| 402 | # define max_dist_mateL 1024 |
||
| 403 | # define max_dist_lossL 1024 |
||
| 404 | /* forced mate/loss detection macros (mate/loss centipawn argument) */ |
||
| 405 | # define forced_mate(cpev) ((cpev) >= ((cpev_mate - (max_dist_mateL * 2)) + 1)) |
||
| 406 | # define forced_loss(cpev) ((cpev) <= (cpev_bust + (max_dist_lossL * 2))) |
||
| 407 | /* move flag bits */ |
||
| 408 | typedef siT mfT; |
||
| 409 | |||
| 108 | pmbaty | 410 | # define mf_bust (bit << 0) /* illegal move */ |
| 411 | # define mf_chec (bit << 1) /* checking */ |
||
| 412 | # define mf_chmt (bit << 2) /* checkmating */ |
||
| 413 | # define mf_draw (bit << 3) /* drawing (includes stalemating) */ |
||
| 414 | # define mf_exec (bit << 4) /* executed at least once */ |
||
| 415 | # define mf_null (bit << 5) /* special null move */ |
||
| 416 | # define mf_sanf (bit << 6) /* needs file disambiguation */ |
||
| 417 | # define mf_sanr (bit << 7) /* needs rank disambiguation */ |
||
| 418 | # define mf_stmt (bit << 8) /* stalemating */ |
||
| 33 | pmbaty | 419 | /* special case move type */ |
| 420 | typedef siT scmvT; |
||
| 421 | |||
| 422 | # define scmvQ 3 |
||
| 423 | # define scmvL (bit << scmvQ) |
||
| 424 | # define scmv_nil (-1) |
||
| 108 | pmbaty | 425 | # define scmv_reg 0 /* regular */ |
| 426 | # define scmv_epc 1 /* en passant capture */ |
||
| 427 | # define scmv_cks 2 /* castles kingside */ |
||
| 428 | # define scmv_cqs 3 /* castles queenside */ |
||
| 429 | # define scmv_ppn 4 /* pawn promotes to knight */ |
||
| 430 | # define scmv_ppb 5 /* pawn promotes to bishop */ |
||
| 431 | # define scmv_ppr 6 /* pawn promotes to rook */ |
||
| 432 | # define scmv_ppq 7 /* pawn promotes to queen */ |
||
| 33 | pmbaty | 433 | /* move type */ |
| 434 | typedef struct mS { |
||
| 108 | pmbaty | 435 | mfT m_flag; /* move flags */ |
| 436 | sqT m_frsq; /* from square */ |
||
| 437 | sqT m_tosq; /* to square */ |
||
| 438 | cpT m_frcp; /* from color-piece */ |
||
| 439 | cpT m_tocp; /* to color-piece */ |
||
| 440 | scmvT m_scmv; /* special case move indication */ |
||
| 33 | pmbaty | 441 | } mT, *mptrT; |
| 442 | |||
| 443 | /* game termination indicator markers */ |
||
| 444 | typedef siT gtimT, *gtimptrT; |
||
| 445 | |||
| 446 | # define gtimL 4 |
||
| 447 | # define gtim_nil (-1) |
||
| 108 | pmbaty | 448 | # define gtim_w 0 /* White won */ |
| 449 | # define gtim_b 1 /* Black won */ |
||
| 450 | # define gtim_d 2 /* draw */ |
||
| 451 | # define gtim_u 3 /* unknown */ |
||
| 33 | pmbaty | 452 | /* clockstamp length hh:mm:ss */ |
| 453 | # define clockstampL (2 + 1 + 2 + 1 + 2 + 1) |
||
| 454 | /* datestamp length YYYY.MM.DD */ |
||
| 455 | # define datestampL (4 + 1 + 2 + 1 + 2 + 1) |
||
| 456 | /* duration length dddd:hh:mm:ss */ |
||
| 457 | # define durationL (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1) |
||
| 458 | /* EPD operand basetype */ |
||
| 459 | typedef siT eobT; |
||
| 460 | |||
| 461 | # define eobL 2 |
||
| 462 | # define eob_nil (-1) |
||
| 108 | pmbaty | 463 | # define eob_string 0 /* quoted string */ |
| 464 | # define eob_symbol 1 /* unquoted symbol */ |
||
| 33 | pmbaty | 465 | /* EPD operand value type */ |
| 466 | typedef struct eovS { |
||
| 108 | pmbaty | 467 | eobT eov_eob; /* basetype */ |
| 468 | charptrT eov_str; /* string value */ |
||
| 469 | struct eovS *eov_prev; /* previous operand */ |
||
| 470 | struct eovS *eov_next; /* next operand */ |
||
| 33 | pmbaty | 471 | } eovT, *eovptrT; |
| 472 | |||
| 473 | /* EPD operation type */ |
||
| 474 | typedef struct eopS { |
||
| 108 | pmbaty | 475 | charptrT eop_opsym; /* operation code symbol */ |
| 476 | eovptrT eop_headeov; /* head of operand value list */ |
||
| 477 | eovptrT eop_taileov; /* tail of operand value list */ |
||
| 478 | struct eopS *eop_prev; /* previous operation */ |
||
| 479 | struct eopS *eop_next; /* next operation */ |
||
| 33 | pmbaty | 480 | } eopT, *eopptrT; |
| 481 | |||
| 482 | /* EPD record type */ |
||
| 483 | typedef struct epdS { |
||
| 108 | pmbaty | 484 | nbvT epd_nbv; /* piece placement nybble board vector */ |
| 485 | cT epd_actc; /* active color */ |
||
| 486 | castT epd_cast; /* castling availability */ |
||
| 487 | sqT epd_epsq; /* en passant target square */ |
||
| 488 | eopptrT epd_headeop; /* head of operation list */ |
||
| 489 | eopptrT epd_taileop; /* tail of operation list */ |
||
| 33 | pmbaty | 490 | } epdT, *epdptrT; |
| 491 | |||
| 492 | /* EPD standard operators */ |
||
| 493 | typedef siT epdsoT, *epdsoptrT; |
||
| 494 | |||
| 495 | # define epdsoL 51 |
||
| 496 | # define epdso_nil (-1) |
||
| 108 | pmbaty | 497 | # define epdso_acd 0 /* analysis count: depth */ |
| 498 | # define epdso_acn 1 /* analysis count: nodes */ |
||
| 499 | # define epdso_acs 2 /* analysis count: seconds */ |
||
| 500 | # define epdso_am 3 /* avoid move(s) */ |
||
| 501 | # define epdso_bm 4 /* best move(s) */ |
||
| 502 | # define epdso_c0 5 /* comment slot 0 */ |
||
| 503 | # define epdso_c1 6 /* comment slot 1 */ |
||
| 504 | # define epdso_c2 7 /* comment slot 2 */ |
||
| 505 | # define epdso_c3 8 /* comment slot 3 */ |
||
| 506 | # define epdso_c4 9 /* comment slot 4 */ |
||
| 507 | # define epdso_c5 10 /* comment slot 5 */ |
||
| 508 | # define epdso_c6 11 /* comment slot 6 */ |
||
| 509 | # define epdso_c7 12 /* comment slot 7 */ |
||
| 510 | # define epdso_c8 13 /* comment slot 8 */ |
||
| 511 | # define epdso_c9 14 /* comment slot 9 */ |
||
| 512 | # define epdso_cc 15 /* chess clock */ |
||
| 513 | # define epdso_ce 16 /* centipawn evaluation */ |
||
| 514 | # define epdso_dm 17 /* direct move count */ |
||
| 515 | # define epdso_draw_accept 18 /* draw accept */ |
||
| 516 | # define epdso_draw_claim 19 /* draw claim */ |
||
| 517 | # define epdso_draw_offer 20 /* draw offer */ |
||
| 518 | # define epdso_draw_reject 21 /* draw reject */ |
||
| 519 | # define epdso_eco 22 /* ECO code */ |
||
| 520 | # define epdso_fmvn 23 /* fullmove number */ |
||
| 521 | # define epdso_hmvc 24 /* halfmove clock */ |
||
| 522 | # define epdso_id 25 /* position identification */ |
||
| 523 | # define epdso_nic 26 /* NIC code */ |
||
| 524 | # define epdso_noop 27 /* no operation */ |
||
| 525 | # define epdso_pm 28 /* predicted move */ |
||
| 526 | # define epdso_ptp 29 /* PGN tag pair(s) */ |
||
| 527 | # define epdso_pv 30 /* predicted variation */ |
||
| 528 | # define epdso_rc 31 /* repetition count */ |
||
| 529 | # define epdso_refcom 32 /* referee command */ |
||
| 530 | # define epdso_refreq 33 /* referee request */ |
||
| 531 | # define epdso_resign 34 /* resign */ |
||
| 532 | # define epdso_sm 35 /* supplied move */ |
||
| 533 | # define epdso_sv 36 /* supplied variation */ |
||
| 534 | # define epdso_tcgs 37 /* telecommunications: game selector */ |
||
| 535 | # define epdso_tcri 38 /* telecommunications: receiver identification */ |
||
| 536 | # define epdso_tcsi 39 /* telecommunications: sender identification */ |
||
| 537 | # define epdso_ts 40 /* timestamp */ |
||
| 538 | # define epdso_v0 41 /* variation slot 0 */ |
||
| 539 | # define epdso_v1 42 /* variation slot 1 */ |
||
| 540 | # define epdso_v2 43 /* variation slot 2 */ |
||
| 541 | # define epdso_v3 44 /* variation slot 3 */ |
||
| 542 | # define epdso_v4 45 /* variation slot 4 */ |
||
| 543 | # define epdso_v5 46 /* variation slot 5 */ |
||
| 544 | # define epdso_v6 47 /* variation slot 6 */ |
||
| 545 | # define epdso_v7 48 /* variation slot 7 */ |
||
| 546 | # define epdso_v8 49 /* variation slot 8 */ |
||
| 547 | # define epdso_v9 50 /* variation slot 9 */ |
||
| 33 | pmbaty | 548 | /* referee commands */ |
| 549 | typedef siT refcomT, *refcomptrT; |
||
| 550 | |||
| 551 | # define refcomL 7 |
||
| 552 | # define refcom_nil (-1) |
||
| 553 | # define refcom_conclude 0 |
||
| 554 | # define refcom_disconnect 1 |
||
| 555 | # define refcom_execute 2 |
||
| 556 | # define refcom_fault 3 |
||
| 557 | # define refcom_inform 4 |
||
| 558 | # define refcom_respond 5 |
||
| 559 | # define refcom_reset 6 |
||
| 560 | /* referee requests */ |
||
| 561 | typedef siT refreqT, *refreqptrT; |
||
| 562 | |||
| 563 | # define refreqL 4 |
||
| 564 | # define refreq_nil (-1) |
||
| 565 | # define refreq_fault 0 |
||
| 566 | # define refreq_reply 1 |
||
| 567 | # define refreq_sign_on 2 |
||
| 568 | # define refreq_sign_off 3 |
||
| 569 | /* referee interface procedure type */ |
||
| 570 | typedef epdptrT(*refintptrT) (epdptrT epdptr, siptrT flagptr); |
||
| 571 | |||
| 572 | /* PGN Seven Tag Roster names */ |
||
| 573 | typedef siT pgnstrT, *pgnstrptrT; |
||
| 574 | |||
| 575 | # define pgnstrL 7 |
||
| 576 | # define pgnstr_nil (-1) |
||
| 577 | # define pgnstr_event 0 |
||
| 578 | # define pgnstr_site 1 |
||
| 579 | # define pgnstr_date 2 |
||
| 580 | # define pgnstr_round 3 |
||
| 581 | # define pgnstr_white 4 |
||
| 582 | # define pgnstr_black 5 |
||
| 583 | # define pgnstr_result 6 |
||
| 584 | /* benchmark score structure */ |
||
| 585 | typedef struct bmsS { |
||
| 108 | pmbaty | 586 | siT bms_acdflag; /* ACD (depth) data valid flag */ |
| 587 | siT bms_acnflag; /* ACN (nodes) data valid flag */ |
||
| 588 | siT bms_acsflag; /* ACS (seconds) data valid flag */ |
||
| 589 | liT bms_total; /* total record count */ |
||
| 590 | liT bms_solve; /* solved record count */ |
||
| 591 | liT bms_unsol; /* unsolved record count */ |
||
| 592 | liT bms_total_acd; /* ACD used, all records */ |
||
| 593 | liT bms_solve_acd; /* ACD used, solved records */ |
||
| 594 | liT bms_unsol_acd; /* ACD used, unsolved records */ |
||
| 595 | liT bms_total_acn; /* ACN used, all records */ |
||
| 596 | liT bms_solve_acn; /* ACN used, solved records */ |
||
| 597 | liT bms_unsol_acn; /* ACN used, unsolved records */ |
||
| 598 | liT bms_total_acs; /* ACS used, all records */ |
||
| 599 | liT bms_solve_acs; /* ACS used, solved records */ |
||
| 600 | liT bms_unsol_acs; /* ACS used, unsolved records */ |
||
| 33 | pmbaty | 601 | } bmsT, *bmsptrT; |
| 602 | |||
| 603 | /* environment stack entry record type */ |
||
| 604 | typedef struct eseS { |
||
| 108 | pmbaty | 605 | cT ese_actc; /* active color */ |
| 606 | castT ese_cast; /* castling availability */ |
||
| 607 | sqT ese_epsq; /* en passant target square */ |
||
| 608 | siT ese_hmvc; /* halfmove clock */ |
||
| 609 | siT ese_fmvn; /* fullmove number */ |
||
| 610 | sqT ese_ksqv[rcL]; /* king square locations */ |
||
| 33 | pmbaty | 611 | } eseT, *eseptrT; |
| 612 | |||
| 613 | /* game played move record type (entries are prior to move) */ |
||
| 614 | typedef struct gpmS { |
||
| 108 | pmbaty | 615 | mT gpm_m; /* the move to be played */ |
| 616 | eseT gpm_ese; /* environment statck entry storage */ |
||
| 617 | nbvT gpm_nbv; /* nybble board vector */ |
||
| 618 | struct gpmS *gpm_prev; /* previous played move record */ |
||
| 619 | struct gpmS *gpm_next; /* next played move record */ |
||
| 33 | pmbaty | 620 | } gpmT, *gpmptrT; |
| 621 | |||
| 622 | /* game record type */ |
||
| 623 | typedef struct gamS { |
||
| 108 | pmbaty | 624 | charptrT gam_strv[pgnstrL]; /* PGN STR tag values */ |
| 625 | gtimT gam_gtim; /* game termination indicator */ |
||
| 626 | gpmptrT gam_headgpm; /* head of game played move list */ |
||
| 627 | gpmptrT gam_tailgpm; /* tail of game played move list */ |
||
| 628 | struct gamS *gam_prev; /* previous game */ |
||
| 629 | struct gamS *gam_next; /* next game */ |
||
| 33 | pmbaty | 630 | } gamT, *gamptrT; |
| 631 | |||
| 632 | /* statndard disply output column limit */ |
||
| 633 | # define columnL 80 |
||
| 634 | /* inclusion telltale closure */ |
||
| 635 | # endif |
||
| 636 | /* *INDENT-ON* */ |