X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FHidden.js;h=f9455fd628af3df07f5f042a81f16ad0c653db7f;hb=032ecd58543d1182b41da0c45b272e99a3014ad8;hp=c060310c3ff74801e2ab3ce144124868b3d8b8f5;hpb=32f6285ee325a14286562a53baefc647201df2af;p=vchess.git diff --git a/client/src/variants/Hidden.js b/client/src/variants/Hidden.js index c060310c..f9455fd6 100644 --- a/client/src/variants/Hidden.js +++ b/client/src/variants/Hidden.js @@ -7,12 +7,12 @@ export class HiddenRules extends ChessRules { return false; } - static get HasCastle() { + static get HasEnpassant() { return false; } - static get HasEnpassant() { - return false; + static get SomeHiddenMoves() { + return true; } // Analyse in Hidden mode makes no sense @@ -54,7 +54,7 @@ export class HiddenRules extends ChessRules { } static get PIECES() { - return ChessRules.PIECES.concat(Object.values(V.HIDDEN_CODE)); + return ChessRules.PIECES.concat(Object.keys(V.HIDDEN_DECODE)); } // Pieces can be hidden :) @@ -209,9 +209,11 @@ export class HiddenRules extends ChessRules { pieces[c][rook2Pos] = "u"; } let upFen = pieces["b"].join(""); - upFen = upFen.substr(0,8) + "/" + upFen.substr(8).split("").reverse().join(""); + upFen = upFen.substr(0,8) + "/" + + upFen.substr(8).split("").reverse().join(""); let downFen = pieces["b"].join("").toUpperCase(); - downFen = downFen.substr(0,8) + "/" + downFen.substr(8).split("").reverse().join(""); + downFen = downFen.substr(0,8) + "/" + + downFen.substr(8).split("").reverse().join(""); return upFen + "/8/8/8/8/" + downFen + " w 0"; } @@ -259,9 +261,10 @@ export class HiddenRules extends ChessRules { if (move.vanish.length == 2 && move.vanish[1].c != color) { // OK this isn't a castling move const myPieceVal = V.VALUES[move.appear[0].p]; - const hisPieceVal = Object.keys(V.HIDDEN_DECODE).includes(move.vanish[1].p) - ? undefined - : V.VALUES[move.vanish[1].p]; + const hisPieceVal = + Object.keys(V.HIDDEN_DECODE).includes(move.vanish[1].p) + ? undefined + : V.VALUES[move.vanish[1].p]; if (!hisPieceVal) { // Opponent's piece is unknown: do not take too much risk move.eval = -myPieceVal + 1.5; //so that pawns always take @@ -280,7 +283,8 @@ export class HiddenRules extends ChessRules { // If no capture, favor small step moves, // but sometimes move the knight anyway const penalty = V.Decode(move.vanish[0].p) != V.KNIGHT - ? Math.abs(move.end.x - move.start.x) + Math.abs(move.end.y - move.start.y) + ? Math.abs(move.end.x - move.start.x) + + Math.abs(move.end.y - move.start.y) : (Math.random() < 0.5 ? 3 : 1); move.eval -= penalty / (V.size.x + V.size.y - 1); }