From 11a31682261b2bb40b06e1c026b07a3c5b2285e1 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Tue, 4 Dec 2018 21:29:42 +0100 Subject: [PATCH] Fix depth 2 search --- public/javascripts/base_rules.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; -- 2.44.0