Skip to content

Commit c96d800

Browse files
committed
selective depth
1 parent 84af41c commit c96d800

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static const clock_t CPMS = CLOCKS_PER_SEC/1000;
102102
typedef struct CONTROL {
103103
clock_t wtime, btime, wtime_inc, btime_inc;
104104
clock_t init_time, wish_time, max_time;
105-
unsigned int max_depth;
105+
unsigned int max_depth, seldepth;
106106
unsigned long long node_count;
107107
char uci, stop, ponder;
108108
MOVE best_move;

fen.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ int ReadFEN(const char *sFEN, BOARD *board)
111111
/*halfmoves and moves.*/
112112
int rev = atoi(&sFEN[fen_pos]);
113113
while(sFEN[++fen_pos] != ' ');
114-
board->ply = atoi(&sFEN[fen_pos]);
114+
board->ply = 2*atoi(&sFEN[fen_pos]) - board->white_to_move - 1;
115115
board->rev_plies[board->ply] = rev;
116116
InitZobrist(board);
117+
board->zobrist_history[board->ply] = board->zobrist_key;
117118
InitMaterial(board);
118119
return fen_pos;
119120
}

search.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int RetrievePV(BOARD *board, MOVE *PV, unsigned int depth)
5454
return PVlen;
5555
}
5656

57-
static int AssesDraw(const BOARD *board)
57+
static int AssessDraw(const BOARD *board)
5858
{
5959
if(board->rev_plies[board->ply] >= 50) {
6060
return DRAW_VALUE;
@@ -78,6 +78,7 @@ static int Quiescent(BOARD *board, int alpha, int beta, int root, CONTROL *contr
7878
control->stop = 1;
7979
}
8080

81+
if(root > control->seldepth) control->seldepth = root;
8182
val = LazyEval(board);
8283
if(val-LAZYBETA >= beta) return beta;
8384
if(val+LAZYALPHA < alpha) return alpha;
@@ -122,6 +123,7 @@ static int AlphaBeta(BOARD *board, unsigned int depth, int alpha, int beta,
122123
int reduce = 0, LMR = 0;
123124

124125
if(depth){
126+
if(root > control->seldepth) control->seldepth = root;
125127
if(root > 0){
126128
val = GetHashEval(&hash_table, board->zobrist_key, depth, alpha, beta);
127129
if(val != ERRORVALUE) return val;
@@ -147,12 +149,12 @@ static int AlphaBeta(BOARD *board, unsigned int depth, int alpha, int beta,
147149
if(!control->best_move) control->best_move = moves[i]; /* Better than nothing. */
148150
if(depth > 6 && !control->ponder){
149151
MoveToAlgeb(moves[i], str_mov);
150-
printf("info depth %i hashfull %i currmove %s currmovenumber %i\n",
151-
depth, hash_table.full/(hash_table.size/1000), str_mov, i+1);
152+
printf("info depth %i seldepth %i hashfull %i currmove %s currmovenumber %i\n",
153+
depth, control->seldepth, hash_table.full/(hash_table.size/1000), str_mov, i+1);
152154
}
153155
}
154156
nlegal++;
155-
val = AssesDraw(board);
157+
val = AssessDraw(board);
156158
if(val) {
157159
if(best_move){
158160
LMR = (reduce && i > good && !CAPTMASK(moves[i]) && !InCheck(board, 0)) ? 1 : 0;
@@ -227,6 +229,7 @@ void IterativeDeep(BOARD *board, CONTROL *control)
227229
clock_t curr_time = clock();
228230
memset(sPV, 0, SPVLEN);
229231
control->node_count = 0;
232+
control->seldepth = 0;
230233

231234
eval = AlphaBeta(board, depth, alpha, beta, 0, control, 1, killers);
232235
if(control->stop && !control->ponder){

0 commit comments

Comments
 (0)