Subversion Repositories Games.Chess Giants

Rev

Rev 33 | Rev 154 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33 Rev 108
Line 26... Line 26...
26
#  if (CPUS > 1)
26
#  if (CPUS > 1)
27
#    include <pthread.h>
27
#    include <pthread.h>
28
#  endif
28
#  endif
29
#  include <unistd.h>
29
#  include <unistd.h>
30
#  include <sys/types.h>
30
#  include <sys/types.h>
-
 
31
#  include <sys/stat.h>
31
#endif
32
#endif
32
#include <stdint.h>
33
#include <stdint.h>
33
#ifdef _MSC_VER
-
 
34
#include <stdint.h> // Pierre-Marie Baty -- Visual Studio lacks inttypes.h
-
 
35
#define PRIu64 "I64u" // Pierre-Marie Baty -- missing definition
-
 
36
#if !defined(INLINEASM)
-
 
37
int MSB(uint64_t arg1); // Pierre-Marie Baty -- missing forward declaration
-
 
38
int LSB(uint64_t arg1); // Pierre-Marie Baty -- missing forward declaration
-
 
39
int PopCnt(uint64_t arg1); // Pierre-Marie Baty -- missing forward declaration
-
 
40
#endif // !defined(INLINEASM)
-
 
41
#else // !_MSC_VER
-
 
42
#include <inttypes.h>
34
#include <inttypes.h>
43
#endif // _MSC_VER
-
 
44
#include <time.h>
35
#include <time.h>
45
#include <stdio.h>
36
#include <stdio.h>
46
#include <assert.h>
37
#include <assert.h>
47
#include <stdlib.h>
38
#include <stdlib.h>
48
#include <string.h>
39
#include <string.h>
Line 70... Line 61...
70
#      undef  CDECL
61
#      undef  CDECL
71
#      define CDECL __cdecl
62
#      define CDECL __cdecl
72
#    endif
63
#    endif
73
#  endif
64
#  endif
74
#  if !defined(BOOKDIR)
65
#  if !defined(BOOKDIR)
75
#    define     BOOKDIR        "."
66
#    define   BOOKDIR      "."
76
#  endif
67
#  endif
77
#  if !defined(LOGDIR)
68
#  if !defined(LOGDIR)
78
#    define      LOGDIR        "."
69
#    define   LOGDIR       "."
79
#  endif
70
#  endif
80
#  if !defined(TBDIR)
71
#  if !defined(TBDIR)
81
#    define       TBDIR     "./TB"
72
#    define   TBDIR        "./TB"
82
#  endif
73
#  endif
83
#  if !defined(RCDIR)
74
#  if !defined(RCDIR)
84
#    define       RCDIR        "."
75
#    define   RCDIR        "."
85
#  endif
76
#  endif
86
#  include "lock.h"
77
#  include "lock.h"
87
#  define MAXPLY                                 129
78
#  define MAXPLY                                 129
88
#  define MAX_TC_NODES                      10000000
79
#  define MAX_TC_NODES                       3000000
89
#  define MAX_BLOCKS_PER_CPU                      64
80
#  define MAX_BLOCKS                       64 * CPUS
90
#  define MAX_BLOCKS         MAX_BLOCKS_PER_CPU*CPUS
-
 
91
#  define BOOK_CLUSTER_SIZE                     8000
81
#  define BOOK_CLUSTER_SIZE                     8000
92
#  define BOOK_POSITION_SIZE                      16
-
 
93
#  define MERGE_BLOCK                           1000
82
#  define MERGE_BLOCK                           1000
94
#  define SORT_BLOCK                         4000000
83
#  define SORT_BLOCK                         4000000
95
#  define LEARN_INTERVAL                          10
84
#  define LEARN_INTERVAL                          10
96
#  define LEARN_COUNTER_BAD                      -80
85
#  define LEARN_COUNTER_BAD                      -80
97
#  define LEARN_COUNTER_GOOD                    +100
86
#  define LEARN_COUNTER_GOOD                    +100
98
#  define MATE                                 32768
87
#  define MATE                                 32768
99
#  define PAWN_VALUE                             100
88
#  define PAWN_VALUE                             100
100
#  define KNIGHT_VALUE                           325
89
#  define KNIGHT_VALUE                           305
101
#  define BISHOP_VALUE                           325
90
#  define BISHOP_VALUE                           305
102
#  define ROOK_VALUE                             500
91
#  define ROOK_VALUE                             490
103
#  define QUEEN_VALUE                           1050
92
#  define QUEEN_VALUE                           1000
104
#  define KING_VALUE                           40000
93
#  define KING_VALUE                           40000
105
#  define MAX_DRAFT                              256
-
 
106
#  if !defined(CLOCKS_PER_SEC)
94
#  if !defined(CLOCKS_PER_SEC)
107
#    define CLOCKS_PER_SEC 1000000
95
#    define CLOCKS_PER_SEC 1000000
108
#  endif
96
#  endif
109
typedef enum {
97
typedef enum {
110
  A1, B1, C1, D1, E1, F1, G1, H1,
98
  A1, B1, C1, D1, E1, F1, G1, H1,
Line 123... Line 111...
123
  rook = 4, queen = 5, king = 6
111
  rook = 4, queen = 5, king = 6
124
} PIECE;
112
} PIECE;
125
typedef enum { black = 0, white = 1 } COLOR;
113
typedef enum { black = 0, white = 1 } COLOR;
126
typedef enum { mg = 0, eg = 1 } PHASE;
114
typedef enum { mg = 0, eg = 1 } PHASE;
127
typedef enum { empty_v = 0, pawn_v = 1, knight_v = 3,
115
typedef enum { empty_v = 0, pawn_v = 1, knight_v = 3,
128
  bishop_v = 3, rook_v = 5, queen_v = 9, king_v = 99
116
               bishop_v = 3, rook_v = 5, queen_v = 9, king_v = 99
129
} PIECE_V;
117
} PIECE_V;
-
 
