mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-27 06:10:28 +01:00
CuckooChess: Don't use LMP when alpha or beta is a mate score.
This commit is contained in:
parent
43e0f00175
commit
4f4c1c75e7
|
@ -756,6 +756,7 @@ public class Evaluate {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int threatBonus(Position pos) {
|
private int threatBonus(Position pos) {
|
||||||
|
// FIXME!! Try higher weight for attacks on more valuable pieces.
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
// Sum values for all black pieces under attack
|
// Sum values for all black pieces under attack
|
||||||
|
|
|
@ -53,7 +53,7 @@ public interface Player {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inform player that the transposition table should be cleared.
|
* Inform player that the transposition table should be cleared.
|
||||||
* Of coarse, a human player has a hard time implementing this.
|
* Of course, a human player has a hard time implementing this.
|
||||||
*/
|
*/
|
||||||
public void clearTT();
|
public void clearTT();
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,14 +734,16 @@ public class Search {
|
||||||
boolean givesCheck = MoveGen.givesCheck(pos, m);
|
boolean givesCheck = MoveGen.givesCheck(pos, m);
|
||||||
boolean doFutility = false;
|
boolean doFutility = false;
|
||||||
if (mayReduce && haveLegalMoves && !givesCheck && !passedPawnPush(pos, m)) {
|
if (mayReduce && haveLegalMoves && !givesCheck && !passedPawnPush(pos, m)) {
|
||||||
int moveCountLimit;
|
if ((Math.abs(alpha) <= MATE0 / 2) && (Math.abs(beta) <= MATE0 / 2)) {
|
||||||
if (depth <= plyScale) moveCountLimit = 3;
|
int moveCountLimit;
|
||||||
else if (depth <= 2 * plyScale) moveCountLimit = 6;
|
if (depth <= plyScale) moveCountLimit = 3;
|
||||||
else if (depth <= 3 * plyScale) moveCountLimit = 12;
|
else if (depth <= 2 * plyScale) moveCountLimit = 6;
|
||||||
else if (depth <= 4 * plyScale) moveCountLimit = 24;
|
else if (depth <= 3 * plyScale) moveCountLimit = 12;
|
||||||
else moveCountLimit = 256;
|
else if (depth <= 4 * plyScale) moveCountLimit = 24;
|
||||||
if (mi >= moveCountLimit)
|
else moveCountLimit = 256;
|
||||||
continue; // Late move pruning
|
if (mi >= moveCountLimit)
|
||||||
|
continue; // Late move pruning
|
||||||
|
}
|
||||||
if (futilityPrune)
|
if (futilityPrune)
|
||||||
doFutility = true;
|
doFutility = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,7 +290,7 @@ public class TextIO {
|
||||||
ret.append("O-O-O");
|
ret.append("O-O-O");
|
||||||
}
|
}
|
||||||
} else if (move.from == bKingOrigPos && pos.getPiece(bKingOrigPos) == Piece.BKING) {
|
} else if (move.from == bKingOrigPos && pos.getPiece(bKingOrigPos) == Piece.BKING) {
|
||||||
// Check white castle
|
// Check black castle
|
||||||
if (move.to == Position.getSquare(6, 7)) {
|
if (move.to == Position.getSquare(6, 7)) {
|
||||||
ret.append("O-O");
|
ret.append("O-O");
|
||||||
} else if (move.to == Position.getSquare(2, 7)) {
|
} else if (move.to == Position.getSquare(2, 7)) {
|
||||||
|
|
|
@ -205,6 +205,17 @@ public class SearchTest {
|
||||||
assertEquals(TextIO.stringToMove(pos, "Kb1"), new Move(bestM));
|
assertEquals(TextIO.stringToMove(pos, "Kb1"), new Move(bestM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Late move pruning must not be used in mate search.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testLMP() throws ChessParseError {
|
||||||
|
Position pos = TextIO.readFEN("2r2rk1/6p1/p3pq1p/1p1b1p2/3P1n2/PP3N2/3N1PPP/1Q2RR1K b"); // WAC 174
|
||||||
|
Search sc = new Search(pos, nullHist, 0, tt);
|
||||||
|
Move bestM = idSearch(sc, 2);
|
||||||
|
assertTrue(bestM.score < Search.MATE0 / 2);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCheckEvasion() throws ChessParseError {
|
public void testCheckEvasion() throws ChessParseError {
|
||||||
System.out.println("check evasion");
|
System.out.println("check evasion");
|
||||||
|
@ -234,7 +245,7 @@ public class SearchTest {
|
||||||
System.out.println("kqkrNullMove");
|
System.out.println("kqkrNullMove");
|
||||||
Position pos = TextIO.readFEN("7K/6R1/5k2/3q4/8/8/8/8 b - - 0 1");
|
Position pos = TextIO.readFEN("7K/6R1/5k2/3q4/8/8/8/8 b - - 0 1");
|
||||||
Search sc = new Search(pos, nullHist, 0, tt);
|
Search sc = new Search(pos, nullHist, 0, tt);
|
||||||
Move bestM = idSearch(sc, 9);
|
Move bestM = idSearch(sc, 10);
|
||||||
assertEquals(Search.MATE0-18, bestM.score);
|
assertEquals(Search.MATE0-18, bestM.score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user