X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=6cab3496b2f9def3bda447e73b7be8b5b94ff6a1;hb=cf1303697774a12ef9bb154014a38797716944cf;hp=d4315c73724b5572437e3e7b3203b12bc7fefda4;hpb=c605216162dfc09cbbe61b0969f8890f28625372;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index d4315c73..6cab3496 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -284,7 +284,7 @@ class ChessRules i += step[0]; j += step[1]; } - if (i>=0 && i<8 && j>=0 && j<8 && this.canTake([x,y], [i,j])) + if (i>=0 && i=0 && j= 0 && x+shift < sizeX && x+shift != lastRank) { @@ -417,7 +417,7 @@ class ChessRules let step = finalSquares[castleSide][0] < y ? -1 : 1; for (i=y; i!=finalSquares[castleSide][0]; i+=step) { - if (this.isAttacked([x,i], oppCol) || (this.board[x][i] != V.EMPTY && + if (this.isAttacked([x,i], [oppCol]) || (this.board[x][i] != V.EMPTY && // NOTE: next check is enough, because of chessboard constraints (this.getColor(x,i) != c || ![V.KING,V.ROOK].includes(this.getPiece(x,i))))) { @@ -547,14 +547,15 @@ class ChessRules // Is square x,y attacked by pawns of color c ? isAttackedByPawn([x,y], colors) { + const [sizeX,sizeY] = VariantRules.size; for (let c of colors) { let pawnShift = (c=="w" ? 1 : -1); - if (x+pawnShift>=0 && x+pawnShift<8) + if (x+pawnShift>=0 && x+pawnShift=0 && y+i<8 && this.getPiece(x+pawnShift,y+i)==VariantRules.PAWN + if (y+i>=0 && y+i=0 && rx<8 && ry>=0 && ry<8 && this.board[rx][ry] == VariantRules.EMPTY - && !oneStep) + while (rx>=0 && rx=0 && ry=0 && rx<8 && ry>=0 && ry<8 && this.board[rx][ry] != VariantRules.EMPTY + if (rx>=0 && rx=0 && ry { return (color=="w" ? 1 : -1) * (b.eval - a.eval); }); + let candidates = [0]; //indices of candidates moves + for (let j=1; j= 3 + && Math.abs(moves1[0].eval) < VariantRules.THRESHOLD_MATE) { // TODO: show current analyzed move for depth 3, allow stopping eval (return moves1[0]) for (let i=0; i { return (color=="w" ? 1 : -1) * (b.eval - a.eval); }); } + else + return currentBest; - let candidates = [0]; //indices of candidates moves + candidates = [0]; for (let j=1; j { return [this.getNotation(m), m.eval]; }));