118
typedef enum { serial = 0, parallel = 1} SEARCH_MODE;
130
typedef enum { think = 1, puzzle = 2, book = 3, annotate = 4 } SEARCH_TYPE;
119
typedef enum { think = 1, puzzle = 2, book = 3, annotate = 4 } SEARCH_TYPE;
131
typedef enum { normal_mode, tournament_mode } PLAYING_MODE;
120
typedef enum { normal_mode, tournament_mode } PLAYING_MODE;
132
typedef struct {
121
typedef struct {
133
  int8_t castle[2];
122
  int8_t castle[2];
134
  uint8_t enpassant_target;
123
  uint8_t enpassant_target;
Line 147... Line 136...
147
  uint64_t pawn_hash_key;
136
  uint64_t pawn_hash_key;
148
  int material_evaluation;
137
  int material_evaluation;
149
  int kingsq[2];
138
  int kingsq[2];
150
  int8_t board[64];
139
  int8_t board[64];
151
  char pieces[2][7];
140
  char pieces[2][7];
152
  char majors[2];
-
 
153
  char minors[2];
-
 
154
  char total_all_pieces;
141
  char total_all_pieces;
155
} POSITION;
142
} POSITION;
156
typedef struct {
143
typedef struct {
157
  uint64_t word1;
144
  uint64_t word1;
158
  uint64_t word2;
145
  uint64_t word2;
159
} HASH_ENTRY;
146
} HASH_ENTRY;
160
typedef struct {
147
typedef struct {
161
  uint64_t key;
148
  uint64_t key;
162
  int score_mg, score_eg;
149
  int32_t score_mg, score_eg;
163
  unsigned char defects_k[2];
150
  unsigned char defects_k[2];
164
  unsigned char defects_e[2];
-
 
165
  unsigned char defects_d[2];
151
  unsigned char defects_m[2];
166
  unsigned char defects_q[2];
152
  unsigned char defects_q[2];
167
  unsigned char all[2];
-
 
168
  unsigned char passed[2];
153
  unsigned char passed[2];
169
  unsigned char filler[4];
-
 
170
} PAWN_HASH_ENTRY;
154
} PAWN_HASH_ENTRY;
171
typedef struct {
155
typedef struct {
172
  uint64_t entry[4];
156
  uint64_t entry[3];
173
} PXOR;
157
} PXOR;
174
typedef struct {
158
typedef struct {
175
  int path[MAXPLY];
159
  int path[MAXPLY];
176
  int pathh;
160
  int pathh;
177
  int pathl;
161
  int pathl;
Line 184... Line 168...
184
  int hash_path_age;
168
  int hash_path_age;
185
  int hash_path_moves[MAXPLY];
169
  int hash_path_moves[MAXPLY];
186
} HPATH_ENTRY;
170
} HPATH_ENTRY;
187
typedef struct {
171
typedef struct {
188
  int phase;
172
  int phase;
-
 
173
  int order;
189
  int remaining;
174
  int remaining;
190
  int *last;
175
  unsigned *last;
191
  int excluded_moves[5];
176
  unsigned done[10];
192
  int num_excluded;
177
  unsigned *exclude;
193
} NEXT_MOVE;
178
} NEXT_MOVE;
-
 
179
/*
-
 
180
   root_move.status:
-
 
181
 
-
 
182
   xxx1 = failed low this iteration
-
 
183
   xx1x = failed high this iteration
-
 
184
   x1xx = don't search in parallel or reduce
-
 
185
   1xxx = move has been searched
-
 
186
 */
194
typedef struct {
187
typedef struct {
195
  int move;
188
  int move;
196
/*
-
 
197
   x..xx xxxx xxx1 = failed low this iteration
-
 
198
   x..xx xxxx xx1x = failed high this iteration
-
 
199
   x..xx xxxx x1xx = don't search in parallel or reduce
-
 
200
   x..xx xxxx 1xxx = move has been searched
-
 
201
 */
-
 
202
  unsigned int status;
189
  unsigned status;
203
  int bm_age;
190
  int bm_age;
-
 
191
  PATH path;
204
} ROOT_MOVE;
192
} ROOT_MOVE;
205
#  if !defined(UNIX)
193
#  if !defined(UNIX)
206
#    pragma pack(4)
194
#    pragma pack(4)
207
#  endif
195
#  endif
208
typedef struct {
196
typedef struct {
209
  uint64_t position;
197
  uint64_t position;
210
  unsigned int status_played;
198
  unsigned status_played;
211
  float learn;
199
  float learn;
212
} BOOK_POSITION;
200
} BOOK_POSITION;
213
#  if !defined(UNIX)
201
#  if !defined(UNIX)
214
#    pragma pack()
202
#    pragma pack()
215
#  endif
203
#  endif
Line 220... Line 208...
220
} BB_POSITION;
208
} BB_POSITION;
221
struct personality_term {
209
struct personality_term {
222
  char *description;
210
  char *description;
223
  int type;
211
  int type;
224
  int size;
212
  int size;
225
  int *value;
213
  void *value;
226
};
214
};
227
struct tree {
215
struct autotune {
-
 
216
  unsigned int min;
-
 
217
  unsigned int max;
-
 
218
  unsigned int increment;
-
 
219
  char description[64];
-
 
220
  char command[16];
-
 
221
  unsigned int *parameter;
-
 
222
};
-
 
223
typedef struct tree {
-
 
224
/* commonly used variables */
-
 
225
  SEARCH_POSITION status[MAXPLY + 3];
-
 
226
  NEXT_MOVE next_status[MAXPLY];
-
 
227
  KILLER killers[MAXPLY];
228
  POSITION position;
228
  POSITION position;
229
  uint64_t save_hash_key[MAXPLY + 3];
229
  uint64_t save_hash_key[MAXPLY + 3];
230
  uint64_t save_pawn_hash_key[MAXPLY + 3];
230
  uint64_t save_pawn_hash_key[MAXPLY + 3];
231
  int rep_index;
-
 
232
  uint64_t rep_list[256];
231
  uint64_t rep_list[256];
233
  uint64_t all_pawns;
-
 
234
  uint64_t nodes_searched;
-
 
235
  uint64_t cache_n[64];
-
 
236
  PAWN_HASH_ENTRY pawn_score;
-
 
237
  SEARCH_POSITION status[MAXPLY + 3];
-
 
238
  NEXT_MOVE next_status[MAXPLY];
-
 
239
  PATH pv[MAXPLY];
-
 
240
  int cache_n_mobility[64];
-
 
241
  int curmv[MAXPLY];
232
  int curmv[MAXPLY];
-
 
233
  int phase[MAXPLY];
242
  int hash_move[MAXPLY];
234
  int hash_move[MAXPLY];
243
  int *last[MAXPLY];
235
  unsigned *last[MAXPLY];
244
  uint64_t fail_highs;
-
 
245
  uint64_t fail_high_first_move;
-
 
246
  unsigned int evaluations;
236
  unsigned move_list[5120];
247
  unsigned int egtb_probes;
-
 
248
  unsigned int egtb_probes_successful;
-
 
249
  unsigned int extensions_done;
-
 
250
  unsigned int qchecks_done;
-
 
251
  unsigned int reductions_done;
-
 
252
  unsigned int moves_fpruned;
-
 
253
  KILLER killers[MAXPLY];
237
  PATH pv[MAXPLY];
254
  int move_list[5120];
-
 
255
  int sort_value[256];
238
/* variables used by Evaluate() */
256
  unsigned char inchk[MAXPLY];
239
  PAWN_HASH_ENTRY pawn_score;
257
  int phase[MAXPLY];
-
 
258
  int tropism[2];
240
  int tropism[2];
259
  int dangerous[2];
241
  int dangerous[2];
-
 
242
  uint64_t all_pawns;
260
  int score_mg, score_eg;
243
  int score_mg, score_eg;
-
 
244
/* statistical counters */
-
 
245
  uint64_t nodes_searched;
-
 
246
  uint64_t fail_highs;
-
 
247
  uint64_t fail_high_first_move;
-
 
248
  uint64_t evaluations;
-
 
249
  uint64_t egtb_probes;
-
 
250
  uint64_t egtb_hits;
-
 
251
  uint64_t extensions_done;
-
 
252
  uint64_t qchecks_done;
-
 
253
  uint64_t moves_fpruned;
-
 
254
  uint64_t moves_mpruned;
-
 
255
  uint64_t LMR_done[16];
-
 
256
  uint64_t null_done[16];
261
#  if (CPUS > 1)
257
/* thread stuff */
262
  lock_t lock;
258
  lock_t lock;
263
#  endif
-
 
264
  int thread_id;
259
  int thread_id;
-
 
260
  volatile int joinable;
-
 
261
  volatile int joined;
265
  volatile int stop;
262
  volatile int stop;
266
  char root_move_text[16];
-
 
267
  char remaining_moves_text[16];
-
 
268
  struct tree *volatile siblings[CPUS], *parent;
-
 
269
  volatile int nprocs;
263
  volatile int nprocs;
270
  int alpha;
264
  int alpha;
271
  int beta;
265
  int beta;
272
  volatile int value;
266
  volatile int value;
273
  int side;
267
  int wtm;
274
  int depth;
268
  int depth;
275
  int ply;
269
  int ply;
-
 
270
  int in_check;
-
 
271
  int *searched;
276
  int cutmove;
272
  int cutmove;
-
 
273
  struct tree *volatile siblings[CPUS], *parent;
277
  volatile int used;
274
/* rarely accessed */
-
 
275
  char root_move_text[16];
278
  volatile int moves_searched;
276
  char remaining_moves_text[16];
279
};
277
} TREE;
280
typedef struct tree TREE;
278
typedef struct thread {
281
struct thread {
279
  TREE *tree;
-
 
280
  uint64_t blocks;
282
  TREE *volatile tree;
281
  uint64_t max_blocks;
283
  volatile int idle;
282
  unsigned int idle;
-
 
283
  volatile unsigned int terminate;
284
  char filler[52];
284
  char filler[40];
285
};
285
} THREAD;
286
typedef struct thread THREAD;
-
 
