- Ambiguity move_ambiguity(const Position& pos, Move m) {
-
- MoveStack mlist[MOVES_MAX];
- Piece pc = pos.piece_on(move_from(m));
- int f = 0, r = 0;
-
- MoveStack* last = generate<MV_LEGAL>(pos, mlist);
-
- // Collect all legal moves of piece 'pc' with destination 'to'
- for (MoveStack* cur = mlist; cur != last; cur++)
- {
- if ( move_to(cur->move) == move_to(m)
- && pos.piece_on(move_from(cur->move)) == pc)
- {
- if (square_file(move_from(cur->move)) == square_file(move_from(m)))
- f++;
-
- if (square_rank(move_from(cur->move)) == square_rank(move_from(m)))
- r++;
- }
- }
-
- assert(f > 0 && r > 0);
-
- return f == 1 ? (r == 1 ? AMBIGUITY_NONE : AMBIGUITY_FILE)
- : (r == 1 ? AMBIGUITY_RANK : AMBIGUITY_BOTH);
- }
-
-