X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=26c744777c1b4a4b77f311363e372ce2dd63a3bb;hp=d4315c73724b5572437e3e7b3203b12bc7fefda4;hb=3c09dc498791ac478679bf2f42f441342c4fa22c;hpb=c605216162dfc09cbbe61b0969f8890f28625372 diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index d4315c73..26c74477 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -800,9 +800,14 @@ class ChessRules return VariantRules.INFINITY; } + static get SEARCH_DEPTH() { + return 3; //2 for high branching factor, 4 for small (Loser chess) + } + // Assumption: at least one legal move getComputerMove(moves1) //moves1 might be precomputed (Magnetic chess) { + this.shouldReturn = false; const maxeval = VariantRules.INFINITY; const color = this.turn; if (!moves1) @@ -834,21 +839,32 @@ class ChessRules } moves1.sort( (a,b) => { return (color=="w" ? 1 : -1) * (b.eval - a.eval); }); + let candidates = [0]; //indices of candidates moves + for (let j=1; j= 3 + && Math.abs(moves1[0].eval) < VariantRules.THRESHOLD_MATE) { // TODO: show current analyzed move for depth 3, allow stopping eval (return moves1[0]) for (let i=0; i { return (color=="w" ? 1 : -1) * (b.eval - a.eval); }); } + else + return currentBest; - let candidates = [0]; //indices of candidates moves + candidates = [0]; for (let j=1; j { return [this.getNotation(m), m.eval]; }));