287
/*
286
/*
288
   DO NOT modify these.  these are constants, used in multiple modules.
287
   DO NOT modify these.  these are constants, used in multiple modules.
289
   modification may corrupt the search in any number of ways, all bad.
288
   modification may corrupt the search in any number of ways, all bad.
290
 */
289
 */
291
#  define WORTHLESS                 0
290
#  define WORTHLESS                    0
292
#  define LOWER                     1
291
#  define UPPER                        1
293
#  define UPPER                     2
292
#  define LOWER                        2
294
#  define EXACT                     3
293
#  define EXACT                        3
295
#  define HASH_MISS                 0
294
#  define HASH_MISS                    0
296
#  define HASH_HIT                  1
295
#  define HASH_HIT                     1
297
#  define AVOID_NULL_MOVE           2
296
#  define AVOID_NULL_MOVE              2
298
#  define NO_NULL                   0
297
#  define NO_NULL                      0
299
#  define DO_NULL                   1
298
#  define DO_NULL                      1
300
#  define NONE                      0
299
#  define NONE                         0
301
#  define EVALUATION                0
300
#  define NULL_MOVE                    1
302
#  define NULL_MOVE                 1
301
#  define DO_NOT_REDUCE                1
303
#  define HASH_MOVE                 2
302
#  define HASH                         2
304
#  define GENERATE_CAPTURE_MOVES    3
303
#  define GENERATE_CAPTURES            3
305
#  define CAPTURE_MOVES             4
304
#  define CAPTURES                     4
306
#  define KILLER_MOVE_1             5
305
#  define KILLER1                      5
307
#  define KILLER_MOVE_2             6
306
#  define KILLER2                      6
308
#  define KILLER_MOVE_3             7
307
#  define KILLER3                      7
-
 
308
#  define KILLER4                      8
-
 
309
#  define COUNTER_MOVE1                9
309
#  define KILLER_MOVE_4             8
310
#  define COUNTER_MOVE2               10
-
 
311
#  define MOVE_PAIR1                  11
-
 
312
#  define MOVE_PAIR2                  12
310
#  define GENERATE_ALL_MOVES        9
313
#  define GENERATE_QUIET              13
-
 
314
#  define HISTORY                     14
311
#  define REMAINING_MOVES          10
315
#  define REMAINING                   15
-
 
316
#  define EVALUATION                  16
-
 
317
#  define ILLEGAL                      0
-
 
318
#  define LEGAL                        1
312
#if defined(UNIX) && !defined(INLINEASM)
319
#  define IN_WINDOW                    2
-
 
320
#  define FAIL_HIGH                    3
-
 
321
#if /*defined(UNIX) &&*/ !defined(INLINEASM) // Pierre-Marie Baty -- we also use them on Windows...
313
int CDECL PopCnt(uint64_t);
322
int CDECL PopCnt(uint64_t);
314
int CDECL MSB(uint64_t);
323
int CDECL MSB(uint64_t);
315
int CDECL LSB(uint64_t);
324
int CDECL LSB(uint64_t);
316
#endif
325
#endif
317
void AlignedMalloc(void **, int, size_t);
326
void AlignedMalloc(void **, int, size_t);
Line 323... Line 332...
323
void AnnotatePositionHTML(TREE *RESTRICT, int, FILE *);
332
void AnnotatePositionHTML(TREE *RESTRICT, int, FILE *);
324
char *AnnotateVtoNAG(int, int, int, int);
333
char *AnnotateVtoNAG(int, int, int, int);
325
void AnnotateHeaderTeX(FILE *);
334
void AnnotateHeaderTeX(FILE *);
326
void AnnotateFooterTeX(FILE *);
335
void AnnotateFooterTeX(FILE *);
327
void AnnotatePositionTeX(TREE *, int, FILE *);
336
void AnnotatePositionTeX(TREE *, int, FILE *);
328
uint64_t atoiKM(char *);
337
uint64_t atoiKMB(char *);
329
int Attacks(TREE *RESTRICT, int, int);
338
int Attacks(TREE *RESTRICT, int, int);
-
 
339
uint64_t Attacked(TREE *RESTRICT, int, uint64_t);
330
uint64_t AttacksFrom(TREE *RESTRICT, int, int);
340
uint64_t AttacksFrom(TREE *RESTRICT, int, int);
331
uint64_t AttacksTo(TREE *RESTRICT, int);
341
uint64_t AttacksTo(TREE *RESTRICT, int);
-
 
342
void AutoTune(int, char **);
332
void Bench(int);
343
int Bench(int, int);
-
 
