mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-02-06 20:29:10 +01:00
DroidFish: Workaround for GTB en passant probing bug.
This commit is contained in:
parent
47f1cc4ac9
commit
c3acf44ac8
|
@ -26,7 +26,7 @@ import java.util.ArrayList;
|
|||
* @author petero
|
||||
*/
|
||||
public class MoveGen {
|
||||
static MoveGen instance;
|
||||
public static MoveGen instance;
|
||||
static {
|
||||
instance = new MoveGen();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,39 @@ public class Probe {
|
|||
* @return True if success.
|
||||
*/
|
||||
public final ProbeResult probeHard(Position pos) {
|
||||
ProbeResult ret = probeHardRaw(pos);
|
||||
if (ret.result == ProbeResult.DRAW && pos.getEpSquare() != -1) {
|
||||
ArrayList<Move> moveList = MoveGen.instance.legalMoves(pos);
|
||||
int pawn = pos.whiteMove ? Piece.WPAWN : Piece.BPAWN;
|
||||
int maxMate = -1;
|
||||
UndoInfo ui = new UndoInfo();
|
||||
for (Move move : moveList) {
|
||||
if ((move.to != pos.getEpSquare()) || (pos.getPiece(move.from) != pawn))
|
||||
return ret;
|
||||
pos.makeMove(move, ui);
|
||||
ProbeResult ret2 = probeHard(pos);
|
||||
pos.unMakeMove(move, ui);
|
||||
switch (ret2.result) {
|
||||
case ProbeResult.DRAW:
|
||||
break;
|
||||
case ProbeResult.WMATE:
|
||||
case ProbeResult.BMATE:
|
||||
maxMate = Math.max(maxMate, ret2.movesToMate);
|
||||
break;
|
||||
case ProbeResult.UNKNOWN:
|
||||
ret.result = ProbeResult.UNKNOWN;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (maxMate != -1) {
|
||||
ret.result = pos.whiteMove ? ProbeResult.BMATE : ProbeResult.WMATE;
|
||||
ret.movesToMate = maxMate;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private final ProbeResult probeHardRaw(Position pos) {
|
||||
int castleMask = 0;
|
||||
if (pos.a1Castle()) castleMask |= GtbProbe.A1_CASTLE;
|
||||
if (pos.h1Castle()) castleMask |= GtbProbe.H1_CASTLE;
|
||||
|
|
Loading…
Reference in New Issue
Block a user