added insufficient material condition for draw
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
isMoveLegalFor,
|
||||
isKingInCheck,
|
||||
isCheckmate,
|
||||
hasInsufficientMaterial,
|
||||
type State,
|
||||
type Piece,
|
||||
type PieceType,
|
||||
@@ -293,6 +294,7 @@ function quiescence(
|
||||
color: "w" | "b",
|
||||
depthLimit: number
|
||||
): number {
|
||||
if (hasInsufficientMaterial(s)) return 0;
|
||||
const standPat = (color === "w" ? 1 : -1) * evaluateStatic(s);
|
||||
if (standPat >= beta) return beta;
|
||||
if (standPat > alpha) alpha = standPat;
|
||||
@@ -333,6 +335,10 @@ function negamax(
|
||||
return -100000 + ply;
|
||||
}
|
||||
|
||||
if (hasInsufficientMaterial(s)) {
|
||||
return 0; // Drawn position
|
||||
}
|
||||
|
||||
if (depth <= 0) {
|
||||
if (quiesceDepth > 0) {
|
||||
return quiescence(s, alpha, beta, color, quiesceDepth);
|
||||
|
||||
Reference in New Issue
Block a user