344
int Bench_PGO(int, int);
333
int Book(TREE *RESTRICT, int, int);
345
int Book(TREE *RESTRICT, int);
334
void BookClusterIn(FILE *, int, BOOK_POSITION *);
346
void BookClusterIn(FILE *, int, BOOK_POSITION *);
335
void BookClusterOut(FILE *, int, BOOK_POSITION *);
347
void BookClusterOut(FILE *, int, BOOK_POSITION *);
336
int BookIn32(unsigned char *);
348
int BookIn32(unsigned char *);
337
float BookIn32f(unsigned char *);
349
float BookIn32f(unsigned char *);
338
uint64_t BookIn64(unsigned char *);
350
uint64_t BookIn64(unsigned char *);
339
int BookMask(char *);
351
int BookMask(char *);
340
unsigned char *BookOut32(int);
352
unsigned char *BookOut32(int);
341
unsigned char *BookOut32f(float);
353
unsigned char *BookOut32f(float);
342
unsigned char *BookOut64(uint64_t);
354
unsigned char *BookOut64(uint64_t);
343
int BookPonderMove(TREE *RESTRICT, int);
355
int BookPonderMove(TREE *RESTRICT, int);
344
void BookUp(TREE *RESTRICT, int, char **);
356
void Bookup(TREE *RESTRICT, int, char **);
345
void BookSort(BB_POSITION *, int, int);
357
void BookSort(BB_POSITION *, int, int);
346
int BookUpCompare(const void *, const void *);
358
int BookupCompare(const void *, const void *);
347
BB_POSITION BookUpNextPosition(int, int);
359
BB_POSITION BookupNextPosition(int, int);
348
int CheckInput(void);
360
int CheckInput(void);
349
void ClearHashTableScores(void);
361
void ClearHashTableScores(void);
350
int ComputeDifficulty(int, int);
362
int ComputeDifficulty(int, int);
-
 
363
void CopyFromParent(TREE *RESTRICT);
351
void CopyToParent(TREE *RESTRICT, TREE *RESTRICT, int);
364
void CopyToParent(TREE *RESTRICT, TREE *RESTRICT, int);
352
void CopyToChild(TREE *RESTRICT, int);
-
 
353
void CraftyExit(int);
365
void CraftyExit(int);
354
void DisplayArray(int *, int);
366
void DisplayArray(int *, int);
355
void DisplayArrayX2(int *, int *, int);
367
void DisplayArrayX2(int *, int *, int);
356
void DisplayBitBoard(uint64_t);
368
void DisplayBitBoard(uint64_t);
357
void Display2BitBoards(uint64_t, uint64_t);
369
void Display2BitBoards(uint64_t, uint64_t);
358
void DisplayChessBoard(FILE *, POSITION);
370
void DisplayChessBoard(FILE *, POSITION);
359
char *DisplayEvaluation(int, int);
371
char *DisplayEvaluation(int, int);
360
char *DisplayEvaluationKibitz(int, int);
372
char *DisplayEvaluationKibitz(int, int);
361
void DisplayFT(int, int, int);
373
void DisplayFT(int, int, int);
362
char *DisplayHHMM(unsigned int);
374
char *DisplayHHMM(unsigned);
363
char *DisplayHHMMSS(unsigned int);
375
char *DisplayHHMMSS(unsigned);
364
char *DisplayKMB(uint64_t);
376
char *DisplayKMB(uint64_t, int);
-
 
377
void DisplayFail(TREE *RESTRICT, int, int, int, int, int, int, int);
-
 
378
char *DisplayPath(TREE *RESTRICT, int, PATH *);
365
void DisplayPV(TREE *RESTRICT, int, int, int, PATH *);
379
void DisplayPV(TREE *RESTRICT, int, int, int, PATH *, int);
366
char *DisplayTime(unsigned int);
380
char *DisplayTime(unsigned);
367
char *Display2Times(unsigned int);
381
char *Display2Times(unsigned);
368
char *DisplayTimeKibitz(unsigned int);
382
char *DisplayTimeKibitz(unsigned);
369
void DisplayTreeState(TREE *RESTRICT, int, int, int);
-
 
370
void DisplayChessMove(char *, int);
383
void DisplayChessMove(char *, int);
371
int Drawn(TREE *RESTRICT, int);
384
int Drawn(TREE *RESTRICT, int);
372
void DisplayType3(int *, int *);
-
 
373
void DisplayType4(int *, int *);
-
 
374
void DisplayType5(int *, int);
-
 
375
void DisplayType6(int *);
-
 
376
void Edit(void);
385
void Edit(void);
377
#  if !defined(NOEGTB)
386
#  if !defined(NOEGTB)
378
int EGTBProbe(TREE *RESTRICT, int, int, int *);
387
int EGTBProbe(TREE *RESTRICT, int, int, int *);
379
void EGTBPV(TREE *RESTRICT, int);
388
void EGTBPV(TREE *RESTRICT, int);
380
#  endif
389
#  endif
381
int Evaluate(TREE *RESTRICT, int, int, int, int);
390
int Evaluate(TREE *RESTRICT, int, int, int, int);
382
void EvaluateBishops(TREE *RESTRICT, int);
391
void EvaluateBishops(TREE *RESTRICT, int);
383
void EvaluateDevelopment(TREE *RESTRICT, int, int);
392
void EvaluateCastling(TREE *RESTRICT, int, int);
384
int EvaluateDraws(TREE *RESTRICT, int, int, int);
393
int EvaluateDraws(TREE *RESTRICT, int, int, int);
385
int EvaluateHasOpposition(int, int, int);
394
int EvaluateHasOpposition(int, int, int);
386
void EvaluateKings(TREE *RESTRICT, int, int);
395
void EvaluateKing(TREE *RESTRICT, int, int);
387
int EvaluateKingsFile(TREE *RESTRICT, int, int);
396
int EvaluateKingsFile(TREE * RESTRICT, int, int, int);
388
void EvaluateKnights(TREE *RESTRICT, int);
397
void EvaluateKnights(TREE *RESTRICT, int);
389
void EvaluateMate(TREE *RESTRICT, int);
398
void EvaluateMate(TREE *RESTRICT, int);
390
void EvaluateMaterial(TREE *RESTRICT, int);
399
void EvaluateMaterial(TREE *RESTRICT, int);
391
void EvaluatePassedPawns(TREE *RESTRICT, int, int);
400
void EvaluatePassedPawns(TREE *RESTRICT, int, int);
392
void EvaluatePassedPawnRaces(TREE *RESTRICT, int);
401
void EvaluatePassedPawnRaces(TREE *RESTRICT, int);
Line 398... Line 407...
398
int Exclude(TREE *RESTRICT, int, int);
407
int Exclude(TREE *RESTRICT, int, int);
399
int FindBlockID(TREE *RESTRICT);
408
int FindBlockID(TREE *RESTRICT);
400
char *FormatPV(TREE *RESTRICT, int, PATH);
409
char *FormatPV(TREE *RESTRICT, int, PATH);
401
int FTbSetCacheSize(void *, unsigned long);
410
int FTbSetCacheSize(void *, unsigned long);
402
int GameOver(int);
411
int GameOver(int);
403
int *GenerateCaptures(TREE *RESTRICT, int, int, int *);
412
unsigned *GenerateCaptures(TREE *RESTRICT, int, int, unsigned *);
404
int *GenerateCheckEvasions(TREE *RESTRICT, int, int, int *);
413
unsigned *GenerateCheckEvasions(TREE *RESTRICT, int, int, unsigned *);
405
int *GenerateChecks(TREE *RESTRICT, int, int *);
414
unsigned *GenerateChecks(TREE *RESTRICT, int, unsigned *);
406
int *GenerateNoncaptures(TREE *RESTRICT, int, int, int *);
415
unsigned *GenerateNoncaptures(TREE *RESTRICT, int, int, unsigned *);
407
int HashProbe(TREE *RESTRICT, int, int, int, int, int, int*);
-
 
