Dec 27, 2006

[Bug] Pawn move generation

While testing the search I ran into a few bugs concerning pawn move generation. Namely:
  • When generating captures for pawns on the edge of the board no check was made if the piece tried to capture outside the board. I missed this since the only time it generated an error was when a black pawn was standing on 'a2' and tried capture diagonally to the left which results in an out of bounds exception, since that square would get index -1 which does not exist in the array.

  • Black pawns were given rank 2 as homerank instead of rank 7, resulting in the pawns happily moving two squares and jumping off the board as they passed rank 1.

  • The last bug was rather amusing. The default value for no existing en passant is -1. And the check consisted of trying to match the pawn's diagonal movement to the en passant 'square'. Since a black pawn standing on 'a2' has left diagonal movement index -1 (outside the board), it matched the no existing en passant number and a very weird en passant move was generated.
These changes are made in mediocre(dl7).

No comments: