1 /***************************************************************************
2 platform.h - Platoform dependent utilities
4 begin : Sun Oct 07 2007
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
26 /* a prime number. Probably no good reason, i just like primes */
27 // #define PLUTO_SIZE ((1<<16)+1)
28 // #define MP(_x) ({int x = _x; x = (x - (x>>16))&0xffff; x<0?x+PLUTO_SIZE:x;})
29 //#define PLUTO_SIZE 577177
30 #define PLUTO_SIZE 277177
31 #define MP(x) ((int)(((unsigned int)(x))%PLUTO_SIZE))
33 #define CAPT_INDEX(m) ({Move _m=(m);_m.capture*128*128 + _m.from*128 + _m.to;})
34 #define PLUTO_INDEX(a,b) MP(CAPT_INDEX(a)*9829+CAPT_INDEX(b))
35 #define PLUTO2_INDEX(a,b,c) MP(CAPT_INDEX(a)*9829+CAPT_INDEX(b)*67+CAPT_INDEX(c))
36 //#define PLUTO2_INDEX(a,b,c) (CAPT_INDEX(a)*9829+CAPT_INDEX(b)*49+CAPT_INDEX(c))%PLUTO_SIZE
38 #define PLUTO1(a) MP(CAPT_INDEX(a)*9829)
39 #define PLUTO2(a,b) MP(CAPT_INDEX(a)*9829+CAPT_INDEX(b)*67)
40 #define FAST_PLUTO(p,m) MP(p+m)
42 #define HISTORY_SIZE (64*64)
43 #define HISTORY_INDEX(m) (SQUARE_TO_64(m.from)*64 + SQUARE_TO_64(m.to))
45 #define WORST_MATE (INF-5000)
53 Move
*moves
; /* generated moves */
54 int num_moves
; /* num of moves */
55 int curr_move
; /* the move being currently analyzed */
60 bool null_threat_dangerous
;
61 uint8_t escape_from
[2];
64 Move mv_stack
[200*MAX_PV
];
66 SearchStack stack
[MAX_PV
];
72 SearchGui
*search_gui
;
76 static uint16_t pluto_tot
[PLUTO_SIZE
];
77 static uint16_t pluto_hit
[PLUTO_SIZE
];
78 static uint16_t pluto2_tot
[PLUTO_SIZE
];
79 static uint16_t pluto2_hit
[PLUTO_SIZE
];
80 static uint16_t history_tot
[HISTORY_SIZE
];
81 static uint16_t history_hit
[HISTORY_SIZE
];
83 bool check_draw(int curr_ply
);
84 bool check_repetition(int curr_ply
, int nfold
);
86 void moves_heuristic(Move
*mv
, int num_mv
, bool pv
, int ply
,
87 int orig_depth
, Move best_mv_hash
, bool quiesce
,
88 Move
* prev
, int* overall_extensions
,
90 void moves_quiescence_heuristic(Move
*mv
, int num_mv
, const Move
& hash
,
91 int static_eval
, int alpha
, int beta
, int depth
, Move
* prev
);
92 int16_t search(int ply
, int depth
, bool pv
,
93 int16_t alpha
, int16_t beta
, bool expect_allbad
);
94 SearchRoot(Engine
* e
, const Board
& b
);