408
void HashStore(TREE *RESTRICT, int, int, int, int, int, int);
-
 
409
void HashStorePV(TREE *RESTRICT, int, int);
416
TREE *GetBlock(TREE *, int);
410
int IInitializeTb(char *);
-
 
411
void Initialize(void);
417
void Initialize(void);
412
void InitializeAttackBoards(void);
418
void InitializeAttackBoards(void);
413
void InitializeChessBoard(TREE *);
419
void InitializeChessBoard(TREE *);
414
int InitializeGetLogID();
420
int InitializeGetLogID();
415
void InitializeHashTables(void);
421
void InitializeHashTables(int);
416
void InitializeKillers(void);
422
void InitializeKillers(void);
417
void InitializeKingSafety(void);
423
void InitializeKingSafety(void);
418
void InitializeMagic(void);
424
void InitializeMagic(void);
419
uint64_t InitializeMagicBishop(int, uint64_t);
425
uint64_t InitializeMagicBishop(int, uint64_t);
420
uint64_t InitializeMagicRook(int, uint64_t);
426
uint64_t InitializeMagicRook(int, uint64_t);
421
uint64_t InitializeMagicOccupied(int *, int, uint64_t);
427
uint64_t InitializeMagicOccupied(int *, int, uint64_t);
422
void InitializeMasks(void);
428
void InitializeMasks(void);
423
void InitializePawnMasks(void);
429
void InitializePawnMasks(void);
-
 
430
void InitializeReductions(void);
424
void InitializeSMP(void);
431
void InitializeSMP(void);
-
 
432
int IInitializeTb(char *);
425
int InputMove(TREE *RESTRICT, char *, int, int, int, int);
433
int InputMove(TREE *RESTRICT, int, int, int, int, char *);
426
int InputMoveICS(TREE *RESTRICT, char *, int, int, int, int);
434
int InputMoveICS(TREE *RESTRICT, int, int, int, int, char *);
427
uint64_t InterposeSquares(int, int, int);
435
uint64_t InterposeSquares(int, int, int);
428
void Interrupt(int);
436
void Interrupt(int);
429
int InvalidPosition(TREE *RESTRICT);
437
int InvalidPosition(TREE *RESTRICT);
430
int Iterate(int, int, int);
438
int Iterate(int, int, int);
-
 
439
int Join(int64_t);
431
void Kibitz(int, int, int, int, int, uint64_t, int, int, char *);
440
void Kibitz(int, int, int, int, int, uint64_t, int, int, char *);
432
void Killer(TREE *RESTRICT, int, int);
441
void History(TREE *RESTRICT, int, int, int, int, int*);
433
int KingPawnSquare(int, int, int, int);
442
int KingPawnSquare(int, int, int, int);
434
int LearnAdjust(int);
443
int LearnAdjust(int);
435
void LearnBook(void);
444
void LearnBook(void);
436
int LearnFunction(int, int, int, int);
445
int LearnFunction(int, int, int, int);
437
void LearnValue(int, int);
446
void LearnValue(int, int);
438
void MakeMove(TREE *RESTRICT, int, int, int);
447
void MakeMove(TREE *RESTRICT, int, int, int);
439
void MakeMoveRoot(TREE *RESTRICT, int, int);
448
void MakeMoveRoot(TREE *RESTRICT, int, int);
440
void NewGame(int);
449
void NewGame(int);
441
int NextEvasion(TREE *RESTRICT, int, int);
-
 
442
int NextMove(TREE *RESTRICT, int, int);
450
int NextMove(TREE *RESTRICT, int, int, int, int);
443
int NextRootMove(TREE *RESTRICT, TREE *RESTRICT, int);
451
int NextRootMove(TREE *RESTRICT, TREE *RESTRICT, int);
444
int NextRootMoveParallel(void);
452
int NextRootMoveParallel(void);
-
 
453
void NextSort(TREE *RESTRICT, int);
445
int Option(TREE *RESTRICT);
454
int Option(TREE *RESTRICT);
446
int OptionMatch(char *, char *);
455
int OptionMatch(char *, char *);
447
void OptionPerft(TREE *RESTRICT, int, int, int);
456
void OptionPerft(TREE *RESTRICT, int, int, int);
448
void Output(TREE *RESTRICT, int);
457
void Output(TREE *RESTRICT);
449
char *OutputMove(TREE *RESTRICT, int, int, int);
458
char *OutputMove(TREE *RESTRICT, int, int, int);
450
int ParseTime(char *);
459
int ParseTime(char *);
451
void Pass(void);
460
void Pass(void);
452
int PinnedOnKing(TREE *RESTRICT, int, int);
461
int PinnedOnKing(TREE *RESTRICT, int, int);
453
int Ponder(int);
462
int Ponder(int);
454
void Print(int, char *, ...);
463
void Print(int, char *, ...);
-
 
464
int HashProbe(TREE *RESTRICT, int, int, int, int, int, int*);
-
 
465
void HashStore(TREE *RESTRICT, int, int, int, int, int, int);
455
char *PrintKM(size_t, int);
466
void HashStorePV(TREE *RESTRICT, int, int);
456
int Quiesce(TREE *RESTRICT, int, int, int, int, int);
467
int Quiesce(TREE *RESTRICT, int, int, int, int, int);
457
int QuiesceEvasions(TREE *RESTRICT, int, int, int, int);
468
int QuiesceEvasions(TREE *RESTRICT, int, int, int, int);
458
unsigned int Random32(void);
469
unsigned Random32(void);
459
uint64_t Random64(void);
470
uint64_t Random64(void);
460
int Read(int, char *, size_t); // Pierre-Marie Baty -- sanitize buffer ops
471
int Read(int, char *);
461
int ReadChessMove(TREE *RESTRICT, FILE *, int, int);
472
int ReadChessMove(TREE *RESTRICT, FILE *, int, int);
462
void ReadClear(void);
473
void ReadClear(void);
463
unsigned int ReadClock(void);
474
unsigned ReadClock(void);
464
int ReadPGN(FILE *, int);
475
int ReadPGN(FILE *, int);
465
int ReadNextMove(TREE *RESTRICT, char *, int, int);
476
int ReadNextMove(TREE *RESTRICT, char *, int, int);
466
int ReadParse(char *, char *args[], char *);
477
int ReadParse(char *, char *args[], char *);
467
int ReadInput(void);
478
int ReadInput(void);
468
int Repeat(TREE *RESTRICT, int);
479
int Repeat(TREE *RESTRICT, int);
469
int Repeat3x(TREE *RESTRICT, int);
480
int Repeat3x(TREE *RESTRICT);
470
void ResignOrDraw(TREE *RESTRICT, int);
481
void ResignOrDraw(TREE *RESTRICT, int);
471
void RestoreGame(void);
482
void RestoreGame(void);
472
void RootMoveList(int);
483
void RootMoveList(int);
473
int Search(TREE *RESTRICT, int, int, int, int, int, int);
484
int Search(TREE *RESTRICT, int, int, int, int, int, int, int);
-
 
