Skip to content

Commit 9522d00

Browse files
authored
Merge pull request #6 from bctboi23/Pruning-improvement
Futility pruning + code cleanup
2 parents 160f699 + 9df2ba0 commit 9522d00

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

bin/CeeChess-v1.3.1.exe

0 Bytes
Binary file not shown.

src/search.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ static const int R = 2;
99
static const int minDepth = 3;
1010

1111
// Razoring Values
12-
static const int RazorDepth = 3;
13-
static const int RazorMargin[4] = {0, 200, 400, 600};
12+
static const int RazorDepth = 2;
13+
static const int RazorMargin[3] = {0, 200, 400};
1414

1515
// Futility Values
16-
static const int FutilityDepth = 5;
17-
static const int FutilityMargin[6] = {0, 200, 325, 450, 575, 700};
16+
static const int FutilityDepth = 6;
17+
static const int FutilityMargin[7] = {0, 200, 325, 450, 575, 700, 825};
1818

1919
// Reverse Futility Values
2020
static const int RevFutilityDepth = 4;
2121
static const int RevFutilityMargin[5] = {0, 250, 500, 750, 1000};
2222

2323
// LMR Values
2424
static const int LateMoveDepth = 3;
25-
static const int FullSearchMoves = 3;
25+
static const int FullSearchMoves = 4;
2626
int LMRTable[64][64];
2727

2828
void InitSearch() {
2929
// creating the LMR table entries (idea from Ethereal)
3030
for (int moveDepth = 1; moveDepth < 64; moveDepth++)
3131
for (int played = 1; played < 64; played++)
32-
LMRTable[moveDepth][played] = 1 + (log(moveDepth) * log(played) / 1.9);
32+
LMRTable[moveDepth][played] = 1 + (log(moveDepth) * log(played) / 1.7);
3333
}
3434

3535
static void CheckUp(S_SEARCHINFO *info) {
@@ -284,23 +284,23 @@ static int AlphaBeta(int alpha, int beta, int depth, S_BOARD *pos, S_SEARCHINFO
284284

285285
int FoundPv = FALSE;
286286

287-
// Futility pruning flag (if this flag is on, prune at the futile node)
287+
// Futility Pruning flag (if node is futile (unlikely to raise alpha), this flag is set)
288288
int FutileNode = (depth <= FutilityDepth && positionEval + FutilityMargin[depth] <= alpha && abs(Score) < ISMATE) ? 1 : 0;
289289

290290
for(MoveNum = 0; MoveNum < list->count; ++MoveNum) {
291291

292292
PickNextMove(MoveNum, list);
293293

294-
if ( !MakeMove(pos,list->moves[MoveNum].move)) {
295-
continue;
296-
}
297-
298-
// Futility Pruning
294+
// Futility Pruning (if node is considered futile, and at least 1 legal move has been searched, don't search any more quiet moves in the position)
299295
if (Legal && FutileNode && !(list->moves[MoveNum].move & MFLAGCAP) && !(list->moves[MoveNum].move & MFLAGPROM) && !SqAttacked(pos->KingSq[pos->side],pos->side^1,pos)) {
300-
TakeMove(pos);
301296
continue;
302297
}
303298

299+
// if move is legal, play it
300+
if ( !MakeMove(pos,list->moves[MoveNum].move)) {
301+
continue;
302+
}
303+
304304
Legal++;
305305

306306
// PVS (speeds up search with good move ordering)

0 commit comments

Comments
 (0)