getPotentialMovesFrom([x, y]) {
let moves = super.getPotentialMovesFrom([x, y]);
+ if (this.getPiece(x, y) == V.PAWN) {
+ // Promotions by captures can be reduced to only one deterministic
+ // move (because of the explosion).
+ moves = moves.filter(m => {
+ return (
+ m.vanish.length == 1 ||
+ [V.PAWN, V.QUEEN].includes(m.appear[0].p)
+ );
+ });
+ }
+
// Handle explosions
moves.forEach(m => {
// NOTE: if vanish.length==2 and appear.length==2, this is castle
) {
this.kingPos[c] = [-1, -1];
this.castleFlags[c] = [8, 8];
- } else {
+ }
+ else {
// Now check if init rook(s) exploded
if (Math.abs(move.end.x - firstRank[c]) <= 1) {
if (Math.abs(move.end.y - this.castleFlags[c][0]) <= 1)