Skip to content

Commit 6215f3a

Browse files
committed
Extend checks before qSearch
+ 20 Elo self play (should break the 2200 barrier yay!)
1 parent 8e9312b commit 6215f3a

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exit(1);}
2323

2424
typedef unsigned long long U64;
2525

26-
#define NAME "SeeChess v1.1"
26+
#define NAME "SeeChess v1.2"
2727
#define BRD_SQ_NUM 120
2828

2929
#define MAXGAMEMOVES 2048

search.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,7 @@
33
#include "stdio.h"
44
#include "defs.h"
55
#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"
227

238
static void CheckUp(S_SEARCHINFO *info) {
249
// .. 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
177162
ASSERT(beta>alpha);
178163
ASSERT(depth>=0);
179164

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+
180172
if(depth <= 0) {
181173
return Quiescence(alpha, beta, pos, info);
182174
// return EvalPosition(pos);
@@ -196,20 +188,13 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
196188
return EvalPosition(pos);
197189
}
198190

199-
// Mate Distance Pruning
191+
// Mate Distance Pruning (finds shorter mates)
200192
alpha = MAX(alpha, -INFINITE + pos->ply);
201193
beta = MIN(beta, INFINITE - pos->ply);
202194
if (alpha >= beta) {
203195
return alpha;
204196
}
205197

206-
const int InCheck = SqAttacked(pos->KingSq[pos->side],pos->side^1,pos);
207-
208-
// Check Extension
209-
if(InCheck) {
210-
depth++;
211-
}
212-
213198
int Score = -INFINITE;
214199
int PvMove = NOMOVE;
215200

@@ -220,7 +205,7 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
220205

221206
const int positionEval = EvalPosition(pos);
222207

223-
// Razoring (alpha)
208+
// Razoring (alpha) (+50 ELO)
224209
if (depth <= RazorDepth && !PvMove && !InCheck && positionEval + RazorMargin[depth] <= alpha) {
225210
// drop into qSearch if move most likely won't beat alpha
226211
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
230215
}
231216
}
232217

233-
// Reverse Futility Pruning (beta)
218+
// Reverse Futility Pruning (beta) (+20 ELO)
234219
if (depth <= RevFutilityDepth && !PvMove && !InCheck && abs(beta) < ISMATE && positionEval - RevFutilityMargin[depth] >= beta) {
235220
info->nodesPruned++;
236221
return positionEval - RevFutilityMargin[depth];
@@ -286,7 +271,7 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
286271
Legal++;
287272
// PVS (speeds up search with good move ordering)
288273
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)
290275
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)) {
291276
const int reduce = log(depth) * log(Legal) / 1.7;
292277
Score = -AlphaBeta( -alpha - 1, -alpha, depth - 1 - reduce, pos, info, TRUE, FALSE);

search.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef SEARCH_H
2+
#define SEARCH_H
3+
4+
// ALl search constants
5+
6+
// Null Move Pruning Values
7+
const int R = 2;
8+
const int minDepth = 3;
9+
10+
// Razoring Values
11+
const int RazorDepth = 3;
12+
const int RazorMargin[4] = {0, 200, 400, 600};
13+
14+
// Reverse Futility Values
15+
const int RevFutilityDepth = 3;
16+
const int RevFutilityMargin[4] = {0, 350, 500, 950};
17+
18+
// LMR Values
19+
const int LateMoveDepth = 3;
20+
const int FullSearchMoves = 4;
21+
22+
#endif

seeChess.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)