return '';
}
- let moves = find_attacking_moves(move.to, piece, move.color, sloppy);
+ let moves = find_attacking_moves(move.to, piece, move.color);
+ if (moves.length <= 1) {
+ // There can be no ambiguity, so don't bother checking legality
+ // (we assume the move has already been found legal).
+ return '';
+ }
+
+ moves = possibly_filter_moves(moves, move.color, !sloppy);
var ambiguities = 0;
var same_rank = 0;
return '';
}
- // Find all moves featuring the given piece attacking the given square
- // (using symmetry of all non-pawn-or-castle moves, we simply generate
- // moves backwards). Does not support kings or pawns. Assumes there's
- // not already a piece of our own color on the destination square.
- function find_attacking_moves(to, piece, us, sloppy) {
+ // Find all pseudolegal moves featuring the given piece attacking
+ // the given square (using symmetry of all non-pawn-or-castle moves,
+ // we simply generate // moves backwards). Does not support kings
+ // or pawns. Assumes there's // not already a piece of our own color
+ // on the destination square.
+ function find_attacking_moves(to, piece, us) {
let moves = [];
function add_move(board, moves, from, to, flags, rook_sq) {
}
}
- return possibly_filter_moves(moves, us, !sloppy);
+ return moves;
}
function ascii() {