kalebburnham / Majikthise

0 stars 0 forks source link

Generate En Passant Moves #7

Open kalebburnham opened 4 years ago

kalebburnham commented 3 years ago

As of 20-Dec-2020, En Passant captures with pawns can be generated. Knights are the only other piece that generates moves at the moment, but they generate moves without knowing the Position and therefore the epTargetSquare. There are two easy ways to deal with this.

  1. Include the epTargetSquare in the [w/b]GenerateKnightMoves functions. When the capture check is performed, it could include a check if the To square is the epTargetSquare. If it is, update the flag.
  2. That comparison would be performed in the function that calls [w/b]GenerateKnightMoves by looping through all moves. This way, all knight/queen/rook/bishop moves could be checked for En Passant captures simultaneously.

I prefer the first method since it reduces the amount of the work the calling function would need to perform and clearly defines the scope of the GenerateKnightMoves functions. The function signatures would differ with most of the pawn move generators, but keep it consistent with [w/b]GenerateEnPassantPawnMoves.