Skip to content

Commit

Permalink
Fixing algebric notation ambiguity bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericojordan committed Jan 31, 2017
1 parent 85dc2f2 commit 5ce7d3f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/fast-chess.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<NUM_SQUARES; i++)
if (posBefore->board[i] == piece)
if ( getAttacks(index2bb(i), posBefore->board, color) & index2bb(arrivingSquare) )
attackCount += 1;
for (i=0; i<moveCount; i++) {
if ( getTo(moves[i]) == getTo(move) &&
posBefore->board[getFrom(moves[i])] == posBefore->board[getFrom(move)] ) {
attackCount++;
}
}

return attackCount > 1;

}

// ====== BOARD FILTERS ======
Expand Down

0 comments on commit 5ce7d3f

Please sign in to comment.