Rev 33 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 33 | Rev 108 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | * remaining on the board is less than or equal to the max number of pieces * |
10 | * remaining on the board is less than or equal to the max number of pieces * |
11 | * we have in the EGTB files that are available for use. * |
11 | * we have in the EGTB files that are available for use. * |
12 | * * |
12 | * * |
13 | ******************************************************************************* |
13 | ******************************************************************************* |
14 | */ |
14 | */ |
15 | # define \ |
15 | # define \ |
16 | VInitSqCtr(rgCtr, rgSquares, piece, bitboard) { \ |
16 | VInitSqCtr(rgCtr, rgSquares, piece, bitboard) { \ |
17 | int cPieces=0; \ |
17 | int cPieces=0; \ |
18 | uint64_t bbTemp=(bitboard); \ |
18 | uint64_t bbTemp=(bitboard); \ |
19 | while (bbTemp) { \ |
19 | while (bbTemp) { \ |
20 | const squaret sq=MSB(bbTemp); \ |
20 | const squaret sq=MSB(bbTemp); \ |
21 | (rgSquares)[(piece)*C_PIECES+cPieces]=sq; \ |
21 | (rgSquares)[(piece)*C_PIECES+cPieces]=sq; \ |
22 | cPieces++; \ |
22 | cPieces++; \ |
23 | Clear(sq, bbTemp); \ |
23 | Clear(sq, bbTemp); \ |
24 | } \ |
24 | } \ |
25 | (rgCtr)[(piece)]=cPieces; \ |
25 | (rgCtr)[(piece)]=cPieces; \ |
26 | } |
26 | } |
27 | # define T_INDEX64 |
27 | # define T_INDEX64 |
28 | # define C_PIECES 3 |
28 | # define C_PIECES 3 /* Maximum # of pieces of one color OTB */ |
29 | # if defined (T_INDEX64) && defined (_MSC_VER) |
29 | # if defined (T_INDEX64) && defined (_MSC_VER) |
30 | typedef uint64_t INDEX; |
30 | typedef uint64_t INDEX; |
31 | # elif defined (T_INDEX64) |
31 | # elif defined (T_INDEX64) |
32 | typedef uint64_t INDEX; |
32 | typedef uint64_t INDEX; |
33 | # else |
33 | # else |
Line 35... | Line 35... | ||
35 | # endif |
35 | # endif |
36 | typedef unsigned int squaret; |
36 | typedef unsigned int squaret; |
37 | 37 | ||
38 | /* Those declarations necessary because Crafty is C, not C++ program */ |
38 | /* Those declarations necessary because Crafty is C, not C++ program */ |
39 | # if defined (_MSC_VER) |
39 | # if defined (_MSC_VER) |
40 | # define TB_FASTCALL |
40 | # define TB_FASTCALL __fastcall |
41 | # else |
41 | # else |
42 | # define TB_FASTCALL |
42 | # define TB_FASTCALL |
43 | # endif |
43 | # endif |
44 | typedef int pcolor; |
44 | typedef int pcolor; |
45 | 45 | ||
46 | # define x_colorWhite 0 |
46 | # define x_colorWhite 0 |
47 | # define x_colorBlack 1 |
47 | # define x_colorBlack 1 |
48 | # define x_colorNeutral 2 |
48 | # define x_colorNeutral 2 |
49 | # define COLOR_DECLARED |
49 | # define COLOR_DECLARED |
50 | typedef int piece; |
50 | typedef int piece; |
51 | 51 | ||
52 | # define x_pieceNone 0 |
52 | # define x_pieceNone 0 |
53 | # define x_piecePawn 1 |
53 | # define x_piecePawn 1 |
54 | # define x_pieceKnight 2 |
54 | # define x_pieceKnight 2 |
55 | # define x_pieceBishop 3 |
55 | # define x_pieceBishop 3 |
56 | # define x_pieceRook 4 |
56 | # define x_pieceRook 4 |
57 | # define x_pieceQueen 5 |
57 | # define x_pieceQueen 5 |
58 | # define x_pieceKing 6 |
58 | # define x_pieceKing 6 |
59 | # define PIECES_DECLARED |
59 | # define PIECES_DECLARED |
60 | typedef signed char tb_t; |
60 | typedef signed char tb_t; |
61 | 61 | ||
62 | # define pageL 65536 |
62 | # define pageL 65536 |
63 | # define tbbe_ssL ((pageL-4)/2) |
63 | # define tbbe_ssL ((pageL-4)/2) |
64 | # define bev_broken (tbbe_ssL+1) |
64 | # define bev_broken (tbbe_ssL+1) /* illegal or busted */ |
65 | # define bev_mi1 tbbe_ssL |
65 | # define bev_mi1 tbbe_ssL /* mate in 1 move */ |
66 | # define bev_mimin 1 /* mate in max moves */ |
66 | # define bev_mimin 1 /* mate in max moves */ |
67 | # define bev_draw 0 /* draw */ |
67 | # define bev_draw 0 /* draw */ |
68 | # define bev_limax (-1) |
68 | # define bev_limax (-1) /* mated in max moves */ |
69 | # define bev_li0 (-tbbe_ssL) |
69 | # define bev_li0 (-tbbe_ssL) |
70 |
|
70 | /* mated in 0 moves */ |
71 | typedef INDEX(TB_FASTCALL * PfnCalcIndex) |
71 | typedef INDEX(TB_FASTCALL * PfnCalcIndex) |
72 | (squaret *, squaret *, squaret, int fInverse); |
72 | (squaret *, squaret *, squaret, int fInverse); |
73 | extern int IDescFindFromCounters(int *); |
73 | extern int IDescFindFromCounters(int *); |
74 | extern int FRegisteredFun(int, pcolor); |
74 | extern int FRegisteredFun(int, pcolor); |
75 | extern PfnCalcIndex PfnIndCalcFun(int, pcolor); |
75 | extern PfnCalcIndex PfnIndCalcFun(int, pcolor); |
Line 163... | Line 163... | ||
163 | if (tbValue > 0) |
163 | if (tbValue > 0) |
164 | *score = MATE + 2 * (-bev_mi1 + tbValue - 1); |
164 | *score = MATE + 2 * (-bev_mi1 + tbValue - 1); |
165 | else if (tbValue < 0) |
165 | else if (tbValue < 0) |
166 | *score = -MATE + 2 * (bev_mi1 + tbValue); |
166 | *score = -MATE + 2 * (bev_mi1 + tbValue); |
167 | else |
167 | else |
168 | *score = |
168 | *score = 0; |
169 | return 1; |
169 | return 1; |
170 | } |
170 | } |
171 | #endif |
171 | #endif |