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