X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=d8ec34a0f7969d25f62f675e52bd8e8659e10cd2;hb=33ee191669b40afbd03d8fbf5406382fa2de1bf9;hp=b604e7970ffc357c4b05b0217836756485bde3c6;hpb=4b5fe3061829e184f9ad86a13d831eda22d95343;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index b604e797..d8ec34a0 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -98,6 +98,7 @@ class ChessRules j++; } } + // TODO: since we keep moves stack, next 2 are redundant let epSq = undefined; if (fenParts[2] != "-") { @@ -838,8 +839,7 @@ class ChessRules alphabeta(color, oppCol, depth, alpha, beta) { - const moves = this.getAllValidMoves(color); - if (moves.length == 0) + if (!this.atLeastOneMove(color)) { switch (this.checkGameEnd(color)) { @@ -849,6 +849,7 @@ class ChessRules } if (depth == 0) return this.evalPosition(); + const moves = this.getAllValidMoves(color); let v = color=="w" ? -1000 : 1000; if (color == "w") {