Also the generation of the pseudo-legal moves is coming along nicely. I got the generation for common moves up and running. I.e. king, queen, rook, bishop and knight moves are working.
Now we have the special moves.
- Castling - Here we need a special check to see if the squares between the king and rook are empty. Also it does not follow any delta and moves two pieces (the only move that does that), so we can not use the same generation as ordinary moves.
So what I will do is; when a king is found both the ordinary generation method is called (for ordinary king moves), as well as a special castling generation method. We have to make sure the castling generation is cut off quickly if no castling is available so we do not slow down the end game with slow checks for castling at every move.
- Pawn moves - The pawns do follow a delta, but there are many differences compared to ordinary pieces. The differences we have to look out for are:
- Captures diagonally and can not capture forwards. This is a major difference since the generation method for other pieces check the arrival square and turn the move into a capture if it holds an opposite side piece.
- On the original square a pawn has the option of moving one or two squares. So we need an extra check to catch that.
- If the pawn reaches the last rank, it gets promoted. Basically for one pawn move we then have four options (queen, rook, bishop, knight), resulting in four moves generated.
It is hard to catch all these differences in the ordinary move generation method.