3 Copyright (c) Scott Gasch
17 $Id: chess.h 354 2008-06-30 05:10:08Z 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 354 2008-06-30 05:10:08Z 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;
1038 UINT64 u64MaxNodeCount;
1042 FLAG fSuccessfulPonder;
1045 FLAG fForceDrawWorthZero;
1047 ULONG uMovesPerTimePeriod;
1048 CHAR szAnalyzeProgressReport[SMALL_STRING_LEN_CHAR];
1049 FLAG fShouldAnnounceOpening;
1050 SCORE iLastEvalScore;
1051 UINT64 u64NodesSearched;
1052 CHAR szLogfile[SMALL_STRING_LEN_CHAR];
1053 CHAR szEGTBPath[SMALL_STRING_LEN_CHAR];
1054 CHAR szBookName[SMALL_STRING_LEN_CHAR];
1055 ULONG uNumProcessors;
1056 ULONG uNumHashTableEntries;
1057 FLAG fNoInputThread;
1058 FLAG fVerbosePosting;
1059 FLAG fRunningUnderXboard;
1062 INT iResignThreshold;
1093 extern GAME_OPTIONS g_Options;
1095 // ----------------------------------------------------------------------
1100 #define TIMER_SEARCHING_FIRST_MOVE (0x1)
1101 #define TIMER_SEARCHING_IMPORTANT_MOVE (0x2)
1102 #define TIMER_RESOLVING_ROOT_FL (0x4)
1103 #define TIMER_RESOLVING_ROOT_FH (0x8)
1104 #define TIMER_JUST_OUT_OF_BOOK (0x10)
1105 #define TIMER_CURRENT_OBVIOUS (0x20)
1106 #define TIMER_CURRENT_WONT_UNBLOCK (0x40)
1107 #define TIMER_ROOT_POSITION_CRITICAL (0x80)
1108 #define TIMER_MOVE_IMMEDIATELY (0x100)
1109 #define TIMER_MANY_ROOT_FLS (0x200)
1110 #define TIMER_STOPPING (0x400)
1111 #define TIMER_SPLIT_FAILED (0x800)
1113 typedef struct _MOVE_TIMER
1117 double dSoftTimeLimit;
1118 double dHardTimeLimit;
1119 ULONG uNodeCheckMask;
1120 volatile BITV bvFlags;
1124 // ----------------------------------------------------------------------
1126 // Special move tag literals
1128 #define ILLEGALMOVE ((ULONG)0x1DDD8888)
1135 _assert(CHAR *szFile, ULONG uLine);
1137 #define ASSERT(x) if (x) \
1140 { _assert(__FILE__, __LINE__); }
1141 #define VERIFY(x) ASSERT(x)
1144 #define VERIFY(x) x;
1147 #ifdef PERF_COUNTERS
1148 #define INC(x) ((x) += 1)
1153 #define BREAKPOINT SystemDebugBreakpoint()
1155 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
1156 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
1160 // Note: MAXU, MINU and ABS_DIFF require arguments with the high order
1161 // bit CLEAR to work right.
1163 // These are branchless constructs. MAXU and MINU are equivalent to
1164 // MIN and MAX (with the above restriction on inputs)
1166 // MIN0 and MAX0 are equivalent to MAX(0, x) and MIN(0, x). These
1167 // macros have no restiction on argument type.
1169 // ABS_DIFF is equivalent to abs(x - y). Again, x and y must have
1170 // their high-order bits CLEAR for this to work.
1172 // Note: gcc generates code with cmovs so no need for MAXU/MINU on
1175 #define MINU(x, y) \
1176 (((((int)((x)-(y)))>>31) & ((x)-(y)))+(y))
1177 #define MAXU(x, y) \
1178 (((((int)((x)-(y)))>>31) & ((y)-(x)))+(x))
1180 ((x) & (((int)(x)) >> 31))
1182 ((x) & ~(((int)(x)) >> 31))
1185 #define ABS_DIFF(a, b) \
1186 (((b)-(a)) - ((((b) - (a)) & (((int)((b) - (a))) >> 31) ) << 1))
1191 #define MINU(x, y) (MIN((x), (y)))
1195 #define MAXU(x, y) (MAX((x), (y)))
1199 #define MIN0(x) (MIN((x), 0))
1203 #define MAX0(x) (MAX((x), 0))
1207 #define ABS_DIFF(a, b) (abs((a) - (b)))
1210 #define FILE_DISTANCE(a, b) (ABS_DIFF(FILE((a)), FILE((b))))
1211 #define RANK_DISTANCE(a, b) (ABS_DIFF(((a) & 0xF0), ((b) & 0xF0)) >> 4)
1212 #define REAL_DISTANCE(a, b) (MAXU(FILE_DISTANCE((a), (b)), \
1213 RANK_DISTANCE((a), (b))))
1215 #define DISTANCE(a, b) DistanceBetweenSquares((a), (b))
1217 #define DISTANCE(a, b) g_pDistance[(a) - (b)]
1220 #define IS_EMPTY( square ) (!(square))
1221 #define IS_OCCUPIED( square ) ((square))
1223 #define IS_DEAD( listindex ) ((listindex) > 119)
1224 #define IS_ALIVE( listindex ) ((listindex) <= 119)
1225 #define ILLEGAL_COOR (0x88)
1226 #define EDGE_DISTANCE(c) (MIN(MIN(abs(RANK(c) - 7), RANK(c)), \
1227 MIN(abs(FILE(c) - 7), FILE(c))))
1228 #define NOT_ON_EDGE(c) ((((c) & 0xF0) != 0x00) && \
1229 (((c) & 0xF0) != 0x70) && \
1230 (((c) & 0x0F) != 0x00) && \
1231 (((c) & 0x0F) != 0x07))
1232 #define ON_EDGE(c) (RANK8(c) || \
1236 #define CORNER_DISTANCE(c) (MAX(MIN((ULONG)abs(RANK(c) - 7), RANK(c)),\
1237 MIN((ULONG)abs(FILE(c) - 7), FILE(c))))
1238 #define IN_CORNER(c) (((c) == A8) || \
1242 #define WHITE_CORNER_DISTANCE(c) (MIN(DISTANCE((c), A8), \
1244 #define BLACK_CORNER_DISTANCE(c) (MIN(DISTANCE((c), H8), \
1246 #define SYM_SQ(c) ((7 - (((c) & 0xF0) >> 4)) << 4) \
1247 | (7 - ((c) & 0x0F))
1248 #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a[0])))
1249 #define MAKE_PSQT(a, b, c, d) (((a) << 24) | ((b) << 16) | \
1251 #define TO64(x) ((x) & 0x7) + ((0x7 - ((x)>>4)) << 3)
1252 #define COOR_TO_BIT_NUMBER(c) (((((c) & 0x70) >> 1) | ((c) & 0x7)))
1253 #define SLOWCOOR_TO_BB(c) (1ULL << COOR_TO_BIT_NUMBER(c))
1254 #define COOR_TO_BB(c) (BBSQUARE[COOR_TO_BIT_NUMBER(c)])
1255 #define SLOW_BIT_NUMBER_TO_COOR(b) ((((b) / 8) << 4) + ((b) & 7))
1256 #define BIT_NUMBER_TO_COOR(b) ((((b) & 0xF8) << 1) | ((b) & 7))
1259 SLOWCOOR_TO_BB(A8) | SLOWCOOR_TO_BB(B8) | SLOWCOOR_TO_BB(C8) | \
1260 SLOWCOOR_TO_BB(D8) | SLOWCOOR_TO_BB(E8) | SLOWCOOR_TO_BB(F8) | \
1261 SLOWCOOR_TO_BB(G8) | SLOWCOOR_TO_BB(H8)
1264 SLOWCOOR_TO_BB(A7) | SLOWCOOR_TO_BB(B7) | SLOWCOOR_TO_BB(C7) | \
1265 SLOWCOOR_TO_BB(D7) | SLOWCOOR_TO_BB(E7) | SLOWCOOR_TO_BB(F7) | \
1266 SLOWCOOR_TO_BB(G7) | SLOWCOOR_TO_BB(H7)
1269 SLOWCOOR_TO_BB(A6) | SLOWCOOR_TO_BB(B6) | SLOWCOOR_TO_BB(C6) | \
1270 SLOWCOOR_TO_BB(D6) | SLOWCOOR_TO_BB(E6) | SLOWCOOR_TO_BB(F6) | \
1271 SLOWCOOR_TO_BB(G6) | SLOWCOOR_TO_BB(H6)
1274 SLOWCOOR_TO_BB(A5) | SLOWCOOR_TO_BB(B5) | SLOWCOOR_TO_BB(C5) | \
1275 SLOWCOOR_TO_BB(D5) | SLOWCOOR_TO_BB(E5) | SLOWCOOR_TO_BB(F5) | \
1276 SLOWCOOR_TO_BB(G5) | SLOWCOOR_TO_BB(H5)
1279 SLOWCOOR_TO_BB(A4) | SLOWCOOR_TO_BB(B4) | SLOWCOOR_TO_BB(C4) | \
1280 SLOWCOOR_TO_BB(D4) | SLOWCOOR_TO_BB(E4) | SLOWCOOR_TO_BB(F4) | \
1281 SLOWCOOR_TO_BB(G4) | SLOWCOOR_TO_BB(H4)
1284 SLOWCOOR_TO_BB(A3) | SLOWCOOR_TO_BB(B3) | SLOWCOOR_TO_BB(C3) | \
1285 SLOWCOOR_TO_BB(D3) | SLOWCOOR_TO_BB(E3) | SLOWCOOR_TO_BB(F3) | \
1286 SLOWCOOR_TO_BB(G3) | SLOWCOOR_TO_BB(H3)
1289 SLOWCOOR_TO_BB(A2) | SLOWCOOR_TO_BB(B2) | SLOWCOOR_TO_BB(C2) | \
1290 SLOWCOOR_TO_BB(D2) | SLOWCOOR_TO_BB(E2) | SLOWCOOR_TO_BB(F2) | \
1291 SLOWCOOR_TO_BB(G2) | SLOWCOOR_TO_BB(H2)
1294 SLOWCOOR_TO_BB(A1) | SLOWCOOR_TO_BB(B1) | SLOWCOOR_TO_BB(C1) | \
1295 SLOWCOOR_TO_BB(D1) | SLOWCOOR_TO_BB(E1) | SLOWCOOR_TO_BB(F1) | \
1296 SLOWCOOR_TO_BB(G1) | SLOWCOOR_TO_BB(H1)
1299 SLOWCOOR_TO_BB(A1) | SLOWCOOR_TO_BB(A2) | SLOWCOOR_TO_BB(A3) | \
1300 SLOWCOOR_TO_BB(A4) | SLOWCOOR_TO_BB(A5) | SLOWCOOR_TO_BB(A6) | \
1301 SLOWCOOR_TO_BB(A7) | SLOWCOOR_TO_BB(A8)
1304 SLOWCOOR_TO_BB(B1) | SLOWCOOR_TO_BB(B2) | SLOWCOOR_TO_BB(B3) | \
1305 SLOWCOOR_TO_BB(B4) | SLOWCOOR_TO_BB(B5) | SLOWCOOR_TO_BB(B6) | \
1306 SLOWCOOR_TO_BB(B7) | SLOWCOOR_TO_BB(B8)
1309 SLOWCOOR_TO_BB(C1) | SLOWCOOR_TO_BB(C2) | SLOWCOOR_TO_BB(C3) | \
1310 SLOWCOOR_TO_BB(C4) | SLOWCOOR_TO_BB(C5) | SLOWCOOR_TO_BB(C6) | \
1311 SLOWCOOR_TO_BB(C7) | SLOWCOOR_TO_BB(C8)
1314 SLOWCOOR_TO_BB(D1) | SLOWCOOR_TO_BB(D2) | SLOWCOOR_TO_BB(D3) | \
1315 SLOWCOOR_TO_BB(D4) | SLOWCOOR_TO_BB(D5) | SLOWCOOR_TO_BB(D6) | \
1316 SLOWCOOR_TO_BB(D7) | SLOWCOOR_TO_BB(D8)
1319 SLOWCOOR_TO_BB(E1) | SLOWCOOR_TO_BB(E2) | SLOWCOOR_TO_BB(E3) | \
1320 SLOWCOOR_TO_BB(E4) | SLOWCOOR_TO_BB(E5) | SLOWCOOR_TO_BB(E6) | \
1321 SLOWCOOR_TO_BB(E7) | SLOWCOOR_TO_BB(E8)
1324 SLOWCOOR_TO_BB(F1) | SLOWCOOR_TO_BB(F2) | SLOWCOOR_TO_BB(F3) | \
1325 SLOWCOOR_TO_BB(F4) | SLOWCOOR_TO_BB(F5) | SLOWCOOR_TO_BB(F6) | \
1326 SLOWCOOR_TO_BB(F7) | SLOWCOOR_TO_BB(F8)
1329 SLOWCOOR_TO_BB(G1) | SLOWCOOR_TO_BB(G2) | SLOWCOOR_TO_BB(G3) | \
1330 SLOWCOOR_TO_BB(G4) | SLOWCOOR_TO_BB(G5) | SLOWCOOR_TO_BB(G6) | \
1331 SLOWCOOR_TO_BB(G7) | SLOWCOOR_TO_BB(G8)
1334 SLOWCOOR_TO_BB(H1) | SLOWCOOR_TO_BB(H2) | SLOWCOOR_TO_BB(H3) | \
1335 SLOWCOOR_TO_BB(H4) | SLOWCOOR_TO_BB(H5) | SLOWCOOR_TO_BB(H6) | \
1336 SLOWCOOR_TO_BB(H7) | SLOWCOOR_TO_BB(H8)
1339 BBRANK77 | BBRANK66 | BBRANK55 | BBRANK44 | BBRANK33 | BBRANK22
1342 BBRANK66 | BBRANK55 | BBRANK44 | BBRANK33 | BBRANK22
1345 BBRANK55 | BBRANK44 | BBRANK33 | BBRANK22
1348 BBRANK44 | BBRANK33 | BBRANK22
1354 BBRANK22 | BBRANK33 | BBRANK44 | BBRANK55 | BBRANK66 | BBRANK77
1357 BBRANK33 | BBRANK44 | BBRANK55 | BBRANK66 | BBRANK77
1360 BBRANK44 | BBRANK55 | BBRANK66 | BBRANK77
1363 BBRANK55 | BBRANK66 | BBRANK77
1374 #include <sys/types.h>
1375 #include <sys/stat.h>
1381 COMMAND(LearnPsqtFromPgn);
1383 COMMAND(GeneratePositionAndBestMoveSuite);
1386 WalkPV(SEARCHER_THREAD_CONTEXT *ctx);
1389 ReadNextGameFromPgnFile(FILE *pf);
1392 DistanceBetweenSquares(COOR a, COOR b);
1395 Trace(CHAR *szMessage, ...);
1398 Log(CHAR *szMessage, ...);
1401 Bug(CHAR *szMessage, ...);
1404 FindChunk(char *sz, ULONG uTargetChunk);
1407 BufferIsZeroed(BYTE *p, ULONG u);
1410 ColorToString(ULONG u);
1413 CoorToString(COOR c);
1416 ScoreToString(SCORE iScore);
1419 TimeToString(double d);
1422 AcquireSpinLock(volatile ULONG *pSpinlock);
1425 TryAcquireSpinLock(volatile ULONG *pSpinlock);
1428 ReleaseSpinLock(volatile ULONG *pSpinLock);
1431 Checksum(BYTE *p, ULONG uSize);
1434 BackupFile(CHAR *szFile);
1437 UtilPrintPV(SEARCHER_THREAD_CONTEXT *ctx,
1443 #define CANNOT_INITIALIZE_SPLIT (1)
1444 #define INCONSISTENT_POSITION (2)
1445 #define UNEXPECTED_SYSTEM_CALL_FAILURE (3)
1446 #define SHOULD_NOT_GET_HERE (4)
1447 #define GOT_ILLEGAL_MOVE_WHILE_PONDERING (5)
1448 #define CANNOT_OFFICIALLY_MAKE_MOVE (6)
1449 #define DETECTED_INCORRECT_INITIALIZATION (7)
1450 #define INCONSISTENT_STATE (8)
1451 #define FATAL_ACCESS_DENIED (9)
1452 #define TESTCASE_FAILURE (10)
1453 #define INITIALIZATION_FAILURE (11)
1456 UtilPanic(ULONG uPanicCode,
1461 char *file, ULONG line);
1467 #define LOGFILE_NAME "typhoon.log"
1468 extern FILE *g_pfLogfile;
1474 PreGameReset(FLAG fResetBoard);
1477 // system dependent exports (see win32.c or fbsd.c)
1479 typedef ULONG (THREAD_ENTRYPOINT)(ULONG);
1483 GetHeapMemoryUsage(void);
1487 SystemDebugBreakpoint(void);
1490 SystemStrDup(CHAR *p);
1493 SystemTimeStamp(void);
1496 SystemDoesFileExist(CHAR *szFilename);
1499 SystemDeferExecution(ULONG uMs);
1502 SystemFreeMemory(void *pMem);
1505 SystemAllocateMemory(ULONG dwSizeBytes);
1508 SystemMakeMemoryReadOnly(void *pMemory, ULONG dwSizeBytes);
1511 SystemMakeMemoryNoAccess(void *pMemory, ULONG dwSizeBytes);
1514 SystemMakeMemoryReadWrite(void *pMemory, ULONG dwSizeBytes);
1517 SystemDependentInitialization(void);
1520 SystemReadTimeStampCounter(void);
1523 // This routine _must_ implement a full memory fence -- it is used in
1524 // util.c to implement spinlocks.
1527 SystemCreateThread(THREAD_ENTRYPOINT *pEntry, ULONG uParam, ULONG *puHandle);
1530 SystemWaitForThreadToExit(ULONG uThreadHandle);
1533 SystemGetThreadExitCode(ULONG uThreadHandle, ULONG *puCode);
1536 SystemDeleteThread(ULONG uThreadHandle);
1539 SystemGetDateString(void);
1542 SystemGetTimeString(void);
1545 SystemCopyFile(CHAR *szSource, CHAR *szDest);
1548 SystemDeleteFile(CHAR *szFile);
1551 SystemCreateLock(void);
1554 SystemDeleteLock(ULONG u);
1557 SystemBlockingWaitForLock(ULONG u);
1560 SystemReleaseLock(ULONG u);
1563 SystemCreateSemaphore(ULONG u);
1566 SystemDeleteSemaphore(ULONG u);
1569 SystemReleaseSemaphoreResource(ULONG u);
1572 SystemObtainSemaphoreResource(ULONG u);
1578 #define STARTING_POSITION_IN_FEN \
1579 "rnbqkbnr/pppppppp/--------/8/8/--------/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
1582 LooksLikeFen(char *szFen);
1585 PositionToFen(POSITION *p);
1588 FenToPosition(POSITION *p, char *szFen);
1601 // INVERTED VALUE == (VALUE_QUEEN / VALUE_PIECE) * VALUE_PAWN;
1602 #define VALUE_PAWN 100
1603 #define INVERT_PAWN 900
1604 #define VALUE_KNIGHT 300
1605 #define INVERT_KNIGHT 300
1606 #define VALUE_BISHOP 300
1607 #define INVERT_BISHOP 300
1608 #define VALUE_ROOK 500
1609 #define INVERT_ROOK 180
1610 #define VALUE_QUEEN 975
1611 #define INVERT_QUEEN 100
1612 #define VALUE_KING (INFINITY)
1613 #define INVERT_KING 1
1615 #define VALUE_FULL_ARMY (8 * VALUE_PAWN) + (2 * VALUE_KNIGHT) + \
1616 (2 * VALUE_BISHOP) + (2 * VALUE_ROOK) + \
1617 VALUE_QUEEN + VALUE_KING
1618 #define VALUE_MAX_ARMY (9 * VALUE_QUEEN) + (2 * VALUE_KNIGHT) + \
1619 (2 * VALUE_BISHOP) + (2 * VALUE_ROOK) + \
1622 typedef struct _PIECE_DATA
1625 ULONG uValueOver100;
1626 ULONG uInvertedValue;
1630 extern PIECE_DATA g_PieceData[8];
1632 #define PIECE_VALUE_OVER_100(p) (g_PieceData[PIECE_TYPE(p)].uValueOver100)
1634 PieceValueOver100(PIECE p);
1636 #define PIECE_VALUE(p) (g_PieceData[PIECE_TYPE(p)].uValue)
1638 PieceValue(PIECE p);
1640 #define INVERTED_PIECE_VALUE(p) (g_PieceData[PIECE_TYPE(p)].uInvertedValue)
1642 PieceInvertedValue(PIECE p);
1645 PieceAbbrev(PIECE p);
1651 VerifyPositionConsistency(POSITION *pos, FLAG fContinueOnError);
1654 PositionsAreEquivalent(POSITION *p1, POSITION *p2);
1657 DrawTextBoardFromPosition(POSITION *pos);
1660 DumpPosition(POSITION *pos);
1663 CastleInfoString(BITV bv);
1666 SetRootToInitialPosition(void);
1672 SlidePiece(POSITION *pos, COOR cFrom, COOR cTo);
1675 LiftPiece(POSITION *pos, COOR cSquare);
1678 PlacePiece(POSITION *pos, COOR cSquare, PIECE pPiece);
1681 MakeMove(SEARCHER_THREAD_CONTEXT *ctx,
1685 UnmakeMove(SEARCHER_THREAD_CONTEXT *ctx,
1689 MakeUserMove(SEARCHER_THREAD_CONTEXT *ctx, MOVE mvUser);
1697 #define MOVE_TO_INDEX(mv) (((mv).uMove & 0xFFFF) + \
1698 (0x10000 * GET_COLOR(mv.pMoved)))
1701 FasterExposesCheck(POSITION *pos,
1706 ExposesCheck(POSITION *pos,
1711 ExposesCheckEp(POSITION *pos,
1718 IsAttacked(COOR cTest, POSITION *pos, ULONG uSide);
1721 InCheck(POSITION *pos, ULONG uSide);
1724 SanityCheckMove(POSITION *pos, MOVE mv);
1727 LooksLikeFile(CHAR c);
1730 LooksLikeRank(CHAR c);
1733 LooksLikeCoor(CHAR *szData);
1736 StripMove(CHAR *szMove);
1739 LooksLikeMove(CHAR *szData);
1742 SelectBestWithHistory(SEARCHER_THREAD_CONTEXT *ctx, ULONG u);
1745 SelectBestNoHistory(SEARCHER_THREAD_CONTEXT *ctx, ULONG u);
1748 SelectMoveAtRoot(SEARCHER_THREAD_CONTEXT *ctx, ULONG u);
1754 COMMAND(PerftCommand);
1762 TestLiftPlaceSlidePiece(void);
1765 TestExposesCheck(void);
1768 TestIsAttacked(void);
1771 TestMakeUnmakeMove(void);
1777 #define SORT_THESE_FIRST (0x40000000)
1778 #define FIRST_KILLER (0x20000000)
1779 #define SECOND_KILLER (0x10000000)
1780 #define THIRD_KILLER (0x08000000)
1781 #define FOURTH_KILLER (0x04000000)
1782 #define GOOD_MOVE (0x02000000)
1783 #define STRIP_OFF_FLAGS (0x00FFFFFF)
1785 extern const int g_iQKDeltas[9];
1786 extern const int g_iNDeltas[9];
1787 extern const int g_iBDeltas[5];
1788 extern const int g_iRDeltas[5];
1791 GenerateMoves(SEARCHER_THREAD_CONTEXT *ctx,
1796 WouldGiveCheck(IN SEARCHER_THREAD_CONTEXT *ctx,
1805 PlyTest(SEARCHER_THREAD_CONTEXT *ctx,
1807 FLAG fRootPositionInCheck);
1810 TestMoveGenerator(void);
1813 TestLegalMoveGenerator(void);
1820 extern UINT64 g_u64SigSeeds[128][7][2];
1821 extern UINT64 g_u64PawnSigSeeds[128][2];
1822 extern UINT64 g_u64CastleSigSeeds[16];
1823 extern UINT64 g_u64EpSigSeeds[9];
1826 InitializeSigSystem(void);
1829 ComputePawnSig(POSITION *pos);
1832 ComputeSig(POSITION *pos);
1838 seedMT(unsigned int seed);
1849 typedef struct _VECTOR_DELTA
1853 signed char iNegDelta;
1857 extern ULONG g_uDistance[256];
1858 extern ULONG *g_pDistance;
1859 extern VECTOR_DELTA g_VectorDelta[256];
1860 extern VECTOR_DELTA *g_pVectorDelta;
1861 extern CHAR g_SwapTable[14][32][32];
1862 extern SCORE _PSQT[14][128];
1863 extern ULONG g_uSearchSortLimits[];
1864 extern MOVE NULLMOVE;
1865 extern MOVE HASHMOVE;
1866 extern MOVE RECOGNMOVE;
1867 extern MOVE DRAWMOVE;
1868 extern MOVE MATEMOVE;
1869 extern FLAG g_fIsWhiteSquare[128];
1870 extern BITBOARD BBFILE[8];
1871 extern BITBOARD BBRANK[9];
1872 extern BITBOARD BBWHITESQ;
1873 extern BITBOARD BBBLACKSQ;
1874 extern BITBOARD BBLEFTSIDE;
1875 extern BITBOARD BBRIGHTSIDE;
1876 extern BITBOARD BBSQUARE[64];
1877 extern BITBOARD BBROOK_PAWNS;
1878 extern BITBOARD BBPRECEEDING_RANKS[8][2];
1879 extern BITBOARD BBADJACENT_FILES[8];
1880 extern BITBOARD BBADJACENT_RANKS[9];
1883 InitializeWhiteSquaresTable(void);
1886 InitializeVectorDeltaTable(void);
1889 InitializeSwapTable(void);
1892 InitializeDistanceTable(void);
1895 InitializeSearchDepthArray(void);
1898 GetSearchSortLimit(ULONG);
1901 #define SEARCH_SORT_LIMIT(x) (GetSearchSortLimit((x)))
1903 #define SEARCH_SORT_LIMIT(x) (g_uSearchSortLimits[(x)])
1907 ULONG CheckVectorWithIndex(int i, ULONG uColor);
1908 #define CHECK_VECTOR_WITH_INDEX(i, color) \
1909 CheckVectorWithIndex(i, color)
1911 int DirectionBetweenSquaresWithIndex(int i);
1912 #define CHECK_DELTA_WITH_INDEX(i) \
1913 DirectionBetweenSquaresWithIndex(i)
1915 int DirectionBetweenSquaresFromTo(COOR, COOR);
1916 #define DIRECTION_BETWEEN_SQUARES(from, to) \
1917 DirectionBetweenSquaresFromTo(from, to)
1919 int NegativeDirectionBetweenSquaresWithIndex(int i);
1920 #define NEG_DELTA_WITH_INDEX(i) \
1921 NegativeDirectionBetweenSquaresWithIndex(i)
1923 FLAG IsSquareWhite(COOR c);
1924 #define IS_SQUARE_WHITE(c) \
1928 #define CHECK_VECTOR_WITH_INDEX(i, color) \
1929 (g_pVectorDelta[(i)].iVector[(color)])
1931 #define CHECK_DELTA_WITH_INDEX(i) \
1932 (g_pVectorDelta[(i)].iDelta)
1934 #define DIRECTION_BETWEEN_SQUARES(cFrom, cTo) \
1935 CHECK_DELTA_WITH_INDEX((int)(cFrom) - (int)(cTo))
1937 #define NEG_DELTA_WITH_INDEX(i) \
1938 (g_pVectorDelta[(i)].iNegDelta)
1940 #define IS_SQUARE_WHITE(c) \
1941 (g_fIsWhiteSquare[(c)])
1948 ParseMoveSan(CHAR *szInput,
1952 MoveToSan(MOVE mv, POSITION *pos);
1964 InitializeListHead(IN DLIST_ENTRY *pListHead);
1967 IsListEmpty(IN DLIST_ENTRY *pListHead);
1970 RemoveEntryList(IN DLIST_ENTRY *pEntry);
1973 RemoveHeadList(IN DLIST_ENTRY *pListHead);
1976 RemoveTailList(IN DLIST_ENTRY *pListHead);
1979 InsertTailList(IN DLIST_ENTRY *pListHead,
1980 IN DLIST_ENTRY *pEntry);
1983 InsertHeadList(IN DLIST_ENTRY *pListHead,
1984 IN DLIST_ENTRY *pEntry);
1990 ParseUserInput(FLAG fSearching);
1993 InitializeCommandSystem(void);
1996 CleanupCommandSystem(void);
2002 InitInputSystemInBatchMode(void);
2005 InitInputSystemWithDedicatedThread(void);
2008 PushNewInput(CHAR *buf);
2011 PeekNextInput(void);
2014 ReadNextInput(void);
2017 BlockingReadInput(void);
2020 NumberOfPendingInputEvents(void);
2022 volatile extern FLAG g_fExitProgram;
2028 ParseMoveIcs(CHAR *szInput, POSITION *pos);
2042 typedef enum _ERESULT
2044 RESULT_BLACK_WON = -1,
2046 RESULT_WHITE_WON = 1,
2052 typedef struct _GAME_RESULT
2055 CHAR szDescription[256];
2058 typedef struct _GAME_PLAYER
2061 CHAR *szDescription;
2067 typedef struct _GAME_HEADER
2069 CHAR *szGameDescription;
2071 GAME_PLAYER sPlayer[2];
2073 UINT64 u64OpeningSig;
2079 typedef struct _GAME_MOVE
2088 CHAR *szUndoPositionFen;
2090 UINT64 u64PositionSigAfterMove;
2091 UINT64 u64PositionSigBeforeMove;
2092 volatile FLAG fInUse;
2096 typedef struct _GAME_DATA
2098 GAME_HEADER sHeader;
2099 DLIST_ENTRY sMoveList;
2103 extern GAME_DATA g_GameData;
2106 GetRootPosition(void);
2109 SetRootPosition(CHAR *szFen);
2112 ResetGameList(void);
2115 GetMoveNumber(ULONG uColor);
2118 SetGameResultAndDescription(GAME_RESULT result);
2121 GetGameResult(void);
2127 SetOpponentsName(CHAR *sz);
2130 SetMyRating(ULONG u);
2133 SetOpponentsRating(ULONG u);
2139 TellGamelistThatIPlayColor(ULONG u);
2145 LoadPgn(CHAR *szPgn);
2148 CountOccurrancesOfSigInOfficialGameList(UINT64 u64Sig);
2151 DoesSigAppearInOfficialGameList(UINT64 u64Sig);
2154 OfficiallyTakebackMove(void);
2157 OfficiallyMakeMove(MOVE mv, SCORE iMoveScore, FLAG fFast);
2160 GetNthOfficialMoveRecord(ULONG n);
2163 MakeStatusLine(void);
2166 IsLegalDrawByRepetition(void);
2171 COMMAND(ScriptCommand);
2173 COMMAND(SolutionCommand);
2175 COMMAND(AvoidCommand);
2180 PostMoveTestSuiteReport(SEARCHER_THREAD_CONTEXT *);
2183 CheckTestSuiteMove(MOVE mv, SCORE iScore, ULONG uDepth);
2186 WeAreRunningASuite(void);
2192 COMMAND(SetCommand);
2197 extern ULONG g_uSoftExtendLimit;
2198 extern ULONG g_uHardExtendLimit;
2199 extern volatile MOVE_TIMER g_MoveTimer;
2200 extern ULONG g_uExtensionReduction[MAX_PLY_PER_SEARCH];
2202 #ifdef PERF_COUNTERS
2203 #define KEEP_TRACK_OF_FIRST_MOVE_FHs(x) \
2204 ctx->sCounters.tree.u64BetaCutoffs++; \
2207 ctx->sCounters.tree.u64BetaCutoffsOnFirstMove++;\
2210 #define KEEP_TRACK_OF_FIRST_MOVE_FHs(x)
2213 #define GAME_NOT_OVER 0
2214 #define GAME_WHITE_WON 1
2215 #define GAME_BLACK_WON 2
2216 #define GAME_DRAW_STALEMATE 3
2217 #define GAME_DRAW_REPETITION 4
2218 #define GAME_ONE_LEGAL_MOVE 5
2219 #define GAME_DRAW_FIFTY_MOVES_WO_PROGRESS 6
2222 Think(POSITION *pos);
2225 Ponder(POSITION *pos);
2228 Iterate(SEARCHER_THREAD_CONTEXT *ctx);
2231 SetMoveTimerForSearch(FLAG fSwitchOver, ULONG uColor);
2234 SetMoveTimerToThinkForever(void);
2237 ClearRootNodecountHash(void);
2243 IsDraw(SEARCHER_THREAD_CONTEXT *ctx);
2249 #define QPLIES_OF_NON_CAPTURE_CHECKS (1)
2250 #define FUTILITY_BASE_MARGIN (50) // + ctx->uPositional (min 100)
2252 #define IID_R_FACTOR (TWO_PLY + HALF_PLY)
2255 #define WE_SHOULD_STOP_SEARCHING (g_MoveTimer.bvFlags & TIMER_STOPPING)
2257 #define WE_SHOULD_STOP_SEARCHING ((g_MoveTimer.bvFlags & TIMER_STOPPING) || \
2258 (ThreadUnderTerminatingSplit(ctx)))
2262 QSearch(SEARCHER_THREAD_CONTEXT *ctx,
2267 Search(SEARCHER_THREAD_CONTEXT *ctx,
2277 ComputeMoveScore(IN SEARCHER_THREAD_CONTEXT *ctx,
2282 ThreadUnderTerminatingSplit(SEARCHER_THREAD_CONTEXT *);
2285 WeShouldDoHistoryPruning(IN SCORE iRoughEval,
2288 IN SEARCHER_THREAD_CONTEXT *ctx,
2289 IN ULONG uRemainingDepth,
2290 IN ULONG uLegalMoves,
2296 WeShouldTryNullmovePruning(IN SEARCHER_THREAD_CONTEXT *ctx,
2299 IN SCORE iRoughEval,
2300 IN ULONG uNullDepth);
2303 TryNullmovePruning(IN OUT SEARCHER_THREAD_CONTEXT *ctx,
2304 IN OUT FLAG *pfThreat,
2307 IN ULONG uNullDepth,
2308 IN OUT INT *piOrigExtend,
2309 OUT SCORE *piNullScore);
2312 UpdatePV(SEARCHER_THREAD_CONTEXT *ctx, MOVE mv);
2315 CheckInputAndTimers(IN SEARCHER_THREAD_CONTEXT *ctx);
2318 ComputeReactionToCheckExtension(IN OUT SEARCHER_THREAD_CONTEXT *ctx,
2321 IN SCORE iRoughEval,
2323 IN OUT INT *piExtend,
2324 IN OUT INT *piOrigExtend);
2327 ComputeMoveExtension(IN OUT SEARCHER_THREAD_CONTEXT *ctx,
2331 IN SCORE iRoughEval,
2333 IN OUT INT *piExtend);
2336 RescoreMovesViaSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
2342 MateDistancePruningCutoff(IN ULONG uPly,
2344 IN OUT SCORE *piBestScore,
2345 IN OUT SCORE *piAlpha,
2346 IN OUT SCORE *piBeta);
2349 CommonSearchInit(IN SEARCHER_THREAD_CONTEXT *ctx,
2350 IN OUT SCORE *piAlpha,
2351 IN OUT SCORE *piBeta,
2352 IN OUT SCORE *piScore);
2355 SelectNullmoveRFactor(IN SEARCHER_THREAD_CONTEXT *ctx,
2358 #define VERIFY_BEFORE (1)
2359 #define VERIFY_AFTER (2)
2362 SanityCheckMoves(IN SEARCHER_THREAD_CONTEXT *ctx,
2382 typedef struct _SEE_THREESOME
2389 typedef struct _SEE_LIST
2392 SEE_THREESOME data[16];
2397 ControlsSquareMinusPiece(ULONG uSide,
2406 DebugSEE(POSITION *pos,
2410 TestGetAttacks(void);
2415 #define NUM_HASH_ENTRIES_PER_LINE 4
2416 #define HASH_FLAG_EXACT 0x1
2417 #define HASH_FLAG_LOWER 0x2
2418 #define HASH_FLAG_UPPER 0x4
2419 #define HASH_FLAG_VALID_BOUNDS 0x7
2420 #define HASH_FLAG_THREAT 0x8
2421 #define HASH_FLAG_DIRTY 0xF0
2423 typedef struct _HASH_ENTRY
2427 UCHAR bvFlags; // 5 ==> d d d d | thr up low exact
2428 signed short iValue; // 6 7
2429 UINT64 u64Sig; // 8 9 A B C D E F == 16 bytes
2433 InitializeHashSystem(void);
2436 CleanupHashSystem(void);
2439 ClearHashTable(void);
2442 DirtyHashTable(void);
2445 StoreLowerBound(MOVE mvBestMove,
2451 StoreExactScore(MOVE mvBestMove,
2459 StoreUpperBound(//MOVE mvBestMove,
2466 HashLookup(SEARCHER_THREAD_CONTEXT *ctx,
2477 CheckHashForDangerSquare(POSITION *pos);
2480 GetPonderMove(POSITION *pos);
2482 extern ULONG g_uHashTableSizeEntries;
2483 extern ULONG g_uHashTableSizeBytes;
2484 extern HASH_ENTRY *g_pHashTable;
2490 AnalyzeFullHashTable(void);
2495 // IDEA: store "mate threat" flag in here?
2496 // IDEA: store "king safety" numbers in here?
2498 typedef struct _POSITION_HASH_ENTRY {
2501 UCHAR uEnpriseCount[2];
2503 } POSITION_HASH_ENTRY;
2506 InitializePositionHashSystem(void);
2509 CleanupPositionHashSystem(void);
2512 StoreEnprisePiece(POSITION *pos, COOR cSquare);
2515 StoreTrappedPiece(POSITION *pos, COOR cSquare);
2518 GetEnprisePiece(POSITION *pos, ULONG uSide);
2521 GetEnpriseCount(POSITION *pos, ULONG uSide);
2524 GetTrappedPiece(POSITION *pos, ULONG uSide);
2527 SideCanStandPat(POSITION *pos, ULONG uSide);
2530 ValueOfMaterialInTroubleDespiteMove(POSITION *pos, ULONG uSide);
2533 ValueOfMaterialInTroubleAfterNull(POSITION *pos, ULONG uSide);
2538 #define COOR_TO_BIT(x) ((x) & 0x7) + ((0x7 - ((x) >> 4)) << 3)
2541 ClearPawnHashStats(void);
2544 ReportPawnHashStats(void);
2547 PawnHashLookup(SEARCHER_THREAD_CONTEXT *ctx);
2553 #define LAZE_EVAL_BASE_SCORE 10
2554 extern const int g_iAhead[2];
2555 extern const int g_iBehind[2];
2558 DNABufferSizeBytes();
2564 WriteEvalDNA(char *szFilename);
2567 ImportEvalDNA(char *p);
2570 ReadEvalDNA(char *szFilename);
2575 Eval(SEARCHER_THREAD_CONTEXT *, SCORE, SCORE);
2578 EvalPasserRaces(POSITION *,
2582 CountKingSafetyDefects(POSITION *pos,
2593 EvalTraceReport(void);
2596 EvalTrace(ULONG uColor, PIECE p, COOR c, SCORE iVal, CHAR *szMessage);
2599 EvalSigmaForPiece(POSITION *pos, COOR c);
2602 EvalTraceClear(void);
2605 TestEvalWithSymmetry(void);
2607 #define EVAL_TERM(COL, PIE, COO, VAL, ADJ, MESS) \
2609 EvalTrace((COL), (PIE), (COO), (ADJ), (MESS));
2611 #define EVAL_TERM(COL, PIE, COO, VAL, ADJ, MESS) \
2619 InitializeBitboards(void);
2622 SlowCountBits(BITBOARD bb);
2625 DeBruijnFirstBit(BITBOARD bb);
2628 SlowFirstBit(BITBOARD bb);
2631 SlowLastBit(BITBOARD bb);
2634 #define CountBits SlowCountBits
2635 #define FirstBit SlowFirstBit
2636 #define LastBit SlowLastBit
2640 CoorFromBitBoardRank8ToRank1(BITBOARD *pbb);
2643 CoorFromBitBoardRank1ToRank8(BITBOARD *pbb);
2649 CountBits(BITBOARD bb);
2652 FirstBit(BITBOARD bb);
2655 LastBit(BITBOARD bb);
2658 LockCompareExchange(volatile void *pDest,
2663 LockIncrement(volatile void *pDest);
2666 LockDecrement(volatile void *pDest);
2669 CanUseParallelOpcodes();
2672 ParallelCompareUlong(ULONG uComparand, void *pComparators);
2675 ParallelCompareVector(void *pComparand, void *pComparators);
2678 GetAttacks(SEE_LIST *pList,
2684 SlowGetAttacks(SEE_LIST *pList,
2689 #define GetAttacks SlowGetAttacks
2694 // Note: this is most of the stuff that x86.asm assumes about the
2695 // internal data structures. If any of this fails then either the
2696 // assembly language code needs to be updated or you need to use the C
2697 // version of the routine in see.c instead.
2699 #define ASSERT_ASM_ASSUMPTIONS \
2700 ASSERT(VALUE_PAWN == 100); \
2701 ASSERT(OFFSET_OF(uCount, SEE_LIST) == 0); \
2702 ASSERT(OFFSET_OF(data, SEE_LIST) == 4); \
2703 ASSERT(sizeof(SEE_THREESOME) == 12); \
2704 ASSERT(OFFSET_OF(pPiece, SEE_THREESOME) == 0); \
2705 ASSERT(OFFSET_OF(cLoc, SEE_THREESOME) == 4); \
2706 ASSERT(OFFSET_OF(uVal, SEE_THREESOME) == 8); \
2707 ASSERT(OFFSET_OF(cNonPawns, POSITION) == 0x478); \
2708 ASSERT(OFFSET_OF(uNonPawnCount, POSITION) == 0x500); \
2709 ASSERT(OFFSET_OF(rgSquare, POSITION) == 0); \
2710 ASSERT(sizeof(SQUARE) == 8); \
2711 ASSERT(sizeof(VECTOR_DELTA) == 4); \
2712 ASSERT(sizeof(g_VectorDelta) == 256 * 4); \
2713 ASSERT(OFFSET_OF(iVector, VECTOR_DELTA) == 0); \
2714 ASSERT(OFFSET_OF(iDelta, VECTOR_DELTA) == 2); \
2715 ASSERT(OFFSET_OF(iNegDelta, VECTOR_DELTA) == 3); \
2716 ASSERT(sizeof(g_PieceData) == 8 * 4 * 4); \
2717 ASSERT(OFFSET_OF(uValue, PIECE_DATA) == 0);
2719 #define ASSERT_ASM_ASSUMPTIONS
2726 TestBitboards(void);
2731 extern ULONG g_HistoryCounters[14][128];
2734 GetMoveFailHighPercentage(MOVE mv);
2737 UpdateDynamicMoveOrdering(SEARCHER_THREAD_CONTEXT *ctx,
2738 ULONG uRemainingDepth,
2744 NewKillerMove(SEARCHER_THREAD_CONTEXT *ctx, MOVE mv, SCORE iScore);
2747 InitializeDynamicMoveOrdering(void);
2750 CleanupDynamicMoveOrdering(void);
2753 ClearDynamicMoveOrdering(void);
2756 MaintainDynamicMoveOrdering(void);
2759 IncrementMoveHistoryCounter(MOVE mv, ULONG u);
2762 DecrementMoveHistoryCounter(MOVE mv, ULONG u);
2767 extern volatile ULONG g_uNumHelpersAvailable;
2768 extern ULONG g_uNumHelperThreads;
2771 InitializeParallelSearch(void);
2774 CleanupParallelSearch(void);
2777 ClearHelperThreadIdleness(void);
2780 DumpHelperIdlenessReport(void);
2783 StartParallelSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
2784 IN OUT SCORE *piAlpha,
2786 IN OUT SCORE *piBestScore,
2787 IN OUT MOVE *pmvBest,
2789 IN INT iPositionExtend,
2793 InitializeSearcherContext(POSITION *pos, SEARCHER_THREAD_CONTEXT *ctx);
2796 ReInitializeSearcherContext(POSITION *pos, SEARCHER_THREAD_CONTEXT *ctx);
2799 InitializeLightweightSearcherContext(POSITION *pos,
2800 LIGHTWEIGHT_SEARCHER_CONTEXT *ctx);
2806 #define BOOK_PROBE_MISS_LIMIT (7)
2807 #define FLAG_DISABLED (1)
2808 #define FLAG_ALWAYSPLAY (2)
2809 #define FLAG_DELETED (4)
2811 #define BOOKMOVE_SELECT_MOVE (1)
2812 #define BOOKMOVE_DUMP (2)
2815 typedef struct _BOOK_ENTRY
2817 UINT64 u64Sig; // 8 bytes
2818 UINT64 u64NextSig; // 8 bytes
2819 MOVE mvNext; // 4 bytes
2820 ULONG uWins; // 4 bytes
2821 ULONG uDraws; // 4 bytes
2822 ULONG uLosses; // 4 bytes
2823 BITV bvFlags; // 4 bytes
2828 typedef struct _OPENING_NAME_MAPPING
2833 OPENING_NAME_MAPPING;
2835 #define BOOK_EDITING_RECORD "bkedit.edt"
2836 #define OPENING_LEARNING_FILENAME "bklearn.bin"
2838 typedef struct _OPENING_LEARNING_ENTRY
2845 OPENING_LEARNING_ENTRY;
2848 InitializeOpeningBook(void);
2851 ResetOpeningBook(void);
2854 CleanupOpeningBook(void);
2857 BookMove(POSITION *pos,
2860 COMMAND(BookCommand);
2862 extern ULONG g_uBookProbeFailures;
2863 extern FLAG g_fTournamentMode;
2864 extern CHAR *g_szBookName;
2869 COMMAND(BenchCommand);
2881 ProbeEGTB(SEARCHER_THREAD_CONTEXT *ctx, SCORE *score);
2884 InitializeEGTB(void);
2895 InitializeTreeDump(void);
2898 CleanupTreeDump(void);
2901 DTEnterNode(SEARCHER_THREAD_CONTEXT *ctx,
2908 DTLeaveNode(SEARCHER_THREAD_CONTEXT *ctx,
2914 DTTrace(ULONG uPly, CHAR *szMessage, ...);
2916 #define DTTRACE(...) DTTrace(ctx->uPly, __VA_ARGS__)
2920 #define DTTRACE(...)
2922 #define DTEnterNode(...)
2924 #define DTLeaveNode(...)
2926 #define InitializeTreeDump(...)
2928 #define CleanupTreeDump(...)
2936 IsBoardLegal(POSITION *pos);
2939 GenerateRandomLegalPosition(POSITION *pos);
2942 GenerateRandomLegalSymetricPosition(POSITION *pos);
2947 #define UNRECOGNIZED (0)
2948 #define RECOGN_EXACT (1)
2949 #define RECOGN_UPPER (2)
2950 #define RECOGN_LOWER (3)
2951 #define RECOGN_EGTB (4)
2954 InitializeInteriorNodeRecognizers(void);
2957 RecognLookup(SEARCHER_THREAD_CONTEXT *ctx,
2963 ClearEvalHashStats(void);
2966 ReportEvalHashStats(void);
2969 ProbeEvalHash(SEARCHER_THREAD_CONTEXT *ctx);
2972 GetRoughEvalScore(IN SEARCHER_THREAD_CONTEXT *ctx,
2978 StoreEvalHash(SEARCHER_THREAD_CONTEXT *ctx, SCORE iScore);