485
int SearchMove(TREE *RESTRICT, int, int, int, int, int, int, int, int, int);
-
 
486
int SearchMoveList(TREE *RESTRICT, int, int, int, int, int, int *, int, int, int);
474
int SearchParallel(TREE *RESTRICT, int, int, int, int, int, int);
487
int SearchNull(TREE * RESTRICT, int, int, int, int);
475
void Trace(TREE *RESTRICT, int, int, int, int, int, const char *, int);
488
void Trace(TREE *RESTRICT, int, int, int, int, int, const char *, int, int, int);
476
void SetBoard(TREE *, int, char **, int);
489
void SetBoard(TREE *, int, char **, int);
477
void SetChessBitBoards(TREE *);
490
void SetChessBitBoards(TREE *);
478
void SharedFree(void *address);
491
void SharedFree(void *address);
-
 
492
void SortRootMoves(void);
-
 
493
int Split(TREE *RESTRICT);
479
int StrCnt(char *, char);
494
int StrCnt(char *, char);
480
int Swap(TREE *RESTRICT, int, int);
495
int SEE(TREE *RESTRICT, int, int);
481
int SwapO(TREE *RESTRICT, int, int);
496
int SEEO(TREE *RESTRICT, int, int);
482
void Test(char *);
497
void Test(char *, FILE *, int, int);
483
void TestEPD(char *);
498
void TestEPD(char *, FILE *, int, int);
484
int Thread(TREE *RESTRICT);
499
void ThreadAffinity(int);
485
void WaitForAllThreadsInitialized(void);
-
 
486
void *STDCALL ThreadInit(void *);
500
void *STDCALL ThreadInit(void *);
487
#  if !defined(UNIX)
501
#  if !defined(UNIX)
488
void ThreadMalloc(int64_t);
502
void ThreadMalloc(int64_t);
489
#  endif
503
#  endif
-
 
504
int ThreadSplit(TREE *RESTRICT, int, int, int, int, int);
490
void ThreadStop(TREE *RESTRICT);
505
void ThreadStop(TREE *RESTRICT);
-
 
506
void ThreadTrace(TREE * RESTRICT, int, int);
491
int ThreadWait(int64_t, TREE *RESTRICT);
507
int ThreadWait(int, TREE *RESTRICT);
-
 
508
int Threat(TREE *, int, int, int, int);
492
void TimeAdjust(int, int);
509
void TimeAdjust(int, int);
493
int TimeCheck(TREE *RESTRICT, int);
510
int TimeCheck(TREE *RESTRICT, int);
494
void TimeSet(int);
511
void TimeSet(int);
495
void UnmakeMove(TREE *RESTRICT, int, int, int);
512
void UnmakeMove(TREE *RESTRICT, int, int, int);
496
int ValidMove(TREE *RESTRICT, int, int, int);
513
int ValidMove(TREE *RESTRICT, int, int, int);
497
int VerifyMove(TREE *RESTRICT, int, int, int);
514
int VerifyMove(TREE *RESTRICT, int, int, int);
498
void ValidatePosition(TREE *RESTRICT, int, int, char *);
515
void ValidatePosition(TREE *RESTRICT, int, int, char *);
-
 
516
void WaitForAllThreadsInitialized(void);
499
#  if !defined(UNIX)
517
#  if !defined(UNIX)
500
extern void *WinMallocInterleaved(size_t, int);
518
extern void *WinMallocInterleaved(size_t, int);
501
extern void WinFreeInterleaved(void *, size_t);
519
extern void WinFreeInterleaved(void *, size_t);
502
#    define MallocInterleaved(cBytes, cThreads)\
520
#    define MallocInterleaved(cBytes, cThreads)     \
503
    WinMallocInterleaved(cBytes, cThreads)
521
       WinMallocInterleaved(cBytes, cThreads)
504
#    define FreeInterleaved(pMemory, cBytes)\
522
#    define FreeInterleaved(pMemory, cBytes)        \
505
    WinFreeInterleaved(pMemory, cBytes)
523
       WinFreeInterleaved(pMemory, cBytes)
506
#  else
524
#  else
507
#    if defined(NUMA)
525
#    if defined(NUMA)
508
#      define MallocInterleaved(cBytes, cThreads) numa_alloc_interleaved(cBytes)
526
#      define MallocInterleaved(cBytes, cThreads) numa_alloc_interleaved(cBytes)
509
#      define FreeInterleaved(pMemory, cBytes)    numa_free(pMemory, 1)
527
#      define FreeInterleaved(pMemory, cBytes)          numa_free(pMemory, 1)
510
#    else
528
#    else
511
#      define MallocInterleaved(cBytes, cThreads) malloc(cBytes)
529
#      define MallocInterleaved(cBytes, cThreads) malloc(cBytes)
512
#      define FreeInterleaved(pMemory, cBytes)    free(pMemory)
530
#      define FreeInterleaved(pMemory, cBytes)          free(pMemory)
513
#    endif
531
#    endif
514
#  endif
532
#  endif
515
#  define Abs(a)    (((a) > 0) ? (a) : -(a))
533
#  define Abs(a)    (((a) > 0) ? (a) : -(a))
516
#  define Max(a,b)  (((a) > (b)) ? (a) : (b))
534
#  define Max(a,b)  (((a) > (b)) ? (a) : (b))
517
#  define Min(a,b)  (((a) < (b)) ? (a) : (b))
535
#  define Min(a,b)  (((a) < (b)) ? (a) : (b))
-
 
536
#  define Sign(a)   ((a) < 0 ? -1 : +1)
518
#  define FileDistance(a,b) abs(File(a) - File(b))
537
#  define FileDistance(a,b) abs(File(a) - File(b))
519
#  define RankDistance(a,b) abs(Rank(a) - Rank(b))
538
#  define RankDistance(a,b) abs(Rank(a) - Rank(b))
520
#  define Distance(a,b) Max(FileDistance(a,b), RankDistance(a,b))
539
#  define Distance(a,b) Max(FileDistance(a,b), RankDistance(a,b))
521
#  define DrawScore(side)                 (draw_score[side])
540
#  define DrawScore(side)                  (draw_score[side])
522
#  define PopCnt8Bit(a) (pop_cnt_8bit[a])
541
#  define PopCnt8Bit(a) (pop_cnt_8bit[a])
523
#  define MSB8Bit(a) (msb_8bit[a])
542
#  define MSB8Bit(a) (msb_8bit[a])
524
#  define LSB8Bit(a) (lsb_8bit[a])
543
#  define LSB8Bit(a) (lsb_8bit[a])
-
 
