From: Benjamin Auder Date: Thu, 13 Dec 2018 02:29:11 +0000 (+0100) Subject: About to finish completed Ultima rules X-Git-Url: https://git.auder.net/css/vendor/rpsls.js?a=commitdiff_plain;h=2f3c845159670ec8bfba8a3999571d6ee1e45320;p=vchess.git About to finish completed Ultima rules --- diff --git a/TODO b/TODO index b3568538..bb4d6e16 100644 --- a/TODO +++ b/TODO @@ -1,5 +1 @@ Full detection of repeated positions (including turn) -In UltimaChess, consider these rules modifications: http://www.inference.org.uk/mackay/ultima/ultima.html -Reintroduce isAttackedBy in Ultima, and fix it for pawns --> underCheck + stalemate ---> take into account that an immobilized piece does not give check. -(chameleons cannot be immobilized) diff --git a/public/javascripts/variants/Ultima.js b/public/javascripts/variants/Ultima.js index c98822dc..57f3e25c 100644 --- a/public/javascripts/variants/Ultima.js +++ b/public/javascripts/variants/Ultima.js @@ -50,9 +50,39 @@ 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? + // Final check: is this knight immobilized? + let foundImmobilizer = false; + let neutralized = false; + outerLoop: + for (let step of steps) + { + const [i2,j2] = [i+step[0],j+step[1]]; + if (i2>=0 && i2=0 && j2=0 && i3=0 && j3=0 && i1=0 && i2=0 && j1=0 && j2 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 +573,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) }; diff --git a/views/rules/Ultima.pug b/views/rules/Ultima.pug index df8571f4..423ba5d6 100644 --- a/views/rules/Ultima.pug +++ b/views/rules/Ultima.pug @@ -1,5 +1,5 @@ p.boxed - | Pieces look the same but behave very differently. + | Most pieces look the same but behave very differently. | They generally move like an orthodox queen, | but capturing rules are complex. @@ -11,21 +11,20 @@ ul li Non-capturing moves: often like queen. li Special moves: none. li Captures: very special. - li End of game: capture the king. + li End of game: standard; see below. h3 Non-capturing moves // TODO: short paragraph, only the king moves like an orthodox king +// Consider these rules modifications: http://www.inference.org.uk/mackay/ultima/ultima.html h3 Capturing moves // TODO... -// TODO: dire comment suicider une pièce immobilisée (self-capture) h3 End of the game // TODO: show the situation from Wikipedia page -// tell that it's much simpler to go until king capture and not very different in this case h3 Credits