+ // Split into "normal" and "random" moves:
+ // (Next splitting condition is OK because cannot take self object
+ // without a banana or bomb on the way).
+ const deterministicMoves = moves.filter(m => {
+ return m.vanish.every(a => a.c != 'a' || a.p == V.MUSHROOM);
+ });
+ const randomMoves = moves.filter(m => {
+ return m.vanish.some(a => a.c == 'a' && a.p != V.MUSHROOM);
+ });
+ if (Math.random() < deterministicMoves.length / randomMoves.length)
+ // Play a deterministic one: capture king or material if possible
+ return super.getComputerMove(deterministicMoves);
+ // Play a random effect move, at random:
+ let move1 = randomMoves[randInt(moves.length)];