544
#  define HistoryIndex(side, m) ((side << 9) + (Piece(m) << 6) + To(m))
525
/*
545
/*
526
  side = side to move
546
   side = side to move
527
  mptr = pointer into move list
547
   mptr = pointer into move list
528
  m = bit vector of to squares to unpack
548
   m = bit vector of to squares to unpack
529
  t = pre-computed from + moving piece
549
   t = pre-computed from + moving piece
530
 */
550
 */
531
#  define Extract(side, mptr, m, t)                                        \
551
#  define Extract(side, mptr, m, t)                                         \
532
  for ( ; m ; Clear(to, m)) {                                              \
552
  for ( ; m ; Clear(to, m)) {                                               \
533
    to = Advanced(side, m);                                                \
553
    to = MostAdvanced(side, m);                                             \
534
    *mptr++ = t | (to << 6) | (Abs(PcOnSq(to)) << 15);                     \
554
    *mptr++ = t | (to << 6) | (Abs(PcOnSq(to)) << 15);                      \
535
  }
555
  }
536
#  define Check(side) Attacks(tree, Flip(side), KingSQ(side))
556
#  define Check(side) Attacks(tree, Flip(side), KingSQ(side))
537
#  define Attack(from,to) (!(intervening[from][to] & OccupiedSquares))
557
#  define Attack(from,to) (!(intervening[from][to] & OccupiedSquares))
538
#  define BishopAttacks(square, occ) *(magic_bishop_indices[square]+((((occ)&magic_bishop_mask[square])*magic_bishop[square])>>magic_bishop_shift[square]))
558
#  define BishopAttacks(square, occ) *(magic_bishop_indices[square]+((((occ)&magic_bishop_mask[square])*magic_bishop[square])>>magic_bishop_shift[square]))
539
#  define BishopMobility(square, occ) *(magic_bishop_mobility_indices[square]+((((occ)&magic_bishop_mask[square])*magic_bishop[square])>>magic_bishop_shift[square]))
559
#  define BishopMobility(square, occ) *(magic_bishop_mobility_indices[square]+((((occ)&magic_bishop_mask[square])*magic_bishop[square])>>magic_bishop_shift[square]))
Line 542... Line 562...
542
#  define PawnAttacks(side, square)   pawn_attacks[side][square]
562
#  define PawnAttacks(side, square)   pawn_attacks[side][square]
543
#  define Reversible(p)               (tree->status[p].reversible)
563
#  define Reversible(p)               (tree->status[p].reversible)
544
#  define RookAttacks(square, occ) *(magic_rook_indices[square]+((((occ)&magic_rook_mask[square])*magic_rook[square])>>magic_rook_shift[square]))
564
#  define RookAttacks(square, occ) *(magic_rook_indices[square]+((((occ)&magic_rook_mask[square])*magic_rook[square])>>magic_rook_shift[square]))
545
#  define RookMobility(square, occ) *(magic_rook_mobility_indices[square]+((((occ)&magic_rook_mask[square])*magic_rook[square])>>magic_rook_shift[square]))
565
#  define RookMobility(square, occ) *(magic_rook_mobility_indices[square]+((((occ)&magic_rook_mask[square])*magic_rook[square])>>magic_rook_shift[square]))
546
#  define QueenAttacks(square, occ)   (BishopAttacks(square, occ)|RookAttacks(square, occ))
566
#  define QueenAttacks(square, occ)   (BishopAttacks(square, occ)|RookAttacks(square, occ))
547
#  define Rank(x)       ((x)>>3)
567
#  define Rank(x)        ((x)>>3)
548
#  define File(x)       ((x)&7)
568
#  define File(x)        ((x)&7)
549
#  define Flip(x)       ((x)^1)
569
#  define Flip(x)        ((x)^1)
550
#  define Advanced(side, squares) ((side) ? MSB(squares) : LSB(squares))
570
#  define MostAdvanced(side, squares) ((side) ? MSB(squares) : LSB(squares))
-
 
571
#  define LeastAdvanced(side, squares) ((side) ? LSB(squares) : MSB(squares))
551
#  define MinMax(side, v1, v2) ((side) ? Min((v1), (v2)) : Max((v1), (v2)))
572
#  define MinMax(side, v1, v2) ((side) ? Min((v1), (v2)) : Max((v1), (v2)))
552
#  define InFront(side, k, p) ((side) ? k > p : k < p)
573
#  define InFront(side, k, p) ((side) ? k > p : k < p)
553
#  define Behind(side, k, p) ((side) ? k < p : k > p)
574
#  define Behind(side, k, p) ((side) ? k < p : k > p)
-
 
575
#  define Passed(sq, wtm)        (!(mask_passed[wtm][sq] & Pawns(Flip(wtm))))
554
#  define RankAttacks(a) (RookAttacks(a, OccupiedSquares) & rank_mask[Rank(a)])
576
#  define RankAttacks(a) (RookAttacks(a, OccupiedSquares) & rank_mask[Rank(a)])
555
#  define FileAttacks(a) (RookAttacks(a, OccupiedSquares) & file_mask[File(a)])
577
#  define FileAttacks(a) (RookAttacks(a, OccupiedSquares) & file_mask[File(a)])
556
#  define Diaga1Attacks(a) (BishopAttacks(a, OccupiedSquares) & (plus9dir[a] | minus9dir[a]))
578
#  define Diaga1Attacks(a) (BishopAttacks(a, OccupiedSquares) & (plus9dir[a] | minus9dir[a]))
557
#  define Diagh1Attacks(a) (BishopAttacks(a, OccupiedSquares) & (plus7dir[a] | minus7dir[a]))
579
#  define Diagh1Attacks(a) (BishopAttacks(a, OccupiedSquares) & (plus7dir[a] | minus7dir[a]))
558
#  define InterposeSquares(kingsq, checksq) intervening[kingsq][checksq]
580
#  define InterposeSquares(kingsq, checksq) intervening[kingsq][checksq]
559
/*
581
/*
560
   the following macros are used to extract the pieces of a move that are
582
   the following macros are used to extract the pieces of a move that are
561
   kept compressed into the rightmost 21 bits of a simple integer.
583
   kept compressed into the rightmost 21 bits of a simple integer.
562
 */
584
 */
563
#  define Passed(sq, wtm)       (!(mask_passed[wtm][sq] & Pawns(Flip(wtm))))
-
 
564
#  define From(a)               ((a) & 63)
585
#  define From(a)               ((a) & 63)
565
#  define To(a)                 (((a)>>6) & 63)
586
#  define To(a)                 (((a)>>6) & 63)
566
#  define Piece(a)              (((a)>>12) & 7)
587
#  define Piece(a)              (((a)>>12) & 7)
567
#  define Captured(a)           (((a)>>15) & 7)
588
#  define Captured(a)           (((a)>>15) & 7)
568
#  define Promote(a)            (((a)>>18) & 7)
589
#  define Promote(a)            (((a)>>18) & 7)
-
 
590
#  define Move(a)               (a & 0x1fffff)
-
 
