3 Copyright (c) Scott Gasch
17 $Id: chess.h 344 2007-11-30 06:49:50Z scott $
29 #define MIN_CHAR (0x80)
30 #define MAX_CHAR (0x7f)
33 #define MIN_BYTE (0x00)
34 #define MAX_BYTE (0xff)
35 typedef unsigned char BYTE;
37 #define MIN_UCHAR (0x00)
38 #define MAX_UCHAR (0xff)
39 typedef unsigned char UCHAR;
40 #define CAN_FIT_IN_UCHAR(x) ((x) <= MAX_UCHAR)
42 #define MIN_SHORT (0x8000)
43 #define MAX_SHORT (0x7fff)
44 typedef signed short SHORT;
46 #define MIN_USHORT (0x0000)
47 #define MAX_USHORT (0xffff)
48 typedef unsigned short USHORT;
49 #define CAN_FIT_IN_USHORT(x) ((x) <= MAX_USHORT)
51 #define MIN_WORD (0x0000)
52 #define MAX_WORD (0xffff)
53 typedef unsigned short WORD;
55 #define MIN_INT (0x80000000)
56 #define MAX_INT (0x7fffffff)
57 typedef signed int INT;
59 #define MIN_DWORD (0x00000000)
60 #define MAX_DWORD (0xffffffff)
61 typedef unsigned int DWORD;
63 #define MIN_UINT (0x00000000)
64 #define MAX_UINT (0xffffffff)
65 typedef unsigned int UINT;
67 #define MIN_ULONG (0x00000000)
68 #define MAX_ULONG (0xffffffff)
69 typedef unsigned int ULONG;
71 #define MIN_INT64 (0x8000000000000000)
72 #define MAX_INT64 (0x7fffffffffffffff)
73 typedef signed COMPILER_LONGLONG INT64;
75 #define MIN_UINT64 (0x0000000000000000)
76 #define MAX_UINT64 (0xffffffffffffffff)
77 typedef unsigned COMPILER_LONGLONG UINT64;
79 #define MIN_BITBOARD (0x0000000000000000)
80 #define MAX_BITBOARD (0xffffffffffffffff)
81 typedef UINT64 BITBOARD;
83 #define MIN_BITV MIN_UINT
84 #define MAX_BITV MAX_UINT
85 typedef unsigned int BITV;
87 #define MIN_FLAG MIN_UINT
88 #define MAX_FLAG MAX_UINT
89 typedef unsigned int FLAG;
90 #define IS_VALID_FLAG(x) (((x) == TRUE) || ((x) == FALSE))
92 typedef unsigned int COOR;
93 typedef unsigned int PIECE;
94 typedef signed int SCORE;
105 #define BIT10 (0x200)
106 #define BIT11 (0x400)
107 #define BIT12 (0x800)
108 #define BIT13 (0x1000)
109 #define BIT14 (0x2000)
110 #define BIT15 (0x4000)
111 #define BIT16 (0x8000)
112 #define BIT17 (0x10000)
113 #define BIT18 (0x20000)
114 #define BIT19 (0x40000)
115 #define BIT20 (0x80000)
116 #define BIT21 (0x100000)
117 #define BIT22 (0x200000)
118 #define BIT23 (0x400000)
119 #define BIT24 (0x800000)
120 #define BIT25 (0x1000000)
121 #define BIT26 (0x2000000)
122 #define BIT27 (0x4000000)
123 #define BIT28 (0x8000000)
124 #define BIT29 (0x10000000)
125 #define BIT30 (0x20000000)
126 #define BIT31 (0x40000000)
127 #define BIT32 (0x80000000)
129 typedef struct _DLIST_ENTRY
131 struct _DLIST_ENTRY *pFlink;
132 struct _DLIST_ENTRY *pBlink;
148 // Calculate the length of an array (i.e. number of elements)
150 #define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
152 void (x)(CHAR *szInput, ULONG argc, CHAR *argv[], POSITION *pos)
153 #define MB (1024 * 1024)
156 // Calculate the address of the base of the structure given its type, and an
157 // address of a field within the structure.
160 #define OFFSET_OF(field, type) \
161 (ULONG)(&((type *)0)->field)
163 #ifndef CONTAINING_STRUCT
164 #define CONTAINING_STRUCT(address, type, field) \
165 ((type *)((BYTE *)(address) - (BYTE *)(OFFSET_OF(field, type))))
170 #define BAD_COLOR (2)
171 #define IS_VALID_COLOR(x) (((x) == WHITE) || ((x) == BLACK))
172 #define FOREACH_COLOR(x) for((x) = BLACK; (x) < BAD_COLOR; (x)++)
173 #define RANDOM_COLOR (rand() & 1)
174 #define FLIP(color) ((color) ^ 1)
175 #define COLOR_NAME(color) (((color) == WHITE) ? "white" : "black")
177 #define MAX_MOVES_PER_PLY (218)
178 #define MAX_PLY_PER_SEARCH (64)
179 #define MAX_MOVES_PER_GAME (1024)
180 #define SMALL_STRING_LEN_CHAR (256)
181 #define MEDIUM_STRING_LEN_CHAR (8192)
182 #define BIG_STRING_LEN_CHAR (16384)
184 #define QUARTER_PLY 16
186 #define THREE_QUARTERS_PLY 48
189 #define THREE_PLY 192
191 #define MAX_DEPTH_PER_SEARCH (MAX_PLY_PER_SEARCH * ONE_PLY)
193 #define IS_VALID_DEPTH(x) (((x) >= 0) && \
194 ((x) <= MAX_DEPTH_PER_SEARCH) && \
195 (((x) & 0xfffff00f) == 0))
197 #define INFINITY (MAX_SHORT)
198 #define INVALID_SCORE (INFINITY + 1)
199 #define IS_VALID_SCORE(x) (((x) >= -INFINITY) && \
201 #define NMATE (+INFINITY - 200)
202 #define MATED_SCORE(ply) (-INFINITY + (ply))
204 #define IS_A_POWER_OF_2(x) (((x) & (x - 1)) == 0)
206 // Program version number
208 #define VERSION "1.00"
209 #define REVISION "$Id: chess.h 344 2007-11-30 06:49:50Z scott $\n"
212 // Function decorators
220 // ----------------------------------------------------------------------
224 // a piece (4 bits) = type (3 bits) + color (1 bit)
231 #define KING (6) // 110X
232 #define QUEEN (5) // 101X
233 #define ROOK (4) // 100X
234 #define BISHOP (3) // 011X
235 #define KNIGHT (2) // 010X
236 #define PAWN (1) // 001X
237 #define EMPTY (0) // 000X
240 #define BLACK_PAWN (2) // 0010
241 #define BLACK_KNIGHT (4) // 0100
242 #define BLACK_BISHOP (6) // 0110
243 #define BLACK_ROOK (8) // 1000
244 #define BLACK_QUEEN (10) // 1010
245 #define BLACK_KING (12) // 1100
247 // (WHATEVER << 1) | WHITE
248 #define WHITE_PAWN (3) // 0011
249 #define WHITE_KNIGHT (5) // 0101
250 #define WHITE_BISHOP (7) // 0111
251 #define WHITE_ROOK (9) // 1001
252 #define WHITE_QUEEN (11) // 1011
253 #define WHITE_KING (13) // 1101
255 #define PIECE_TYPE(p) ((p) >> 1)
256 #define PIECE_COLOR(p) ((p) & WHITE)
257 #define RANDOM_PIECE (rand() % 12) + 2;
258 #define IS_PAWN(p) (((p) & 0xE) == BLACK_PAWN)
259 #define IS_KNIGHT(p) (((p) & 0xE) == BLACK_KNIGHT)
260 #define IS_BISHOP(p) (((p) & 0xE) == BLACK_BISHOP)
261 #define IS_ROOK(p) (((p) & 0xE) == BLACK_ROOK)
262 #define IS_QUEEN(p) (((p) & 0xE) == BLACK_QUEEN)
263 #define IS_KING(p) (((p) & 0xE) == BLACK_KING)
264 #define IS_KNIGHT_OR_KING(p) (((p) & 0x6) == 0x4)
265 #define IS_VALID_PIECE(p) ((PIECE_TYPE((p)) >= PAWN) && \
266 (PIECE_TYPE((p)) <= KING))
267 #define IS_WHITE_PIECE(p) ((p) & WHITE)
268 #define IS_BLACK_PIECE(p) (!IS_WHITE(p))
269 #define OPPOSITE_COLORS(p, q) (((p) ^ (q)) & WHITE)
270 #define SAME_COLOR(p,q) (!OPPOSITE_COLORS(p, q))
271 #define GET_COLOR(p) ((p) & WHITE)
273 // ----------------------------------------------------------------------
275 // a coordinate (8 bits) = rank + file (0x88)
282 // | +--- 0-7 = file A thru file H
284 // +------------ 0-7 = rank 1 thru rank 8
286 // given a coordinate, C, if C & 0x88 then it is illegal (off board)
289 // 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
290 // +---------------------------------------+
291 // 8 | 00 |:01:| 02 |:03:| 04 |:05:| 06 |:07:| 0x00
292 // 7 |:10:| 11 |:12:| 13 |:14:| 15 |:16:| 17 | 0x10
293 // 6 | 20 |:21:| 22 |:23:| 24 |:25:| 26 |:27:| 0x20
294 // 5 |:30:| 31 |:32:| 33 |:34:| 35 |:36:| 37 | 0x30
295 // 4 | 40 |:41:| 42 |:43:| 44 |:45:| 46 |:47:| 0x40
296 // 3 |:50:| 51 |:52:| 53 |:54:| 55 |:56:| 57 | 0x50
297 // 2 | 60 |:61:| 62 |:63:| 64 |:65:| 66 |:67:| 0x60
298 // 1 |:70:| 71 |:72:| 73 |:74:| 75 |:76:| 77 | 0x70
299 // +---------------------------------------+
383 // TODO: if use this anywhere that matters, consider double loop
384 // and unrolling the inside loop to prevent the multiple
385 // continue for invalid squares
386 #define FOREACH_SQUARE(x) for((x) = (A8); (x) <= (H1); (x)++)
388 #define IS_ON_BOARD(c) (!((c) & 0x88))
389 #define RANDOM_COOR (rand() & 0x77)
390 #define FILE_RANK_TO_COOR(f, r) (((8 - (r)) << 4) | (f))
391 #define RANK(c) (8 - ((c) >> 4))
392 #define RANK1(c) (((c) & 0xF0) == 0x70)
393 #define RANK2(c) (((c) & 0xF0) == 0x60)
394 #define RANK3(c) (((c) & 0xF0) == 0x50)
395 #define RANK4(c) (((c) & 0xF0) == 0x40)
396 #define RANK5(c) (((c) & 0xF0) == 0x30)
397 #define RANK6(c) (((c) & 0xF0) == 0x20)
398 #define RANK7(c) (((c) & 0xF0) == 0x10)
399 #define RANK8(c) (((c) & 0xF0) == 0x00)
400 #define FILE(c) ((c) & 0x0F)
401 #define FILEA(c) (((c) & 0x0F) == 0x00)
402 #define FILEB(c) (((c) & 0x0F) == 0x01)
403 #define FILEC(c) (((c) & 0x0F) == 0x02)
404 #define FILED(c) (((c) & 0x0F) == 0x03)
405 #define FILEE(c) (((c) & 0x0F) == 0x04)
406 #define FILEF(c) (((c) & 0x0F) == 0x05)
407 #define FILEG(c) (((c) & 0x0F) == 0x06)
408 #define FILEH(c) (((c) & 0x0F) == 0x07)
409 #define IS_WHITE_SQUARE_FR(f, r) (((f) + (r) - 1) & 1)
410 #define IS_WHITE_SQUARE_COOR(c) (IS_WHITE_SQUARE_FR(FILE(c), RANK(c)))
411 #define VALID_EP_SQUARE(c) (((c) == ILLEGAL_COOR) || ((c) == 0) || \
415 // ----------------------------------------------------------------------
417 // a move (4 bytes) = from/to, moved, captured, promoted and special
419 // 31 24 23 16 15 12 11 8 7 4 3 0
420 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
421 // | from | to | moved | capt | prom | flags |
425 // | | +-------+-------+-- type and
430 // +---------------+-- board location where
431 // move begins and ends
434 // Special flag asserted on special move types:
438 // if (moved == PAWN)
442 // move is a promote (w/ or w/o capture)
446 // move is an en passant catpure
450 // move is a double jump
453 // else if (moved == KING)
455 // move is a castle (long or short)
459 // invalid use of special flag
477 #define IS_SAME_MOVE(a, b) \
478 (((a).uMove & 0x0FFFFFFF) == (((b).uMove & 0x0FFFFFFF)))
480 #define MAKE_MOVE(from,to,piece,cap,prom,flags) \
482 ((ULONG)(to) << 8) | \
483 ((ULONG)(piece) << 16) | \
484 ((ULONG)(cap) << 20) | \
485 ((ULONG)(prom) << 24) | \
486 ((ULONG)(flags) << 28))
488 #define MAKE_MOVE_WITH_NO_PROM_OR_FLAGS(from,to,piece,cap) \
490 ((ULONG)(to) << 8) | \
491 ((ULONG)(piece) << 16) | \
492 ((ULONG)(cap) << 20))
497 #define MOVE_FLAG_SPECIAL (1) // en pass, prom, castle, double
498 #define IS_SPECIAL_MOVE(mv) \
499 ((mv).uMove & 0x10000000)
501 #define IS_CASTLE(mv) \
502 (IS_SPECIAL_MOVE(mv) && IS_KING((mv).pMoved))
505 #define IS_PROMOTION(mv) \
506 (IS_SPECIAL_MOVE(mv) && ((mv).pPromoted))
508 #define IS_PROMOTION(mv) \
512 #define IS_CAPTURE_OR_PROMOTION(mv) \
513 ((mv).uMove & 0x0FF00000)
515 #define IS_ENPASSANT(mv) \
516 (IS_SPECIAL_MOVE(mv) && (mv.pCaptured) && !IS_PROMOTION(mv))
518 #define IS_DOUBLE_JUMP(mv) \
519 (IS_SPECIAL_MOVE(mv) && !IS_CAPTURE_OR_PROMOTION(mv))
521 #define MOVE_FLAG_KILLERMATE (2) // killer mate
522 #define IS_KILLERMATE_MOVE(mv) ((mv).uMove & 0x20000000)
524 #define MOVE_FLAG_ESCAPING_CHECK (4) // escaping check
525 #define IS_ESCAPING_CHECK(mv) ((mv).uMove & 0x40000000)
527 #define MOVE_FLAG_CHECKING (8) // checking move
528 #define IS_CHECKING_MOVE(mv) ((mv).uMove & 0x80000000)
530 // ----------------------------------------------------------------------
534 #define MAX_MOVE_LIST (MAX_MOVES_PER_GAME + MAX_PLY_PER_SEARCH)
536 // ----------------------------------------------------------------------
539 typedef union _ATTACK_BITV
549 UCHAR uNumAttacks : 3; // 0..2
550 UCHAR uKing : 1; // 4..7
558 // --------------------
564 USHORT uKing : 1; // 8..23
569 USHORT uUnusedFlag1 : 1;
573 // -------------------
580 UCHAR uUnusedFlag2 : 1;
581 UCHAR uQueen : 1; // 24..28
584 UCHAR uUnusedFlag3 : 1;
591 #define UNSAFE_FOR_MINOR(x) ((ULONG)((x).uWholeThing) & 0x00000080UL)
592 #define UNSAFE_FOR_ROOK(x) ((ULONG)((x).uWholeThing) & 0x000000C0UL)
593 #define UNSAFE_FOR_QUEEN(x) ((ULONG)((x).uWholeThing) & 0x000000E0UL)
595 #define PAWN_BIT 0x00000080UL
596 #define MINOR_BIT 0x00000040UL
597 #define MINOR_XRAY_BIT 0x40000000UL
598 #define ROOK_BIT 0x00000020UL
599 #define ROOK_XRAY_BIT 0x20000000UL
600 #define QUEEN_BIT 0x00000010UL
601 #define QUEEN_XRAY_BIT 0x10000000UL
603 #define INVALID_PIECE_INDEX (17)
604 #define IS_VALID_PIECE_INDEX(x) ((x) < INVALID_PIECE_INDEX)
606 typedef union _SQUARE
613 ATTACK_BITV bvAttacks[2];
621 typedef struct _POSITION
623 SQUARE rgSquare[128]; // where the pieces are,
624 // also, the attack table
625 UINT64 u64NonPawnSig; // hash signature
626 UINT64 u64PawnSig; // pawn hash signature
627 ULONG uToMove; // whose turn?
628 ULONG uFifty; // 50 moves w/o progress = draw
629 FLAG fCastled[2]; // record when sides have castled
630 BITV bvCastleInfo; // who can castle how?
631 COOR cEpSquare; // en-passant capture square
633 COOR cPawns[2][8]; // location of pawns on the board
634 ULONG uPawnMaterial[2]; // pawn material of each side
635 ULONG uPawnCount[2]; // number of pawns for each side
637 COOR cNonPawns[2][16]; // location of pieces on the board
638 ULONG uNonPawnMaterial[2]; // piece material of each side
639 ULONG uNonPawnCount[2][8]; // number of non-pawns / type
640 // 0 and 1 are the sum,
641 // 2..6 are per PIECE_TYPE
643 ULONG uWhiteSqBishopCount[2]; // num bishops on white squares
644 SCORE iMaterialBalance[2]; // material balance
646 // temporary storage space for use in eval
648 ULONG uArmyScaler[2];
651 SCORE iReducedMaterialDownScaler[2];
653 ULONG uMinMobility[2];
655 ULONG uMinorsAtHome[2];
657 ULONG uPiecesPointingAtKing[2];
662 // Castling permission bitvector flags.
664 #define CASTLE_WHITE_SHORT (1)
665 #define CASTLE_WHITE_LONG (2)
666 #define WHITE_CAN_CASTLE \
667 (CASTLE_WHITE_SHORT | CASTLE_WHITE_LONG)
668 #define CASTLE_BLACK_SHORT (4)
669 #define CASTLE_BLACK_LONG (8)
670 #define BLACK_CAN_CASTLE \
671 (CASTLE_BLACK_SHORT | CASTLE_BLACK_LONG)
672 #define CASTLE_NONE_POSSIBLE (0)
673 #define CASTLE_ALL_POSSIBLE \
674 (WHITE_CAN_CASTLE | BLACK_CAN_CASTLE)
676 // ----------------------------------------------------------------------
680 #define MAX_MOVE_STACK (MAX_PLY_PER_SEARCH * \
684 // Main part of the move stack, triads of moves, their values and flags
685 // that denote where the values came from
687 #define MVF_MOVE_SEARCHED (1)
688 #define MVF_EXTEND_MOVE (2)
689 #define MVF_REDUCE_MOVE (4)
690 #define MVF_PRUNE_SUBTREE (8)
692 typedef struct _MOVE_STACK_MOVE_VALUE_FLAGS
698 MOVE_STACK_MOVE_VALUE_FLAGS;
700 typedef struct _KEY_POINTER
707 typedef union _GENERATOR_FLAGS
711 UCHAR uKingMoveCount;
712 UCHAR uCheckingPieces;
722 typedef struct _MOVE_STACK
725 POSITION board[MAX_PLY_PER_SEARCH];
728 // Unblocked squares map, used for check detection
730 ULONG uUnblockedKeyValue[MAX_PLY_PER_SEARCH];
731 KEY_POINTER sUnblocked[MAX_PLY_PER_SEARCH][128];
734 // The main move list, a long series of moves, their values and some
735 // flag bits to tell search what the values are based upon.
737 MOVE_STACK_MOVE_VALUE_FLAGS mvf[MAX_MOVE_STACK];
740 // uBegin[ply] and uEnd[ply] specify the start and end of moves gen-
741 // erated for a position at ply distance from the root.
744 ULONG uBegin[MAX_PLY_PER_SEARCH];
745 ULONG uEnd[MAX_PLY_PER_SEARCH];
746 MOVE mvHash[MAX_PLY_PER_SEARCH];
747 GENERATOR_FLAGS sGenFlags[MAX_PLY_PER_SEARCH];
751 #define GENERATE_NO_MOVES \
752 ctx->sMoveStack.uEnd[ctx->uPly] = \
753 ctx->sMoveStack.uBegin[ctx->uPly] + 1; \
754 ctx->sMoveStack.uBegin[ctx->uPly + 1] = \
755 ctx->sMoveStack.uEnd[ctx->uPly]
757 #define GENERATE_ALL_MOVES (1)
758 #define GENERATE_ESCAPES (2)
759 #define GENERATE_CAPTURES_PROMS_CHECKS (3)
760 #define GENERATE_CAPTURES_PROMS (4)
761 #define GENERATE_DONT_SCORE (5)
763 #define GENERATE_ALL_MOVES_CHECK_OK (6)
766 #define MOVE_COUNT(ctx, x) \
767 (((ctx)->sMoveStack.uEnd[(x)]) - (ctx)->sMoveStack.uBegin[(x)])
768 #define ONE_LEGAL_MOVE(ctx, x) \
769 (MOVE_COUNT(ctx, x) == 1)
770 #define NUM_KING_MOVES(ctx, x) \
771 ((ctx)->sMoveStack.sGenFlags[(x)].uKingMoveCount)
772 #define NUM_CHECKING_PIECES(ctx, x) \
773 ((ctx)->sMoveStack.sGenFlags[(x)].uCheckingPieces)
776 // ----------------------------------------------------------------------
780 typedef struct _COUNTERS
785 UINT64 u64OverallHits;
786 UINT64 u64UsefulHits;
787 UINT64 u64UpperBoundHits;
788 UINT64 u64LowerBoundHits;
789 UINT64 u64ExactScoreHits;
802 UINT64 u64TotalNodeCount;
803 UINT64 u64QNodeCount;
805 UINT64 u64TerminalPositionCount;
806 UINT64 u64BetaCutoffs;
807 UINT64 u64BetaCutoffsOnFirstMove;
809 UINT64 u64NullMoveSuccess;
811 UINT64 u64QuickNullSuccess;
812 UINT64 u64QuickNullDeferredSuccess;
813 UINT64 u64QuickNullFailures;
814 UINT64 u64AvoidNullSuccess;
815 UINT64 u64AvoidNullFailures;
817 UINT64 u64EvalHashHits;
820 UINT64 u64CyclesInEval;
827 ULONG uNumSplitsTerminated;
838 ULONG uNoLegalKingMoves;
842 ULONG uSingularReplyToCheck;
844 ULONG uBotvinnikMarkoff;
858 typedef struct _CUMULATIVE_SEARCH_FLAGS
861 ULONG uNumChecks[2]; // not used
862 FLAG fInSuspiciousBranch; // not used
863 FLAG fInReducedDepthBranch; // not used
864 FLAG fAvoidNullmove; // restore
865 FLAG fVerifyNullmove; // restore
868 ULONG uQsearchDepth; // restore
869 ULONG uQsearchNodes; // incremental
870 ULONG uQsearchCheckDepth; // restore
871 FLAG fCouldStandPat[2]; // restore
873 CUMULATIVE_SEARCH_FLAGS;
875 // ----------------------------------------------------------------------
877 // Searcher thread record
879 typedef struct _SPLIT_INFO
882 volatile ULONG uLock; // lock for this split node
883 volatile ULONG uNumThreadsHelping; // num threads in this node
884 volatile FLAG fTerminate; // signal helpers to terminate
886 // moves in the split node
887 ULONG uRemainingMoves; // num moves remaining to do
888 ULONG uOnDeckMove; // next move to do
891 MOVE_STACK_MOVE_VALUE_FLAGS
892 mvf[MAX_MOVES_PER_PLY]; // the moves to search
894 // input to the split node
895 POSITION sRootPosition; // the root position
896 MOVE mvPathToHere[MAX_PLY_PER_SEARCH]; // path from root to split
897 MOVE mvLast; // last move before split
898 ULONG uDepth; // remaining depth at split
899 INT iPositionExtend; // positional extension
900 SCORE iAlpha; // original alpha at split
901 SCORE iBeta; // beta at split
902 ULONG uSplitPositional; // pos->uPositional at split
903 CUMULATIVE_SEARCH_FLAGS sSearchFlags; // flags at split time
905 // output from the split node
906 MOVE mvBest; // the best move
907 SCORE iBestScore; // it's score
908 COUNTERS sCounters; // updated counters
909 MOVE PV[MAX_PLY_PER_SEARCH];
913 POSITION sSplitPosition;
918 typedef struct _PLY_INFO
926 INT iExtensionAmount;
931 MOVE PV[MAX_PLY_PER_SEARCH];
934 ULONG uMinMobility[2];
935 UINT64 u64NonPawnSig;
940 ULONG uTotalNonPawns;
948 #define EVAL_HASH_TABLE_SIZE (2097152) // 32Mb (per thread)
949 typedef struct _EVAL_HASH_ENTRY
959 #define PAWN_HASH_TABLE_SIZE (131072) // 5.5Mb (per thread)
960 typedef struct _PAWN_HASH_ENTRY
963 BITBOARD bbPawnLocations[2];
964 BITBOARD bbPasserLocations[2];
965 BITBOARD bbStationaryPawns[2];
967 UCHAR uCountPerFile[2][10];
968 UCHAR uNumRammedPawns;
969 UCHAR uNumUnmovedPawns[2];
973 #define NUM_SPLIT_PTRS_IN_CONTEXT (8)
975 typedef struct _SEARCHER_THREAD_CONTEXT
977 ULONG uPly; // its distance from root
978 ULONG uPositional; // positional component of score
979 POSITION sPosition; // the board
980 MOVE_STACK sMoveStack; // the move stack
981 CUMULATIVE_SEARCH_FLAGS sSearchFlags;
982 PLY_INFO sPlyInfo[MAX_PLY_PER_SEARCH+1];
983 MOVE mvKiller[MAX_PLY_PER_SEARCH][2];
984 MOVE mvKillerEscapes[MAX_PLY_PER_SEARCH][2];
985 MOVE mvNullmoveRefutations[MAX_PLY_PER_SEARCH];
988 SPLIT_INFO *pSplitInfo[NUM_SPLIT_PTRS_IN_CONTEXT];
992 PAWN_HASH_ENTRY rgPawnHash[PAWN_HASH_TABLE_SIZE];
994 EVAL_HASH_ENTRY rgEvalHash[EVAL_HASH_TABLE_SIZE];
996 CHAR szLastPV[SMALL_STRING_LEN_CHAR];
998 SEARCHER_THREAD_CONTEXT;
1001 // When I added the pawn hash table and eval hash tables to searcher
1002 // thread contexts they became too heavy to just allocate on the fly
1003 // for things like checking the legality of SAN moves or seeing if an
1004 // opening book line leads to a draw. This
1005 // LIGHTWEIGHT_SEARCHER_CONTEXT structure can be cast into a full
1006 // SEARCHER_THREAD_CONTEXT and passed safely into the Generate,
1007 // MakeMove and UnMakeMove functions because they presently only
1015 typedef struct _LIGHTWEIGHT_SEARCHER_CONTEXT
1020 MOVE_STACK sMoveStack;
1021 CUMULATIVE_SEARCH_FLAGS sSearchFlags;
1022 PLY_INFO sPlyInfo[MAX_PLY_PER_SEARCH+1];
1024 LIGHTWEIGHT_SEARCHER_CONTEXT;
1026 // ----------------------------------------------------------------------
1028 // Global game options
1030 typedef struct _GAME_OPTIONS
1033 ULONG uOpponentsClock;
1035 FLAG fOpponentIsComputer;
1041 FLAG fSuccessfulPonder;
1044 FLAG fForceDrawWorthZero;
1046 ULONG uMovesPerTimePeriod;
1047 CHAR szAnalyzeProgressReport[SMALL_STRING_LEN_CHAR];
1048 FLAG fShouldAnnounceOpening;
1049 SCORE iLastEvalScore;
1050 UINT64 u64NodesSearched;
1051 CHAR szLogfile[SMALL_STRING_LEN_CHAR];
1052 CHAR szEGTBPath[SMALL_STRING_LEN_CHAR];
1053 CHAR szBookName[SMALL_STRING_LEN_CHAR];
1054 ULONG uNumProcessors;
1055 ULONG uNumHashTableEntries;
1056 FLAG fNoInputThread;
1057 FLAG fVerbosePosting;
1058 FLAG fRunningUnderXboard;
1091 extern GAME_OPTIONS g_Options;
1093 // ----------------------------------------------------------------------
1098 #define TIMER_SEARCHING_FIRST_MOVE (0x1)
1099 #define TIMER_SEARCHING_IMPORTANT_MOVE (0x2)
1100 #define TIMER_RESOLVING_ROOT_FL (0x4)
1101 #define TIMER_RESOLVING_ROOT_FH (0x8)
1102 #define TIMER_JUST_OUT_OF_BOOK (0x10)
1103 #define TIMER_CURRENT_OBVIOUS (0x20)
1104 #define TIMER_CURRENT_WONT_UNBLOCK (0x40)
1105 #define TIMER_ROOT_POSITION_CRITICAL (0x80)
1106 #define TIMER_MOVE_IMMEDIATELY (0x100)
1107 #define TIMER_MANY_ROOT_FLS (0x200)
1108 #define TIMER_STOPPING (0x400)
1109 #define TIMER_SPLIT_FAILED (0x800)
1111 typedef struct _MOVE_TIMER
1115 double dSoftTimeLimit;
1116 double dHardTimeLimit;
1117 ULONG uNodeCheckMask;
1118 volatile BITV bvFlags;
1122 // ----------------------------------------------------------------------
1124 // Special move tag literals
1126 #define ILLEGALMOVE ((ULONG)0x1DDD8888)
1133 _assert(CHAR *szFile, ULONG uLine);
1135 #define ASSERT(x) if (x) \
1138 { _assert(__FILE__, __LINE__); }
1139 #define VERIFY(x) ASSERT(x)
1142 #define VERIFY(x) x;
1145 #ifdef PERF_COUNTERS
1146 #define INC(x) ((x) += 1)
1151 #define BREAKPOINT SystemDebugBreakpoint()
1153 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
1154 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
1158 // Note: MAXU, MINU and ABS_DIFF require arguments with the high order
1159 // bit CLEAR to work right.
1161 // These are branchless constructs. MAXU and MINU are equivalent to
1162 // MIN and MAX (with the above restriction on inputs)
1164 // MIN0 and MAX0 are equivalent to MAX(0, x) and MIN(0, x). These
1165 // macros have no restiction on argument type.
1167 // ABS_DIFF is equivalent to abs(x - y). Again, x and y must have
1168 // their high-order bits CLEAR for this to work.
1170 // Note: gcc generates code with cmovs so no need for MAXU/MINU on
1174 #define MINU(x, y) \
1175 (((((int)((x)-(y)))>>31) & ((x)-(y)))+(y))
1176 #define MAXU(x, y) \
1177 (((((int)((x)-(y)))>>31) & ((y)-(x)))+(x))
1182 ((x) & (((int)(x)) >> 31))
1185 ((x) & ~(((int)(x)) >> 31))
1188 extern INLINE int MIN0(int x)
1191 int z = ((x) & (((int)(x)) >> 31));
1196 extern INLINE int MAX0(int x)
1199 int z = ((x) & ~(((int)(x)) >> 31));
1205 #define ABS_DIFF(a, b) \
1206 (((b)-(a)) - ((((b) - (a)) & (((int)((b) - (a))) >> 31) ) << 1))
1211 #define MINU(x, y) (MIN((x), (y)))
1215 #define MAXU(x, y) (MAX((x), (y)))
1219 #define MIN0(x) (MIN((x), 0))
1223 #define MAX0(x) (MAX((x), 0))
1227 #define ABS_DIFF(a, b) (abs((a) - (b)))
1230 #define FILE_DISTANCE(a, b) (ABS_DIFF(FILE((a)), FILE((b))))
1231 #define RANK_DISTANCE(a, b) (ABS_DIFF(((a) & 0xF0), ((b) & 0xF0)) >> 4)
1232 #define REAL_DISTANCE(a, b) (MAXU(FILE_DISTANCE((a), (b)), \
1233 RANK_DISTANCE((a), (b))))
1235 #define DISTANCE(a, b) DistanceBetweenSquares((a), (b))
1237 #define DISTANCE(a, b) g_pDistance[(a) - (b)]
1240 #define IS_EMPTY( square ) (!(square))
1241 #define IS_OCCUPIED( square ) ((square))
1243 #define IS_DEAD( listindex ) ((listindex) > 119)
1244 #define IS_ALIVE( listindex ) ((listindex) <= 119)
1245 #define ILLEGAL_COOR (0x88)
1246 #define EDGE_DISTANCE(c) (MIN(MIN(abs(RANK(c) - 7), RANK(c)), \
1247 MIN(abs(FILE(c) - 7), FILE(c))))
1248 #define NOT_ON_EDGE(c) ((((c) & 0xF0) != 0x00) && \
1249 (((c) & 0xF0) != 0x70) && \
1250 (((c) & 0x0F) != 0x00) && \
1251 (((c) & 0x0F) != 0x07))
1252 #define ON_EDGE(c) (RANK8(c) || \
1256 #define CORNER_DISTANCE(c) (MAX(MIN((ULONG)abs(RANK(c) - 7), RANK(c)),\
1257 MIN((ULONG)abs(FILE(c) - 7), FILE(c))))
1258 #define IN_CORNER(c) (((c) == A8) || \
1262 #define WHITE_CORNER_DISTANCE(c) (MIN(DISTANCE((c), A8), \
1264 #define BLACK_CORNER_DISTANCE(c) (MIN(DISTANCE((c), H8), \
1266 #define SYM_SQ(c) ((7 - (((c) & 0xF0) >> 4)) << 4) \
1267 | (7 - ((c) & 0x0F))
1268 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a[0])))
1269 #define MAKE_PSQT(a, b, c, d) (((a) << 24) | ((b) << 16) | \
1271 #define TO64(x) ((x) & 0x7) + ((0x7 - ((x)>>4)) << 3)
1272 #define COOR_TO_BIT_NUMBER(c) (((((c) & 0x70) >> 1) | ((c) & 0x7)))
1273 #define SLOWCOOR_TO_BB(c) (1ULL << COOR_TO_BIT_NUMBER(c))
1274 #define COOR_TO_BB(c) (BBSQUARE[COOR_TO_BIT_NUMBER(c)])
1275 #define SLOW_BIT_NUMBER_TO_COOR(b) ((((b) / 8) << 4) + ((b) & 7))
1276 #define BIT_NUMBER_TO_COOR(b) ((((b) & 0xF8) << 1) | ((b) & 7))
1279 SLOWCOOR_TO_BB(A8) | SLOWCOOR_TO_BB(B8) | SLOWCOOR_TO_BB(C8) | \
1280 SLOWCOOR_TO_BB(D8) | SLOWCOOR_TO_BB(E8) | SLOWCOOR_TO_BB(F8) | \
1281 SLOWCOOR_TO_BB(G8) | SLOWCOOR_TO_BB(H8)
1284 SLOWCOOR_TO_BB(A7) | SLOWCOOR_TO_BB(B7) | SLOWCOOR_TO_BB(C7) | \
1285 SLOWCOOR_TO_BB(D7) | SLOWCOOR_TO_BB(E7) | SLOWCOOR_TO_BB(F7) | \
1286 SLOWCOOR_TO_BB(G7) | SLOWCOOR_TO_BB(H7)
1289 SLOWCOOR_TO_BB(A6) | SLOWCOOR_TO_BB(B6) | SLOWCOOR_TO_BB(C6) | \
1290 SLOWCOOR_TO_BB(D6) | SLOWCOOR_TO_BB(E6) | SLOWCOOR_TO_BB(F6) | \
1291 SLOWCOOR_TO_BB(G6) | SLOWCOOR_TO_BB(H6)
1294 SLOWCOOR_TO_BB(A5) | SLOWCOOR_TO_BB(B5) | SLOWCOOR_TO_BB(C5) | \
1295 SLOWCOOR_TO_BB(D5) | SLOWCOOR_TO_BB(E5) | SLOWCOOR_TO_BB(F5) | \
1296 SLOWCOOR_TO_BB(G5) | SLOWCOOR_TO_BB(H5)
1299 SLOWCOOR_TO_BB(A4) | SLOWCOOR_TO_BB(B4) | SLOWCOOR_TO_BB(C4) | \
1300 SLOWCOOR_TO_BB(D4) | SLOWCOOR_TO_BB(E4) | SLOWCOOR_TO_BB(F4) | \
1301 SLOWCOOR_TO_BB(G4) | SLOWCOOR_TO_BB(H4)
1304 SLOWCOOR_TO_BB(A3) | SLOWCOOR_TO_BB(B3) | SLOWCOOR_TO_BB(C3) | \
1305 SLOWCOOR_TO_BB(D3) | SLOWCOOR_TO_BB(E3) | SLOWCOOR_TO_BB(F3) | \
1306 SLOWCOOR_TO_BB(G3) | SLOWCOOR_TO_BB(H3)
1309 SLOWCOOR_TO_BB(A2) | SLOWCOOR_TO_BB(B2) | SLOWCOOR_TO_BB(C2) | \
1310 SLOWCOOR_TO_BB(D2) | SLOWCOOR_TO_BB(E2) | SLOWCOOR_TO_BB(F2) | \
1311 SLOWCOOR_TO_BB(G2) | SLOWCOOR_TO_BB(H2)
1314 SLOWCOOR_TO_BB(A1) | SLOWCOOR_TO_BB(B1) | SLOWCOOR_TO_BB(C1) | \
1315 SLOWCOOR_TO_BB(D1) | SLOWCOOR_TO_BB(E1) | SLOWCOOR_TO_BB(F1) | \
1316 SLOWCOOR_TO_BB(G1) | SLOWCOOR_TO_BB(H1)
1319 SLOWCOOR_TO_BB(A1) | SLOWCOOR_TO_BB(A2) | SLOWCOOR_TO_BB(A3) | \
1320 SLOWCOOR_TO_BB(A4) | SLOWCOOR_TO_BB(A5) | SLOWCOOR_TO_BB(A6) | \
1321 SLOWCOOR_TO_BB(A7) | SLOWCOOR_TO_BB(A8)
1324 SLOWCOOR_TO_BB(B1) | SLOWCOOR_TO_BB(B2) | SLOWCOOR_TO_BB(B3) | \
1325 SLOWCOOR_TO_BB(B4) | SLOWCOOR_TO_BB(B5) | SLOWCOOR_TO_BB(B6) | \
1326 SLOWCOOR_TO_BB(B7) | SLOWCOOR_TO_BB(B8)
1329 SLOWCOOR_TO_BB(C1) | SLOWCOOR_TO_BB(C2) | SLOWCOOR_TO_BB(C3) | \
1330 SLOWCOOR_TO_BB(C4) | SLOWCOOR_TO_BB(C5) | SLOWCOOR_TO_BB(C6) | \
1331 SLOWCOOR_TO_BB(C7) | SLOWCOOR_TO_BB(C8)
1334 SLOWCOOR_TO_BB(D1) | SLOWCOOR_TO_BB(D2) | SLOWCOOR_TO_BB(D3) | \
1335 SLOWCOOR_TO_BB(D4) | SLOWCOOR_TO_BB(D5) | SLOWCOOR_TO_BB(D6) | \
1336 SLOWCOOR_TO_BB(D7) | SLOWCOOR_TO_BB(D8)
1339 SLOWCOOR_TO_BB(E1) | SLOWCOOR_TO_BB(E2) | SLOWCOOR_TO_BB(E3) | \
1340 SLOWCOOR_TO_BB(E4) | SLOWCOOR_TO_BB(E5) | SLOWCOOR_TO_BB(E6) | \
1341 SLOWCOOR_TO_BB(E7) | SLOWCOOR_TO_BB(E8)
1344 SLOWCOOR_TO_BB(F1) | SLOWCOOR_TO_BB(F2) | SLOWCOOR_TO_BB(F3) | \
1345 SLOWCOOR_TO_BB(F4) | SLOWCOOR_TO_BB(F5) | SLOWCOOR_TO_BB(F6) | \
1346 SLOWCOOR_TO_BB(F7) | SLOWCOOR_TO_BB(F8)
1349 SLOWCOOR_TO_BB(G1) | SLOWCOOR_TO_BB(G2) | SLOWCOOR_TO_BB(G3) | \
1350 SLOWCOOR_TO_BB(G4) | SLOWCOOR_TO_BB(G5) | SLOWCOOR_TO_BB(G6) | \
1351 SLOWCOOR_TO_BB(G7) | SLOWCOOR_TO_BB(G8)
1354 SLOWCOOR_TO_BB(H1) | SLOWCOOR_TO_BB(H2) | SLOWCOOR_TO_BB(H3) | \
1355 SLOWCOOR_TO_BB(H4) | SLOWCOOR_TO_BB(H5) | SLOWCOOR_TO_BB(H6) | \
1356 SLOWCOOR_TO_BB(H7) | SLOWCOOR_TO_BB(H8)
1359 BBRANK77 | BBRANK66 | BBRANK55 | BBRANK44 | BBRANK33 | BBRANK22
1362 BBRANK66 | BBRANK55 | BBRANK44 | BBRANK33 | BBRANK22
1365 BBRANK55 | BBRANK44 | BBRANK33 | BBRANK22
1368 BBRANK44 | BBRANK33 | BBRANK22
1374 BBRANK22 | BBRANK33 | BBRANK44 | BBRANK55 | BBRANK66 | BBRANK77
1377 BBRANK33 | BBRANK44 | BBRANK55 | BBRANK66 | BBRANK77
1380 BBRANK44 | BBRANK55 | BBRANK66 | BBRANK77
1383 BBRANK55 | BBRANK66 | BBRANK77
1394 #include <sys/types.h>
1395 #include <sys/stat.h>
1401 COMMAND(LearnPsqtFromPgn);
1403 COMMAND(GeneratePositionAndBestMoveSuite);
1406 WalkPV(SEARCHER_THREAD_CONTEXT *ctx);
1409 ReadNextGameFromPgnFile(FILE *pf);
1412 DistanceBetweenSquares(COOR a, COOR b);
1415 Trace(CHAR *szMessage, ...);
1418 Log(CHAR *szMessage, ...);
1421 Bug(CHAR *szMessage, ...);
1424 FindChunk(char *sz, ULONG uTargetChunk);
1427 BufferIsZeroed(BYTE *p, ULONG u);
1430 ColorToString(ULONG u);
1433 CoorToString(COOR c);
1436 ScoreToString(SCORE iScore);
1439 TimeToString(double d);
1442 AcquireSpinLock(volatile ULONG *pSpinlock);
1445 TryAcquireSpinLock(volatile ULONG *pSpinlock);
1448 ReleaseSpinLock(volatile ULONG *pSpinLock);
1451 Checksum(BYTE *p, ULONG uSize);
1454 BackupFile(CHAR *szFile);
1457 UtilPrintPV(SEARCHER_THREAD_CONTEXT *ctx,
1463 #define CANNOT_INITIALIZE_SPLIT (1)
1464 #define INCONSISTENT_POSITION (2)
1465 #define UNEXPECTED_SYSTEM_CALL_FAILURE (3)
1466 #define SHOULD_NOT_GET_HERE (4)
1467 #define GOT_ILLEGAL_MOVE_WHILE_PONDERING (5)
1468 #define CANNOT_OFFICIALLY_MAKE_MOVE (6)
1469 #define DETECTED_INCORRECT_INITIALIZATION (7)
1470 #define INCONSISTENT_STATE (8)
1471 #define FATAL_ACCESS_DENIED (9)
1472 #define TESTCASE_FAILURE (10)
1473 #define INITIALIZATION_FAILURE (11)
1476 UtilPanic(ULONG uPanicCode,
1481 char *file, ULONG line);
1487 #define LOGFILE_NAME "typhoon.log"
1488 extern FILE *g_pfLogfile;
1494 PreGameReset(FLAG fResetBoard);
1497 // system dependent exports (see win32.c or fbsd.c)
1499 typedef ULONG (THREAD_ENTRYPOINT)(ULONG);
1503 GetHeapMemoryUsage(void);
1507 SystemDebugBreakpoint(void);
1510 SystemStrDup(CHAR *p);
1513 SystemTimeStamp(void);
1516 SystemDoesFileExist(CHAR *szFilename);
1519 SystemDeferExecution(ULONG uMs);
1522 SystemFreeMemory(void *pMem);
1525 SystemAllocateMemory(ULONG dwSizeBytes);
1528 SystemMakeMemoryReadOnly(void *pMemory, ULONG dwSizeBytes);
1531 SystemMakeMemoryNoAccess(void *pMemory, ULONG dwSizeBytes);
1534 SystemMakeMemoryReadWrite(void *pMemory, ULONG dwSizeBytes);
1537 SystemDependentInitialization(void);
1540 SystemReadTimeStampCounter(void);
1543 // This routine _must_ implement a full memory fence -- it is used in
1544 // util.c to implement spinlocks.
1547 SystemCreateThread(THREAD_ENTRYPOINT *pEntry, ULONG uParam, ULONG *puHandle);
1550 SystemWaitForThreadToExit(ULONG uThreadHandle);
1553 SystemGetThreadExitCode(ULONG uThreadHandle, ULONG *puCode);
1556 SystemDeleteThread(ULONG uThreadHandle);
1559 SystemGetDateString(void);
1562 SystemGetTimeString(void);
1565 SystemCopyFile(CHAR *szSource, CHAR *szDest);
1568 SystemDeleteFile(CHAR *szFile);
1571 SystemCreateLock(void);
1574 SystemDeleteLock(ULONG u);
1577 SystemBlockingWaitForLock(ULONG u);
1580 SystemReleaseLock(ULONG u);
1583 SystemCreateSemaphore(ULONG u);
1586 SystemDeleteSemaphore(ULONG u);
1589 SystemReleaseSemaphoreResource(ULONG u);
1592 SystemObtainSemaphoreResource(ULONG u);
1598 #define STARTING_POSITION_IN_FEN \
1599 "rnbqkbnr/pppppppp/--------/8/8/--------/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
1602 LooksLikeFen(char *szFen);
1605 PositionToFen(POSITION *p);
1608 FenToPosition(POSITION *p, char *szFen);
1621 // INVERTED VALUE == (VALUE_QUEEN / VALUE_PIECE) * VALUE_PAWN;
1622 #define VALUE_PAWN 100
1623 #define INVERT_PAWN 900
1624 #define VALUE_KNIGHT 300
1625 #define INVERT_KNIGHT 300
1626 #define VALUE_BISHOP 300
1627 #define INVERT_BISHOP 300
1628 #define VALUE_ROOK 500
1629 #define INVERT_ROOK 180
1630 #define VALUE_QUEEN 975
1631 #define INVERT_QUEEN 100
1632 #define VALUE_KING (INFINITY)
1633 #define INVERT_KING 1
1635 #define VALUE_FULL_ARMY (8 * VALUE_PAWN) + (2 * VALUE_KNIGHT) + \
1636 (2 * VALUE_BISHOP) + (2 * VALUE_ROOK) + \
1637 VALUE_QUEEN + VALUE_KING
1638 #define VALUE_MAX_ARMY (9 * VALUE_QUEEN) + (2 * VALUE_KNIGHT) + \
1639 (2 * VALUE_BISHOP) + (2 * VALUE_ROOK) + \
1642 typedef struct _PIECE_DATA
1645 ULONG uValueOver100;
1646 ULONG uInvertedValue;
1650 extern PIECE_DATA g_PieceData[8];
1652 #define PIECE_VALUE_OVER_100(p) (g_PieceData[PIECE_TYPE(p)].uValueOver100)
1654 PieceValueOver100(PIECE p);
1656 #define PIECE_VALUE(p) (g_PieceData[PIECE_TYPE(p)].uValue)
1658 PieceValue(PIECE p);
1660 #define INVERTED_PIECE_VALUE(p) (g_PieceData[PIECE_TYPE(p)].uInvertedValue)
1662 PieceInvertedValue(PIECE p);
1665 PieceAbbrev(PIECE p);
1671 VerifyPositionConsistency(POSITION *pos, FLAG fContinueOnError);
1674 PositionsAreEquivalent(POSITION *p1, POSITION *p2);
1677 DrawTextBoardFromPosition(POSITION *pos);
1680 DumpPosition(POSITION *pos);
1683 CastleInfoString(BITV bv);
1686 SetRootToInitialPosition(void);
1692 SlidePiece(POSITION *pos, COOR cFrom, COOR cTo);
1695 LiftPiece(POSITION *pos, COOR cSquare);
1698 PlacePiece(POSITION *pos, COOR cSquare, PIECE pPiece);
1701 MakeMove(SEARCHER_THREAD_CONTEXT *ctx,
1705 UnmakeMove(SEARCHER_THREAD_CONTEXT *ctx,
1709 MakeUserMove(SEARCHER_THREAD_CONTEXT *ctx, MOVE mvUser);
1717 #define MOVE_TO_INDEX(mv) (((mv).uMove & 0xFFFF) + \
1718 (0x10000 * GET_COLOR(mv.pMoved)))
1721 FasterExposesCheck(POSITION *pos,
1726 ExposesCheck(POSITION *pos,
1731 ExposesCheckEp(POSITION *pos,
1738 IsAttacked(COOR cTest, POSITION *pos, ULONG uSide);
1741 InCheck(POSITION *pos, ULONG uSide);
1744 SanityCheckMove(POSITION *pos, MOVE mv);
1747 LooksLikeFile(CHAR c);
1750 LooksLikeRank(CHAR c);
1753 LooksLikeCoor(CHAR *szData);
1756 StripMove(CHAR *szMove);
1759 LooksLikeMove(CHAR *szData);
1762 SelectBestWithHistory(SEARCHER_THREAD_CONTEXT *ctx, ULONG u);
1765 SelectBestNoHistory(SEARCHER_THREAD_CONTEXT *ctx, ULONG u);
1768 SelectMoveAtRoot(SEARCHER_THREAD_CONTEXT *ctx, ULONG u);
1774 COMMAND(PerftCommand);
1782 TestLiftPlaceSlidePiece(void);
1785 TestExposesCheck(void);
1788 TestIsAttacked(void);
1791 TestMakeUnmakeMove(void);
1797 #define SORT_THESE_FIRST (0x40000000)
1798 #define FIRST_KILLER (0x20000000)
1799 #define SECOND_KILLER (0x10000000)
1800 #define THIRD_KILLER (0x08000000)
1801 #define FOURTH_KILLER (0x04000000)
1802 #define GOOD_MOVE (0x02000000)
1803 #define STRIP_OFF_FLAGS (0x00FFFFFF)
1805 extern const int g_iQKDeltas[9];
1806 extern const int g_iNDeltas[9];
1807 extern const int g_iBDeltas[5];
1808 extern const int g_iRDeltas[5];
1811 GenerateMoves(SEARCHER_THREAD_CONTEXT *ctx,
1816 WouldGiveCheck(IN SEARCHER_THREAD_CONTEXT *ctx,
1825 PlyTest(SEARCHER_THREAD_CONTEXT *ctx,
1827 FLAG fRootPositionInCheck);
1830 TestMoveGenerator(void);
1833 TestLegalMoveGenerator(void);
1840 extern UINT64 g_u64SigSeeds[128][7][2];
1841 extern UINT64 g_u64PawnSigSeeds[128][2];
1842 extern UINT64 g_u64CastleSigSeeds[16];
1843 extern UINT64 g_u64EpSigSeeds[9];
1846 InitializeSigSystem(void);
1849 ComputePawnSig(POSITION *pos);
1852 ComputeSig(POSITION *pos);
1858 seedMT(unsigned int seed);
1869 typedef struct _VECTOR_DELTA
1873 signed char iNegDelta;
1877 extern ULONG g_uDistance[256];
1878 extern ULONG *g_pDistance;
1879 extern VECTOR_DELTA g_VectorDelta[256];
1880 extern VECTOR_DELTA *g_pVectorDelta;
1881 extern CHAR g_SwapTable[14][32][32];
1882 extern SCORE _PSQT[14][128];
1883 extern ULONG g_uSearchSortLimits[];
1884 extern MOVE NULLMOVE;
1885 extern MOVE HASHMOVE;
1886 extern MOVE RECOGNMOVE;
1887 extern MOVE DRAWMOVE;
1888 extern MOVE MATEMOVE;
1889 extern FLAG g_fIsWhiteSquare[128];
1890 extern BITBOARD BBFILE[8];
1891 extern BITBOARD BBRANK[9];
1892 extern BITBOARD BBWHITESQ;
1893 extern BITBOARD BBBLACKSQ;
1894 extern BITBOARD BBLEFTSIDE;
1895 extern BITBOARD BBRIGHTSIDE;
1896 extern BITBOARD BBSQUARE[64];
1897 extern BITBOARD BBROOK_PAWNS;
1898 extern BITBOARD BBPRECEEDING_RANKS[8][2];
1899 extern BITBOARD BBADJACENT_FILES[8];
1900 extern BITBOARD BBADJACENT_RANKS[9];
1903 InitializeWhiteSquaresTable(void);
1906 InitializeVectorDeltaTable(void);
1909 InitializeSwapTable(void);
1912 InitializeDistanceTable(void);
1915 InitializeSearchDepthArray(void);
1918 GetSearchSortLimit(ULONG);
1921 #define SEARCH_SORT_LIMIT(x) (GetSearchSortLimit((x)))
1923 #define SEARCH_SORT_LIMIT(x) (g_uSearchSortLimits[(x)])
1927 ULONG CheckVectorWithIndex(int i, ULONG uColor);
1928 #define CHECK_VECTOR_WITH_INDEX(i, color) \
1929 CheckVectorWithIndex(i, color)
1931 int DirectionBetweenSquaresWithIndex(int i);
1932 #define CHECK_DELTA_WITH_INDEX(i) \
1933 DirectionBetweenSquaresWithIndex(i)
1935 int DirectionBetweenSquaresFromTo(COOR, COOR);
1936 #define DIRECTION_BETWEEN_SQUARES(from, to) \
1937 DirectionBetweenSquaresFromTo(from, to)
1939 int NegativeDirectionBetweenSquaresWithIndex(int i);
1940 #define NEG_DELTA_WITH_INDEX(i) \
1941 NegativeDirectionBetweenSquaresWithIndex(i)
1943 FLAG IsSquareWhite(COOR c);
1944 #define IS_SQUARE_WHITE(c) \
1948 #define CHECK_VECTOR_WITH_INDEX(i, color) \
1949 (g_pVectorDelta[(i)].iVector[(color)])
1951 #define CHECK_DELTA_WITH_INDEX(i) \
1952 (g_pVectorDelta[(i)].iDelta)
1954 #define DIRECTION_BETWEEN_SQUARES(cFrom, cTo) \
1955 CHECK_DELTA_WITH_INDEX((int)(cFrom) - (int)(cTo))
1957 #define NEG_DELTA_WITH_INDEX(i) \
1958 (g_pVectorDelta[(i)].iNegDelta)
1960 #define IS_SQUARE_WHITE(c) \
1961 (g_fIsWhiteSquare[(c)])
1968 ParseMoveSan(CHAR *szInput,
1972 MoveToSan(MOVE mv, POSITION *pos);
1984 InitializeListHead(IN DLIST_ENTRY *pListHead);
1987 IsListEmpty(IN DLIST_ENTRY *pListHead);
1990 RemoveEntryList(IN DLIST_ENTRY *pEntry);
1993 RemoveHeadList(IN DLIST_ENTRY *pListHead);
1996 RemoveTailList(IN DLIST_ENTRY *pListHead);
1999 InsertTailList(IN DLIST_ENTRY *pListHead,
2000 IN DLIST_ENTRY *pEntry);
2003 InsertHeadList(IN DLIST_ENTRY *pListHead,
2004 IN DLIST_ENTRY *pEntry);
2010 ParseUserInput(FLAG fSearching);
2013 InitializeCommandSystem(void);
2016 CleanupCommandSystem(void);
2022 InitInputSystemInBatchMode(void);
2025 InitInputSystemWithDedicatedThread(void);
2028 PushNewInput(CHAR *buf);
2031 PeekNextInput(void);
2034 ReadNextInput(void);
2037 BlockingReadInput(void);
2040 NumberOfPendingInputEvents(void);
2042 volatile extern FLAG g_fExitProgram;
2048 ParseMoveIcs(CHAR *szInput, POSITION *pos);
2062 typedef enum _ERESULT
2064 RESULT_BLACK_WON = -1,
2066 RESULT_WHITE_WON = 1,
2073 typedef struct _GAME_PLAYER
2076 CHAR *szDescription;
2082 typedef struct _GAME_HEADER
2084 CHAR *szGameDescription;
2086 GAME_PLAYER sPlayer[2];
2088 UINT64 u64OpeningSig;
2090 CHAR *szResultComment;
2095 typedef struct _GAME_MOVE
2104 CHAR *szUndoPositionFen;
2106 UINT64 u64PositionSigAfterMove;
2107 UINT64 u64PositionSigBeforeMove;
2108 volatile FLAG fInUse;
2112 typedef struct _GAME_DATA
2114 GAME_HEADER sHeader;
2115 DLIST_ENTRY sMoveList;
2119 extern GAME_DATA g_GameData;
2122 GetRootPosition(void);
2125 SetRootPosition(CHAR *szFen);
2128 ResetGameList(void);
2131 GetMoveNumber(ULONG uColor);
2134 SetGameResultAndDescription(ERESULT r, CHAR *sz);
2137 GetGameResult(void);
2143 SetOpponentsName(CHAR *sz);
2146 SetMyRating(ULONG u);
2149 SetOpponentsRating(ULONG u);
2155 TellGamelistThatIPlayColor(ULONG u);
2161 LoadPgn(CHAR *szPgn);
2164 CountOccurrancesOfSigInOfficialGameList(UINT64 u64Sig);
2167 DoesSigAppearInOfficialGameList(UINT64 u64Sig);
2170 OfficiallyTakebackMove(void);
2173 OfficiallyMakeMove(MOVE mv, SCORE iMoveScore, FLAG fFast);
2176 GetNthOfficialMoveRecord(ULONG n);
2179 MakeStatusLine(void);
2182 IsLegalDrawByRepetition(void);
2187 COMMAND(ScriptCommand);
2189 COMMAND(SolutionCommand);
2191 COMMAND(AvoidCommand);
2196 PostMoveTestSuiteReport(SEARCHER_THREAD_CONTEXT *);
2199 CheckTestSuiteMove(MOVE mv, SCORE iScore, ULONG uDepth);
2202 WeAreRunningASuite(void);
2208 COMMAND(SetCommand);
2213 extern ULONG g_uSoftExtendLimit;
2214 extern ULONG g_uHardExtendLimit;
2215 extern volatile MOVE_TIMER g_MoveTimer;
2216 extern ULONG g_uExtensionReduction[MAX_PLY_PER_SEARCH];
2218 #ifdef PERF_COUNTERS
2219 #define KEEP_TRACK_OF_FIRST_MOVE_FHs(x) \
2220 ctx->sCounters.tree.u64BetaCutoffs++; \
2223 ctx->sCounters.tree.u64BetaCutoffsOnFirstMove++;\
2226 #define KEEP_TRACK_OF_FIRST_MOVE_FHs(x)
2229 #define GAME_NOT_OVER 0
2230 #define GAME_WHITE_WON 1
2231 #define GAME_BLACK_WON 2
2232 #define GAME_DRAW_STALEMATE 3
2233 #define GAME_DRAW_REPETITION 4
2234 #define GAME_ONE_LEGAL_MOVE 5
2235 #define GAME_DRAW_FIFTY_MOVES_WO_PROGRESS 6
2238 Think(POSITION *pos);
2241 Ponder(POSITION *pos);
2244 Iterate(SEARCHER_THREAD_CONTEXT *ctx);
2247 SetMoveTimerForSearch(FLAG fSwitchOver, ULONG uColor);
2250 SetMoveTimerToThinkForever(void);
2253 ClearRootNodecountHash(void);
2259 IsDraw(SEARCHER_THREAD_CONTEXT *ctx);
2265 #define QPLIES_OF_NON_CAPTURE_CHECKS (1)
2266 #define FUTILITY_BASE_MARGIN (50) // + ctx->uPositional (min 100)
2268 #define IID_R_FACTOR (TWO_PLY + HALF_PLY)
2271 #define WE_SHOULD_STOP_SEARCHING (g_MoveTimer.bvFlags & TIMER_STOPPING)
2273 #define WE_SHOULD_STOP_SEARCHING ((g_MoveTimer.bvFlags & TIMER_STOPPING) || \
2274 (ThreadUnderTerminatingSplit(ctx)))
2278 QSearch(SEARCHER_THREAD_CONTEXT *ctx,
2283 Search(SEARCHER_THREAD_CONTEXT *ctx,
2293 ComputeMoveScore(IN SEARCHER_THREAD_CONTEXT *ctx,
2298 ThreadUnderTerminatingSplit(SEARCHER_THREAD_CONTEXT *);
2301 WeShouldDoHistoryPruning(IN SCORE iRoughEval,
2304 IN SEARCHER_THREAD_CONTEXT *ctx,
2305 IN ULONG uRemainingDepth,
2306 IN ULONG uLegalMoves,
2312 WeShouldTryNullmovePruning(IN SEARCHER_THREAD_CONTEXT *ctx,
2315 IN SCORE iRoughEval,
2316 IN ULONG uNullDepth);
2319 TryNullmovePruning(IN OUT SEARCHER_THREAD_CONTEXT *ctx,
2320 IN OUT FLAG *pfThreat,
2323 IN ULONG uNullDepth,
2324 IN OUT INT *piOrigExtend,
2325 OUT SCORE *piNullScore);
2328 UpdatePV(SEARCHER_THREAD_CONTEXT *ctx, MOVE mv);
2331 CheckInputAndTimers(IN SEARCHER_THREAD_CONTEXT *ctx);
2334 ComputeReactionToCheckExtension(IN OUT SEARCHER_THREAD_CONTEXT *ctx,
2337 IN SCORE iRoughEval,
2339 IN OUT INT *piExtend,
2340 IN OUT INT *piOrigExtend);
2343 ComputeMoveExtension(IN OUT SEARCHER_THREAD_CONTEXT *ctx,
2347 IN SCORE iRoughEval,
2349 IN OUT INT *piExtend);
2352 RescoreMovesViaSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
2358 MateDistancePruningCutoff(IN ULONG uPly,
2360 IN OUT SCORE *piBestScore,
2361 IN OUT SCORE *piAlpha,
2362 IN OUT SCORE *piBeta);
2365 CommonSearchInit(IN SEARCHER_THREAD_CONTEXT *ctx,
2366 IN OUT SCORE *piAlpha,
2367 IN OUT SCORE *piBeta,
2368 IN OUT SCORE *piScore);
2371 SelectNullmoveRFactor(IN SEARCHER_THREAD_CONTEXT *ctx,
2374 #define VERIFY_BEFORE (1)
2375 #define VERIFY_AFTER (2)
2378 SanityCheckMoves(IN SEARCHER_THREAD_CONTEXT *ctx,
2398 typedef struct _SEE_THREESOME
2405 typedef struct _SEE_LIST
2408 SEE_THREESOME data[16];
2413 ControlsSquareMinusPiece(ULONG uSide,
2422 DebugSEE(POSITION *pos,
2426 TestGetAttacks(void);
2431 #define NUM_HASH_ENTRIES_PER_LINE 4
2432 #define HASH_FLAG_EXACT 0x1
2433 #define HASH_FLAG_LOWER 0x2
2434 #define HASH_FLAG_UPPER 0x4
2435 #define HASH_FLAG_VALID_BOUNDS 0x7
2436 #define HASH_FLAG_THREAT 0x8
2437 #define HASH_FLAG_DIRTY 0xF0
2439 typedef struct _HASH_ENTRY
2443 UCHAR bvFlags; // 5 ==> d d d d | thr up low exact
2444 signed short iValue; // 6 7
2445 UINT64 u64Sig; // 8 9 A B C D E F == 16 bytes
2449 InitializeHashSystem(void);
2452 CleanupHashSystem(void);
2455 ClearHashTable(void);
2458 DirtyHashTable(void);
2461 StoreLowerBound(MOVE mvBestMove,
2467 StoreExactScore(MOVE mvBestMove,
2475 StoreUpperBound(//MOVE mvBestMove,
2482 HashLookup(SEARCHER_THREAD_CONTEXT *ctx,
2493 CheckHashForDangerSquare(POSITION *pos);
2496 GetPonderMove(POSITION *pos);
2498 extern ULONG g_uHashTableSizeEntries;
2499 extern ULONG g_uHashTableSizeBytes;
2500 extern HASH_ENTRY *g_pHashTable;
2506 AnalyzeFullHashTable(void);
2511 // IDEA: store "mate threat" flag in here?
2512 // IDEA: store "king safety" numbers in here?
2514 typedef struct _POSITION_HASH_ENTRY {
2517 UCHAR uEnpriseCount[2];
2519 } POSITION_HASH_ENTRY;
2522 InitializePositionHashSystem(void);
2525 CleanupPositionHashSystem(void);
2528 StoreEnprisePiece(POSITION *pos, COOR cSquare);
2531 StoreTrappedPiece(POSITION *pos, COOR cSquare);
2534 GetEnprisePiece(POSITION *pos, ULONG uSide);
2537 GetEnpriseCount(POSITION *pos, ULONG uSide);
2540 GetTrappedPiece(POSITION *pos, ULONG uSide);
2543 SideCanStandPat(POSITION *pos, ULONG uSide);
2546 ValueOfMaterialInTroubleDespiteMove(POSITION *pos, ULONG uSide);
2549 ValueOfMaterialInTroubleAfterNull(POSITION *pos, ULONG uSide);
2554 #define COOR_TO_BIT(x) ((x) & 0x7) + ((0x7 - ((x) >> 4)) << 3)
2557 ClearPawnHashStats(void);
2560 ReportPawnHashStats(void);
2563 PawnHashLookup(SEARCHER_THREAD_CONTEXT *ctx);
2569 #define LAZE_EVAL_BASE_SCORE 10
2570 extern const int g_iAhead[2];
2571 extern const int g_iBehind[2];
2574 DNABufferSizeBytes();
2580 WriteEvalDNA(char *szFilename);
2583 ImportEvalDNA(char *p);
2586 ReadEvalDNA(char *szFilename);
2591 Eval(SEARCHER_THREAD_CONTEXT *, SCORE, SCORE);
2594 EvalPasserRaces(POSITION *,
2598 CountKingSafetyDefects(POSITION *pos,
2609 EvalTraceReport(void);
2612 EvalTrace(ULONG uColor, PIECE p, COOR c, SCORE iVal, CHAR *szMessage);
2615 EvalSigmaForPiece(POSITION *pos, COOR c);
2618 EvalTraceClear(void);
2621 TestEvalWithSymmetry(void);
2623 #define EVAL_TERM(COL, PIE, COO, VAL, ADJ, MESS) \
2625 EvalTrace((COL), (PIE), (COO), (ADJ), (MESS));
2627 #define EVAL_TERM(COL, PIE, COO, VAL, ADJ, MESS) \
2635 InitializeBitboards(void);
2638 SlowCountBits(BITBOARD bb);
2641 DeBruijnFirstBit(BITBOARD bb);
2644 SlowFirstBit(BITBOARD bb);
2647 SlowLastBit(BITBOARD bb);
2650 CoorFromBitBoardRank8ToRank1(BITBOARD *pbb);
2653 CoorFromBitBoardRank1ToRank8(BITBOARD *pbb);
2659 CountBits(BITBOARD bb);
2662 FirstBit(BITBOARD bb);
2665 LastBit(BITBOARD bb);
2668 LockCompareExchange(volatile void *pDest,
2673 LockIncrement(volatile void *pDest);
2676 LockDecrement(volatile void *pDest);
2679 CanUseParallelOpcodes();
2682 ParallelCompareUlong(ULONG uComparand, void *pComparators);
2685 ParallelCompareVector(void *pComparand, void *pComparators);
2688 GetAttacks(SEE_LIST *pList,
2694 SlowGetAttacks(SEE_LIST *pList,
2701 // Note: this is most of the stuff that x86.asm assumes about the
2702 // internal data structures. If any of this fails then either the
2703 // assembly language code needs to be updated or you need to use the C
2704 // version of the routine in see.c instead.
2706 #define ASSERT_ASM_ASSUMPTIONS \
2707 ASSERT(VALUE_PAWN == 100); \
2708 ASSERT(OFFSET_OF(uCount, SEE_LIST) == 0); \
2709 ASSERT(OFFSET_OF(data, SEE_LIST) == 4); \
2710 ASSERT(sizeof(SEE_THREESOME) == 12); \
2711 ASSERT(OFFSET_OF(pPiece, SEE_THREESOME) == 0); \
2712 ASSERT(OFFSET_OF(cLoc, SEE_THREESOME) == 4); \
2713 ASSERT(OFFSET_OF(uVal, SEE_THREESOME) == 8); \
2714 ASSERT(OFFSET_OF(cNonPawns, POSITION) == 0x478); \
2715 ASSERT(OFFSET_OF(uNonPawnCount, POSITION) == 0x500); \
2716 ASSERT(OFFSET_OF(rgSquare, POSITION) == 0); \
2717 ASSERT(sizeof(SQUARE) == 8); \
2718 ASSERT(sizeof(VECTOR_DELTA) == 4); \
2719 ASSERT(sizeof(g_VectorDelta) == 256 * 4); \
2720 ASSERT(OFFSET_OF(iVector, VECTOR_DELTA) == 0); \
2721 ASSERT(OFFSET_OF(iDelta, VECTOR_DELTA) == 2); \
2722 ASSERT(OFFSET_OF(iNegDelta, VECTOR_DELTA) == 3); \
2723 ASSERT(sizeof(g_PieceData) == 8 * 4 * 4); \
2724 ASSERT(OFFSET_OF(uValue, PIECE_DATA) == 0);
2726 #define ASSERT_ASM_ASSUMPTIONS
2733 TestBitboards(void);
2738 extern ULONG g_HistoryCounters[14][128];
2741 GetMoveFailHighPercentage(MOVE mv);
2744 UpdateDynamicMoveOrdering(SEARCHER_THREAD_CONTEXT *ctx,
2745 ULONG uRemainingDepth,
2751 NewKillerMove(SEARCHER_THREAD_CONTEXT *ctx, MOVE mv, SCORE iScore);
2754 InitializeDynamicMoveOrdering(void);
2757 CleanupDynamicMoveOrdering(void);
2760 ClearDynamicMoveOrdering(void);
2763 MaintainDynamicMoveOrdering(void);
2766 IncrementMoveHistoryCounter(MOVE mv, ULONG u);
2769 DecrementMoveHistoryCounter(MOVE mv, ULONG u);
2774 extern volatile ULONG g_uNumHelpersAvailable;
2775 extern ULONG g_uNumHelperThreads;
2778 InitializeParallelSearch(void);
2781 CleanupParallelSearch(void);
2784 ClearHelperThreadIdleness(void);
2787 DumpHelperIdlenessReport(void);
2790 StartParallelSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
2791 IN OUT SCORE *piAlpha,
2793 IN OUT SCORE *piBestScore,
2794 IN OUT MOVE *pmvBest,
2796 IN INT iPositionExtend,
2800 InitializeSearcherContext(POSITION *pos, SEARCHER_THREAD_CONTEXT *ctx);
2803 ReInitializeSearcherContext(POSITION *pos, SEARCHER_THREAD_CONTEXT *ctx);
2806 InitializeLightweightSearcherContext(POSITION *pos,
2807 LIGHTWEIGHT_SEARCHER_CONTEXT *ctx);
2813 #define BOOK_PROBE_MISS_LIMIT (7)
2814 #define FLAG_DISABLED (1)
2815 #define FLAG_ALWAYSPLAY (2)
2816 #define FLAG_DELETED (4)
2818 #define BOOKMOVE_SELECT_MOVE (1)
2819 #define BOOKMOVE_DUMP (2)
2822 typedef struct _BOOK_ENTRY
2824 UINT64 u64Sig; // 8 bytes
2825 UINT64 u64NextSig; // 8 bytes
2826 MOVE mvNext; // 4 bytes
2827 ULONG uWins; // 4 bytes
2828 ULONG uDraws; // 4 bytes
2829 ULONG uLosses; // 4 bytes
2830 BITV bvFlags; // 4 bytes
2835 typedef struct _OPENING_NAME_MAPPING
2840 OPENING_NAME_MAPPING;
2842 #define BOOK_EDITING_RECORD "bkedit.edt"
2843 #define OPENING_LEARNING_FILENAME "bklearn.bin"
2845 typedef struct _OPENING_LEARNING_ENTRY
2852 OPENING_LEARNING_ENTRY;
2855 InitializeOpeningBook(void);
2858 ResetOpeningBook(void);
2861 CleanupOpeningBook(void);
2864 BookMove(POSITION *pos,
2867 COMMAND(BookCommand);
2869 extern ULONG g_uBookProbeFailures;
2870 extern FLAG g_fTournamentMode;
2871 extern CHAR *g_szBookName;
2876 COMMAND(BenchCommand);
2888 ProbeEGTB(SEARCHER_THREAD_CONTEXT *ctx, SCORE *score);
2891 InitializeEGTB(void);
2902 InitializeTreeDump(void);
2905 CleanupTreeDump(void);
2908 DTEnterNode(SEARCHER_THREAD_CONTEXT *ctx,
2915 DTLeaveNode(SEARCHER_THREAD_CONTEXT *ctx,
2921 DTTrace(ULONG uPly, CHAR *szMessage, ...);
2923 #define DTTRACE(...) DTTrace(ctx->uPly, __VA_ARGS__)
2927 #define DTTRACE(...)
2929 #define DTEnterNode(...)
2931 #define DTLeaveNode(...)
2933 #define InitializeTreeDump(...)
2935 #define CleanupTreeDump(...)
2943 IsBoardLegal(POSITION *pos);
2946 GenerateRandomLegalPosition(POSITION *pos);
2949 GenerateRandomLegalSymetricPosition(POSITION *pos);
2954 #define UNRECOGNIZED (0)
2955 #define RECOGN_EXACT (1)
2956 #define RECOGN_UPPER (2)
2957 #define RECOGN_LOWER (3)
2958 #define RECOGN_EGTB (4)
2961 InitializeInteriorNodeRecognizers(void);
2964 RecognLookup(SEARCHER_THREAD_CONTEXT *ctx,
2970 ClearEvalHashStats(void);
2973 ReportEvalHashStats(void);
2976 ProbeEvalHash(SEARCHER_THREAD_CONTEXT *ctx);
2979 GetRoughEvalScore(IN SEARCHER_THREAD_CONTEXT *ctx,
2985 StoreEvalHash(SEARCHER_THREAD_CONTEXT *ctx, SCORE iScore);