3
3
#include "stdio.h"
4
4
#include "defs.h"
5
5
#include "math.h"
6
-
7
- // Null Move Pruning Values
8
- static const int R = 2 ;
9
- static const int minDepth = 3 ;
10
-
11
- // Razoring Values
12
- static const int RazorDepth = 3 ;
13
- static const int RazorMargin [4 ] = {0 , 200 , 400 , 600 };
14
-
15
- // Reverse Futility Values
16
- static const int RevFutilityDepth = 3 ;
17
- static const int RevFutilityMargin [4 ] = {0 , 350 , 500 , 950 };
18
-
19
- // LMR Values
20
- static const int LateMoveDepth = 3 ;
21
- static const int FullSearchMoves = 4 ;
6
+ #include "search.h"
22
7
23
8
static void CheckUp (S_SEARCHINFO * info ) {
24
9
// .. check if time up, or interrupt from GUI
@@ -177,6 +162,13 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
177
162
ASSERT (beta > alpha );
178
163
ASSERT (depth >=0 );
179
164
165
+ const int InCheck = SqAttacked (pos -> KingSq [pos -> side ],pos -> side ^1 ,pos );
166
+
167
+ // Check Extension (Extend all checks before dropping into Quiescence (+20 ELO Selfplay) (most likely gains less with a good king safety evaluation))
168
+ if (InCheck ) {
169
+ depth ++ ;
170
+ }
171
+
180
172
if (depth <= 0 ) {
181
173
return Quiescence (alpha , beta , pos , info );
182
174
// return EvalPosition(pos);
@@ -196,20 +188,13 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
196
188
return EvalPosition (pos );
197
189
}
198
190
199
- // Mate Distance Pruning
191
+ // Mate Distance Pruning (finds shorter mates)
200
192
alpha = MAX (alpha , - INFINITE + pos -> ply );
201
193
beta = MIN (beta , INFINITE - pos -> ply );
202
194
if (alpha >= beta ) {
203
195
return alpha ;
204
196
}
205
197
206
- const int InCheck = SqAttacked (pos -> KingSq [pos -> side ],pos -> side ^1 ,pos );
207
-
208
- // Check Extension
209
- if (InCheck ) {
210
- depth ++ ;
211
- }
212
-
213
198
int Score = - INFINITE ;
214
199
int PvMove = NOMOVE ;
215
200
@@ -220,7 +205,7 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
220
205
221
206
const int positionEval = EvalPosition (pos );
222
207
223
- // Razoring (alpha)
208
+ // Razoring (alpha) (+50 ELO)
224
209
if (depth <= RazorDepth && !PvMove && !InCheck && positionEval + RazorMargin [depth ] <= alpha ) {
225
210
// drop into qSearch if move most likely won't beat alpha
226
211
Score = Quiescence (alpha - RazorMargin [depth ], beta - RazorMargin [depth ], pos , info );
@@ -230,7 +215,7 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
230
215
}
231
216
}
232
217
233
- // Reverse Futility Pruning (beta)
218
+ // Reverse Futility Pruning (beta) (+20 ELO)
234
219
if (depth <= RevFutilityDepth && !PvMove && !InCheck && abs (beta ) < ISMATE && positionEval - RevFutilityMargin [depth ] >= beta ) {
235
220
info -> nodesPruned ++ ;
236
221
return positionEval - RevFutilityMargin [depth ];
@@ -286,7 +271,7 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
286
271
Legal ++ ;
287
272
// PVS (speeds up search with good move ordering)
288
273
if (FoundPv == TRUE) {
289
- // Late Move Reductions (reduces quiet moves if past full move search limit (not reducing checks, captures, promotions, and killers))
274
+ // Late Move Reductions (reduces quiet moves if past full move search limit (not reducing checks, captures, promotions, and killers)) (+60 ELO)
290
275
if (depth >= LateMoveDepth && !(list -> moves [MoveNum ].move & MFLAGCAP ) && !(list -> moves [MoveNum ].move & MFLAGPROM ) && !SqAttacked (pos -> KingSq [pos -> side ],pos -> side ^1 ,pos ) && DoLMR && Legal > FullSearchMoves && !(list -> moves [MoveNum ].score == 800000 || list -> moves [MoveNum ].score == 900000 )) {
291
276
const int reduce = log (depth ) * log (Legal ) / 1.7 ;
292
277
Score = - AlphaBeta ( - alpha - 1 , - alpha , depth - 1 - reduce , pos , info , TRUE, FALSE);
0 commit comments