From 5ce7d3fbaca70a6665716d3821bdaaf4a8757cb4 Mon Sep 17 00:00:00 2001 From: Frederico Jordan Date: Tue, 31 Jan 2017 13:55:47 -0200 Subject: [PATCH] Fixing algebric notation ambiguity bug --- src/fast-chess.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/fast-chess.c b/src/fast-chess.c index 3cf222b..181bdf2 100644 --- a/src/fast-chess.c +++ b/src/fast-chess.c @@ -825,19 +825,18 @@ void move2str(char * str, Game * game, int moveNumber) { // TODO: refactor } BOOL isAmbiguous(Position * posBefore, Move move) { - int piece = posBefore->board[getFrom(move)]; - char color = piece&COLOR_MASK; - int arrivingSquare = getTo(move); - int i, attackCount = 0; + Move moves[MAX_BRANCHING_FACTOR]; + int moveCount = legalMoves(moves, posBefore, posBefore->toMove); - for (i=0; iboard[i] == piece) - if ( getAttacks(index2bb(i), posBefore->board, color) & index2bb(arrivingSquare) ) - attackCount += 1; + for (i=0; iboard[getFrom(moves[i])] == posBefore->board[getFrom(move)] ) { + attackCount++; + } + } return attackCount > 1; - } // ====== BOARD FILTERS ======