From: Benjamin Auder Date: Tue, 4 Dec 2018 20:29:42 +0000 (+0100) Subject: Fix depth 2 search X-Git-Url: https://git.auder.net/assets/img/css/rpsls.css?a=commitdiff_plain;h=11a31682261b2bb40b06e1c026b07a3c5b2285e1;p=vchess.git Fix depth 2 search --- diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 79b6a7a3..fdfcda35 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -847,7 +847,9 @@ class ChessRules for (let j=0; j eval2)) eval2 = evalPos; this.undo(moves2[j]); @@ -857,6 +859,7 @@ class ChessRules this.undo(moves1[i]); } moves1.sort( (a,b) => { return (color=="w" ? 1 : -1) * (b.eval - a.eval); }); + //console.log(moves1.map(m => { return [this.getNotation(m), m.eval]; })); let candidates = [0]; //indices of candidates moves for (let j=1; j { return [this.getNotation(m)[0], m.eval]; })); candidates = [0]; for (let j=1; j { return [this.getNotation(m), m.eval]; })); return moves1[_.sample(candidates, 1)]; } - // TODO: some optimisations, understand why CH get mated in 2 alphabeta(depth, alpha, beta) { const maxeval = VariantRules.INFINITY;