Add traces to understand what happens in MarseilleChess about turn/subturn
[vchess.git] / public / javascripts / playCompMove.js
1 // For asynchronous computer move search
2 onmessage = function(e)
3 {
4 switch (e.data[0])
5 {
6 case "scripts":
7 self.importScripts(
8 '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js',
9 '/javascripts/base_rules.js',
10 '/javascripts/utils/array.js',
11 '/javascripts/variants/' + e.data[1] + '.js');
12 self.V = VariantRules;
13 break;
14 case "init":
15 const fen = e.data[1];
16 self.vr = new VariantRules(fen, []);
17 break;
18 case "newmove":
19 self.vr.play(e.data[1]);
20 break;
21 case "askmove":
22
23 console.log("IN playCompMove " + self.vr.moves.length + " " + self.vr.turn);
24
25 const compMove = self.vr.getComputerMove();
26 postMessage(compMove);
27 break;
28 }
29 }