added insufficient material condition for draw

This commit is contained in:
2026-10-19 14:03:09 +03:30
parent 8ff113cfba
commit be54bdd5a7
10 changed files with 327 additions and 11 deletions
+6
View File
@@ -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);