mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-04-14 16:12:46 +02:00
CuckooChessEngine: Implemented reverse futility pruning.
This commit is contained in:
parent
62e3ace1ab
commit
15fec82d90
CuckooChessEngine
@ -30,7 +30,7 @@ public class ComputerPlayer implements Player {
|
|||||||
public static final String engineName;
|
public static final String engineName;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String name = "CuckooChess 1.13a4";
|
String name = "CuckooChess 1.13a5";
|
||||||
String m = System.getProperty("sun.arch.data.model");
|
String m = System.getProperty("sun.arch.data.model");
|
||||||
if ("32".equals(m))
|
if ("32".equals(m))
|
||||||
name += " 32-bit";
|
name += " 32-bit";
|
||||||
|
@ -535,6 +535,43 @@ public class Search {
|
|||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Razoring
|
||||||
|
if ((Math.abs(alpha) <= MATE0 / 2) && (depth < 4*plyScale) && (beta == alpha + 1)) {
|
||||||
|
if (evalScore == UNKNOWN_SCORE) {
|
||||||
|
evalScore = eval.evalPos(pos);
|
||||||
|
}
|
||||||
|
final int razorMargin = 250;
|
||||||
|
if (evalScore < beta - razorMargin) {
|
||||||
|
q0Eval = evalScore;
|
||||||
|
int score = quiesce(alpha-razorMargin, beta-razorMargin, ply, 0, inCheck);
|
||||||
|
if (score <= alpha-razorMargin) {
|
||||||
|
emptyMove.score = score;
|
||||||
|
tt.insert(hKey, emptyMove, TTEntry.T_LE, ply, depth, evalScore);
|
||||||
|
if (log != null) log.logNodeEnd(sti.nodeIdx, score, TTEntry.T_LE, evalScore, hKey);
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse futility pruning
|
||||||
|
if (!inCheck && (depth < 5*plyScale) && (posExtend == 0)) {
|
||||||
|
if ((Math.abs(alpha) <= MATE0 / 2) && (Math.abs(beta) <= MATE0 / 2)) {
|
||||||
|
int margin;
|
||||||
|
if (depth <= plyScale) margin = 200;
|
||||||
|
else if (depth <= 2*plyScale) margin = 400;
|
||||||
|
else if (depth <= 3*plyScale) margin = 600;
|
||||||
|
else margin = 800;
|
||||||
|
if (evalScore == UNKNOWN_SCORE)
|
||||||
|
evalScore = eval.evalPos(pos);
|
||||||
|
if (evalScore - margin >= beta) {
|
||||||
|
emptyMove.score = evalScore - margin;
|
||||||
|
tt.insert(hKey, emptyMove, TTEntry.T_GE, ply, depth, evalScore);
|
||||||
|
if (log != null) log.logNodeEnd(sti.nodeIdx, evalScore - margin, TTEntry.T_GE, evalScore, hKey);
|
||||||
|
return evalScore - margin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try null-move pruning
|
// Try null-move pruning
|
||||||
// FIXME! Try null-move verification in late endgames. See loss in round 21.
|
// FIXME! Try null-move verification in late endgames. See loss in round 21.
|
||||||
sti.currentMove = emptyMove;
|
sti.currentMove = emptyMove;
|
||||||
@ -593,47 +630,22 @@ public class Search {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Razoring
|
|
||||||
if ((Math.abs(alpha) <= MATE0 / 2) && (depth < 4*plyScale) && (beta == alpha + 1)) {
|
|
||||||
if (evalScore == UNKNOWN_SCORE) {
|
|
||||||
evalScore = eval.evalPos(pos);
|
|
||||||
}
|
|
||||||
final int razorMargin = 250;
|
|
||||||
if (evalScore < beta - razorMargin) {
|
|
||||||
q0Eval = evalScore;
|
|
||||||
int score = quiesce(alpha-razorMargin, beta-razorMargin, ply, 0, inCheck);
|
|
||||||
if (score <= alpha-razorMargin) {
|
|
||||||
emptyMove.score = score;
|
|
||||||
tt.insert(hKey, emptyMove, TTEntry.T_LE, ply, depth, evalScore);
|
|
||||||
if (log != null) log.logNodeEnd(sti.nodeIdx, score, TTEntry.T_LE, evalScore, hKey);
|
|
||||||
return score;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean futilityPrune = false;
|
boolean futilityPrune = false;
|
||||||
int futilityScore = alpha;
|
int futilityScore = alpha;
|
||||||
if (!inCheck && (depth < 5*plyScale) && (posExtend == 0)) {
|
if (!inCheck && (depth < 5*plyScale) && (posExtend == 0)) {
|
||||||
if ((Math.abs(alpha) <= MATE0 / 2) && (Math.abs(beta) <= MATE0 / 2)) {
|
if ((Math.abs(alpha) <= MATE0 / 2) && (Math.abs(beta) <= MATE0 / 2)) {
|
||||||
int margin;
|
int margin;
|
||||||
if (depth <= plyScale) {
|
if (depth <= plyScale) margin = 61;
|
||||||
margin = 61;
|
else if (depth <= 2*plyScale) margin = 144;
|
||||||
} else if (depth <= 2*plyScale) {
|
else if (depth <= 3*plyScale) margin = 268;
|
||||||
margin = 144;
|
else margin = 334;
|
||||||
} else if (depth <= 3*plyScale) {
|
if (evalScore == UNKNOWN_SCORE)
|
||||||
margin = 268;
|
|
||||||
} else {
|
|
||||||
margin = 334;
|
|
||||||
}
|
|
||||||
if (evalScore == UNKNOWN_SCORE) {
|
|
||||||
evalScore = eval.evalPos(pos);
|
evalScore = eval.evalPos(pos);
|
||||||
}
|
|
||||||
futilityScore = evalScore + margin;
|
futilityScore = evalScore + margin;
|
||||||
if (futilityScore <= alpha) {
|
if (futilityScore <= alpha)
|
||||||
futilityPrune = true;
|
futilityPrune = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((depth > 4*plyScale) && ((hashMove == null) || (hashMove.from == hashMove.to))) {
|
if ((depth > 4*plyScale) && ((hashMove == null) || (hashMove.from == hashMove.to))) {
|
||||||
boolean isPv = beta > alpha + 1;
|
boolean isPv = beta > alpha + 1;
|
||||||
|
@ -83,7 +83,7 @@ public class SearchTest {
|
|||||||
sc = new Search(pos, nullHist, 0, tt);
|
sc = new Search(pos, nullHist, 0, tt);
|
||||||
score = sc.negaScout(-mate0, mate0, 0, 3*plyScale, -1, MoveGen.inCheck(pos));
|
score = sc.negaScout(-mate0, mate0, 0, 3*plyScale, -1, MoveGen.inCheck(pos));
|
||||||
assertTrue(Math.abs(score) < 50); // Stale-mate trap
|
assertTrue(Math.abs(score) < 50); // Stale-mate trap
|
||||||
score2 = idSearch(sc, 5).score;
|
score2 = idSearch(sc, 9).score;
|
||||||
assertEquals(score, score2);
|
assertEquals(score, score2);
|
||||||
|
|
||||||
pos = TextIO.readFEN("8/8/2K5/3QP3/P6P/1q6/8/k7 w - - 31 51");
|
pos = TextIO.readFEN("8/8/2K5/3QP3/P6P/1q6/8/k7 w - - 31 51");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user