X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FUltima.js;h=d5b9f88435d6173204e14ed34669e27a0a2d7177;hb=f4fd6580a227a352f6e0e95870954bc2fa2ce97f;hp=c98822dcbf0e85aa68889faf0f4c338194dd79ef;hpb=9d218497ab97bc0e94ec4c1f0a40cf02df3ea0d4;p=vchess.git diff --git a/public/javascripts/variants/Ultima.js b/public/javascripts/variants/Ultima.js index c98822dc..d5b9f884 100644 --- a/public/javascripts/variants/Ultima.js +++ b/public/javascripts/variants/Ultima.js @@ -50,9 +50,9 @@ class UltimaRules extends ChessRules // - a "bishop" is a chameleon, capturing as its prey // - a "queen" is a withdrawer, capturing by moving away from pieces - getPotentialMovesFrom([x,y]) + // Is piece on square (x,y) immobilized? + isImmobilized([x,y]) { - // Pre-check: is thing on this square immobilized? const piece = this.getPiece(x,y); const color = this.getColor(x,y); const oppCol = this.getOppCol(color); @@ -68,7 +68,7 @@ class UltimaRules extends ChessRules { const oppPiece = this.getPiece(i,j); if (oppPiece == V.BISHOP && piece == V.IMMOBILIZER) - return []; + return true; if (oppPiece == V.IMMOBILIZER && ![V.BISHOP,V.IMMOBILIZER].includes(piece)) { // Moving is impossible only if this immobilizer is not neutralized @@ -78,15 +78,22 @@ class UltimaRules extends ChessRules if (i2>=0 && i2=0 && j2=0 && i1=0 && i2=0 && j1=0 && j2=0 && i3=0 && j3=0 && i3=0 && j3 0) + // Square (x,y) must be on same line as a knight, + // and there must be empty square(s) behind. + const V = VariantRules; + const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); + const [sizeX,sizeY] = V.size; + outerLoop: + for (let step of steps) { - this.kingPos[c][0] = move.appear[0].x; - this.kingPos[c][1] = move.appear[0].y; + const [i0,j0] = [x+step[0],y+step[1]]; + if (i0>=0 && i0=0 && j0=0 && i=0 && j=0 && i=0 && j=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; + } } static get VALUES() { //TODO: totally experimental! @@ -463,10 +566,6 @@ 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) };