1 // Logic to play a computer move in a web worker
2 onmessage
= async
function(e
) {
5 await
import("@/variants/" + e
.data
[1] + ".js")
6 .then((vModule
) => { self
.V
= vModule
[e
.data
[1] + "Rules"]; });
10 const fen
= e
.data
[1];
11 self
.vr
= new self
.V(fen
);
16 // Caution: could be a multi-move
17 if (!Array
.isArray(move))
19 move.forEach(m
=> self
.vr
.play(m
));
22 const compMove
= self
.vr
.getComputerMove();
23 postMessage(compMove
);