X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FTeleport.js;h=6cf14a8023285a1209bbc7214e42c93f4e8bc1d1;hp=b4e6d7faa5a575d2092e3ebd40ee138780b06793;hb=bc0b9205e41c5db0552e4ccf060b945342e36ed0;hpb=107dc1bd5361e2538b1551bdcc37c1e90a444b83 diff --git a/client/src/variants/Teleport.js b/client/src/variants/Teleport.js index b4e6d7fa..6cf14a80 100644 --- a/client/src/variants/Teleport.js +++ b/client/src/variants/Teleport.js @@ -2,6 +2,12 @@ import { ChessRules, Move, PiPo } from "@/base_rules"; import { randInt } from "@/utils/alea"; export class TeleportRules extends ChessRules { + hoverHighlight(x, y) { + // Testing move validity results in an infinite update loop. + // TODO: find a way to test validity anyway. + return (this.subTurn == 2 && this.board[x][y] == V.EMPTY); + } + setOtherVariables(fen) { super.setOtherVariables(fen); this.subTurn = 1; @@ -294,16 +300,17 @@ export class TeleportRules extends ChessRules { moves2.forEach(m2 => { this.play(m2); const score = this.getCurrentScore(); - const mvEval = - ["1-0", "0-1"].includes(score) - ? (score == "1-0" ? 1 : -1) * maxeval - : (score == "1/2" ? 0 : initEval); + let mvEval = 0; + if (["1-0", "0-1"].includes(score)) + mvEval = (score == "1-0" ? 1 : -1) * maxeval; + else if (score == "*") + // Add small fluctuations to avoid dropping pieces always on the + // first square available. + mvEval = initEval + 0.05 - Math.random() / 10; if ( (color == 'w' && mvEval > m.eval) || (color == 'b' && mvEval < m.eval) ) { - // TODO: if many second moves have the same eval, only the - // first is kept. Could be randomized. m.eval = mvEval; m.next = m2; }