From 78bab51e57306ae9085d83828bbb73b62dd83fd8 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Wed, 26 Dec 2018 01:26:38 +0100 Subject: [PATCH] MarseilleRules OK --- public/javascripts/components/game.js | 6 ++++-- public/javascripts/variants/Marseille.js | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 1a3d2379..d8f06b33 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -1120,6 +1120,8 @@ Vue.component('my-game', { const self = this; this.compWorker.onmessage = function(e) { let compMove = e.data; + if (!compMove) + return; //may happen if MarseilleRules and subTurn==2 (TODO: a bit ugly...) if (!Array.isArray(compMove)) compMove = [compMove]; //to deal with MarseilleRules // TODO: imperfect attempt to avoid ghost move: @@ -1133,8 +1135,8 @@ Vue.component('my-game', { if (compMove.length == 2) setTimeout( () => { if (self.mode == "computer") - self.play(compMove[1]); - }, 2000); + self.play(compMove[1], "animate"); + }, 750); }, delay); } }, diff --git a/public/javascripts/variants/Marseille.js b/public/javascripts/variants/Marseille.js index 7ac928f1..02daa22b 100644 --- a/public/javascripts/variants/Marseille.js +++ b/public/javascripts/variants/Marseille.js @@ -230,6 +230,9 @@ class MarseilleRules extends ChessRules // No alpha-beta here, just adapted min-max at depth 2(+1) getComputerMove() { + if (this.subTurn == 2) + return null; //TODO: imperfect interface setup + const maxeval = V.INFINITY; const color = this.turn; const oppCol = this.getOppCol(this.turn); @@ -306,6 +309,7 @@ class MarseilleRules extends ChessRules { candidates.push(i); } + const selected = doubleMoves[_.sample(candidates, 1)].moves; if (selected.length == 1) return selected[0]; -- 2.44.0