Merge pull request #23 from rektdie/LMR
Lmr bench 412557
This commit was merged in pull request #23.
This commit is contained in:
1 file changed
+31
-6
+31
-6
@@ -2,6 +2,7 @@
|
|||||||
#include "movegen.h"
|
#include "movegen.h"
|
||||||
#include "evaluate.h"
|
#include "evaluate.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
#include "tt.h"
|
#include "tt.h"
|
||||||
#include "stopwatch.h"
|
#include "stopwatch.h"
|
||||||
|
|
||||||
@@ -95,6 +96,20 @@ static bool IsThreefold(Board &board) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int GetReductions(Board &board, int depth, int moveSeen, int ply) {
|
||||||
|
int reduction = 0;
|
||||||
|
|
||||||
|
// Late Move Reduction
|
||||||
|
if (depth >= 3 && moveSeen >= 5 + 2 * (ply == 0) && !board.InCheck(board.sideToMove)) {
|
||||||
|
double base = 0.77;
|
||||||
|
double divisor = 2.36;
|
||||||
|
|
||||||
|
reduction = std::round(base + std::log(depth) * std::log(moveSeen) / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return reduction;
|
||||||
|
}
|
||||||
|
|
||||||
static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
static SearchResults Quiescence(Board board, int alpha, int beta, int ply) {
|
||||||
if (!benchStarted) {
|
if (!benchStarted) {
|
||||||
if (sw.GetElapsedMS() >= timeToSearch) {
|
if (sw.GetElapsedMS() >= timeToSearch) {
|
||||||
@@ -218,18 +233,28 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
|
|||||||
Board copy = board;
|
Board copy = board;
|
||||||
copy.MakeMove(currMove);
|
copy.MakeMove(currMove);
|
||||||
|
|
||||||
|
int reductions = GetReductions(board, depth, i, ply);
|
||||||
|
|
||||||
// First move (suspected PV node)
|
// First move (suspected PV node)
|
||||||
if (!i) {
|
if (!i) {
|
||||||
// Full search
|
// Full search
|
||||||
score = -PVS(copy, depth - 1, -beta, -alpha, ply + 1).score;
|
score = -PVS(copy, depth - 1, -beta, -alpha, ply + 1).score;
|
||||||
} else {
|
} else if (reductions) {
|
||||||
// Quick search
|
// Null-window search with reductions
|
||||||
score = -PVS(copy, depth - 1, -alpha-1, -alpha, ply + 1).score;
|
score = -PVS(copy, depth - 1 - reductions, -alpha-1, -alpha, ply + 1).score;
|
||||||
|
|
||||||
if (score > alpha && beta - alpha > 1) {
|
if (score > alpha) {
|
||||||
// We have to do full search
|
// Null-window search now without the reduction
|
||||||
score = -PVS(copy, depth - 1, -beta, -alpha, ply + 1).score;
|
score = -PVS(copy, depth - 1, -alpha-1, -alpha, ply + 1).score;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Null-window search
|
||||||
|
score = -PVS(copy, depth - 1, -alpha-1, -alpha, ply + 1).score;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we need to do full window re-search
|
||||||
|
if (i && score > alpha && score < beta) {
|
||||||
|
score = -PVS(copy, depth - 1, -beta, -alpha, ply + 1).score;
|
||||||
}
|
}
|
||||||
|
|
||||||
positionIndex--;
|
positionIndex--;
|
||||||
|
|||||||
Reference in new issue
Block a user