591
#  define SortV(a)              (a >> 21)
569
#  define CaptureOrPromote(a)   (((a)>>15) & 63)
592
#  define CaptureOrPromote(a)   (((a)>>15) & 63)
-
 
593
#  define PawnPush(c, a)        (Piece(a) == pawn &&                          \
-
 
594
                                     rankflip[c][Rank(To(a))] >= RANK6        \
-
 
595
                                     && !(mask_passed[c][To(a)] &             \
-
 
596
                                          Pawns(Flip(c))))
-
 
597
#  define CastleMove(c, a)       (Piece(a) == king && Abs(File(To(a)) -       \
-
 
598
                                     File(From(a))) > 1)
570
#  define SetMask(a)            (set_mask[a])
599
#  define SetMask(a)             (set_mask[a])
571
#  define ClearMask(a)          (clear_mask[a])
600
#  define ClearMask(a)           (clear_mask[a])
572
#  define Pawns(c)              (tree->position.color[c].pieces[pawn])
601
#  define Pawns(c)               (tree->position.color[c].pieces[pawn])
573
#  define Knights(c)            (tree->position.color[c].pieces[knight])
602
#  define Knights(c)             (tree->position.color[c].pieces[knight])
574
#  define Bishops(c)            (tree->position.color[c].pieces[bishop])
603
#  define Bishops(c)             (tree->position.color[c].pieces[bishop])
575
#  define Rooks(c)              (tree->position.color[c].pieces[rook])
604
#  define Rooks(c)               (tree->position.color[c].pieces[rook])
576
#  define Queens(c)             (tree->position.color[c].pieces[queen])
605
#  define Queens(c)              (tree->position.color[c].pieces[queen])
577
#  define Kings(c)              (tree->position.color[c].pieces[king])
606
#  define Kings(c)               (tree->position.color[c].pieces[king])
578
#  define KingSQ(c)             (tree->position.kingsq[c])
607
#  define KingSQ(c)              (tree->position.kingsq[c])
579
#  define Occupied(c)           (tree->position.color[c].pieces[occupied])
608
#  define Occupied(c)            (tree->position.color[c].pieces[occupied])
580
#  define Pieces(c, p)          (tree->position.color[c].pieces[p])
609
#  define Pieces(c, p)           (tree->position.color[c].pieces[p])
581
#  define TotalPieces(c, p)     (tree->position.pieces[c][p])
610
#  define TotalPieces(c, p)      (tree->position.pieces[c][p])
582
#  define TotalMinors(c)        (tree->position.minors[c])
-
 
583
#  define TotalMajors(c)        (tree->position.majors[c])
-
 
584
#  define PieceValues(c, p)     (piece_values[p][c])
611
#  define PieceValues(c, p)      (piece_values[c][p])
585
#  define TotalAllPieces        (tree->position.total_all_pieces)
612
#  define TotalAllPieces         (tree->position.total_all_pieces)
586
#  define Material              (tree->position.material_evaluation)
613
#  define Material               (tree->position.material_evaluation)
587
#  define MaterialSTM(side)     ((side) ? Material : -Material)
614
#  define MaterialSTM(side)      ((side) ? Material : -Material)
588
#  define MateScore(s)          (Abs(s) > 32000)
615
#  define MateScore(s)           (Abs(s) > 32000)
589
#  define Castle(ply, c)        (tree->status[ply].castle[c])
616
#  define Castle(ply, c)         (tree->status[ply].castle[c])
590
#  define HashKey               (tree->position.hash_key)
617
#  define HashKey                (tree->position.hash_key)
591
#  define PawnHashKey           (tree->position.pawn_hash_key)
618
#  define PawnHashKey            (tree->position.pawn_hash_key)
592
#  define EnPassant(ply)        (tree->status[ply].enpassant_target)
619
#  define EnPassant(ply)         (tree->status[ply].enpassant_target)
593
#  define EnPassantTarget(ply)  (EnPassant(ply) ? SetMask(EnPassant(ply)) : 0)
620
#  define EnPassantTarget(ply)   (EnPassant(ply) ? SetMask(EnPassant(ply)) : 0)
594
#  define PcOnSq(sq)            (tree->position.board[sq])
621
#  define PcOnSq(sq)             (tree->position.board[sq])
595
#  define OccupiedSquares       (Occupied(white) | Occupied(black))
622
#  define OccupiedSquares        (Occupied(white) | Occupied(black))
596
#  define Color(square)         (square_color[square] ? dark_squares : ~dark_squares)
623
#  define Color(square)       (square_color[square] ? dark_squares : ~dark_squares)
597
#  define SideToMove(c)         ((c) ? "White" : "Black")
624
#  define SideToMove(c)          ((c) ? "White" : "Black")
598
/*
625
/*
599
   the following macros are used to Set and Clear a specific bit in the
626
   the following macros are used to Set and Clear a specific bit in the
600
   second argument.  this is done to make the code more readable, rather
627
   second argument.  this is done to make the code more readable, rather
601
   than to make it faster.
628
   than to make it faster.
602
 */
629
 */
Line 608... Line 635...
608
 */
635
 */
609
#  define Hash(stm,piece,square)     (HashKey^=randoms[stm][piece][square])
636
#  define Hash(stm,piece,square)     (HashKey^=randoms[stm][piece][square])
610
#  define HashP(stm,square)          (PawnHashKey^=randoms[stm][pawn][square])
637
#  define HashP(stm,square)          (PawnHashKey^=randoms[stm][pawn][square])
611
#  define HashCastle(stm,direction)  (HashKey^=castle_random[stm][direction])
638
#  define HashCastle(stm,direction)  (HashKey^=castle_random[stm][direction])
612
#  define HashEP(sq)                 (HashKey^=enpassant_random[sq])
639
#  define HashEP(sq)                 (HashKey^=enpassant_random[sq])
613
#  define SavePV(tree,ply,ph)   do {                                        \
640
#  define SavePV(tree,ply,ph)        do {                                     \
614
        tree->pv[ply-1].path[ply-1]=tree->curmv[ply-1];                     \
641
        tree->pv[ply-1].path[ply-1]=tree->curmv[ply-1];                       \
615
        tree->pv[ply-1].pathl=ply;                          \
642
        tree->pv[ply-1].pathl=ply;                                            \
616
        tree->pv[ply-1].pathh=ph;                           \
643
        tree->pv[ply-1].pathh=ph;                                             \
617
        tree->pv[ply-1].pathd=iteration_depth;} while(0)
644
        tree->pv[ply-1].pathd=iteration;} while(0)
618
#  if defined(INLINEASM)
645
#  if defined(INLINEASM)
619
#    include "inline.h"
646
#    include "inline.h"
620
#  endif
-
 
621
#  if defined(UNIX)
-
 
622
#    define SPEAK "./speak "
-
 
623
#  else
-
 
624
#    define SPEAK ".\\Speak.exe "
-
 
625
#  endif
647
#  endif
626
#endif
648
#endif
627
/* *INDENT-ON* */
649
/* *INDENT-ON* */