X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FUltima.js;h=c98822dcbf0e85aa68889faf0f4c338194dd79ef;hp=b3679f71352b62544208b13698ce7a0652cdb26b;hb=9d218497ab97bc0e94ec4c1f0a40cf02df3ea0d4;hpb=7aea79424d0c596e0a34e960c83847cc12b89e32 diff --git a/public/javascripts/variants/Ultima.js b/public/javascripts/variants/Ultima.js index b3679f71..c98822dc 100644 --- a/public/javascripts/variants/Ultima.js +++ b/public/javascripts/variants/Ultima.js @@ -53,13 +53,13 @@ class UltimaRules extends ChessRules getPotentialMovesFrom([x,y]) { // Pre-check: is thing on this square immobilized? - // In this case add potential suicide as a move "taking the immobilizer" const piece = this.getPiece(x,y); const color = this.getColor(x,y); const oppCol = this.getOppCol(color); const V = VariantRules; const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); const [sizeX,sizeY] = V.size; + outerLoop: for (let step of adjacentSteps) { const [i,j] = [x+step[0],y+step[1]]; @@ -67,15 +67,23 @@ class UltimaRules extends ChessRules && this.getColor(i,j) == oppCol) { const oppPiece = this.getPiece(i,j); - if (oppPiece == V.IMMOBILIZER - || (oppPiece == V.BISHOP && piece == V.IMMOBILIZER)) + if (oppPiece == V.BISHOP && piece == V.IMMOBILIZER) + return []; + if (oppPiece == V.IMMOBILIZER && ![V.BISHOP,V.IMMOBILIZER].includes(piece)) { - return [ new Move({ - appear: [], - vanish: [new PiPo({x:x,y:y,p:piece,c:color})], - start: {x:x,y:y}, - end: {x:i,y:j} - }) ]; + // Moving is impossible only if this immobilizer is not neutralized + for (let step2 of adjacentSteps) + { + const [i2,j2] = [i+step2[0],j+step2[1]]; + if (i2>=0 && i2=0 && j2=0 && i1=0 && i2=0 && j1=0 && j2=0 && i0=0 && j0=0 && i=0 && j=0 && i=0 && j 0) { - const [i,j] = [x+step[0],y+step[1]]; - if (i>=0 && i=0 && j=0 && sq2[0]=0 && sq2[1] 0) - { - this.kingPos[c][0] = move.appear[0].x; - this.kingPos[c][1] = move.appear[0].y; - } } checkGameEnd() { - // No valid move: game is lost (stalemate is a win) + // Stalemate, or our king disappeared return this.turn == "w" ? "0-1" : "1-0"; } @@ -529,6 +463,10 @@ class UltimaRules extends ChessRules static get SEARCH_DEPTH() { return 2; } //TODO? + static get THRESHOLD_MATE() { + return 500; //checkmates evals may be slightly below 1000 + } + static GenRandInitFen() { let pieces = { "w": new Array(8), "b": new Array(8) }; @@ -586,15 +524,4 @@ class UltimaRules extends ChessRules { return "0000"; //TODO: or "-" ? } - - getNotation(move) - { - if (move.appear.length == 0) - { - const startSquare = - String.fromCharCode(97 + move.start.y) + (VariantRules.size[0]-move.start.x); - return "^" + startSquare; //suicide - } - return super.getNotation(move); - } }