Commit graph

114 commits

Author SHA1 Message Date
52b19b87d8 [position] Implement FromFen for Position, Piece, and Color
I can now create Positions from FEN strings!
2024-01-29 16:10:08 -08:00
1d7dada987 [bitboard, core, position] Implement proper castle move generation
Add a field to MoveSet called special that flags special moves that should be
generated in the iter() method. This field is a u8. It only tracks castles in
the first and second bits (kingside and queenside, respectively). The move iterator
chains two maps over Option<()> that produce the kingside and queenside castle
moves.

With that done, finish the implementation of Position::player_can_castle by
adding checks for whether the squares between the rook and king are clear, and
that the king would not pass through a check. This is done with BitBoards!

Finally, implement some logic in PositionBuilder that updates the position's
castling flags based on the positions of king and rooks.

Supporting changes:
- Add Color:ALL and iterate on that slice
- Add Castle::ALL and iterator on that slice
- Add a CastlingParameters struct that contains BitBoard properties that describe
  squares that should be clear of pieces and squares that should not be attacked.
2024-01-29 14:46:41 -08:00
83a4e47e56 MoveGenerator::iter() returns an iterator of moves-by-value 2024-01-29 14:46:41 -08:00
ea22f7c5c7 Clean up some test imports 2024-01-29 14:46:41 -08:00
2d5710ccb1 Clean up Pawn::pushes a little bit 2024-01-29 14:46:41 -08:00
296a57d7ac Remove move list arguments from king and pawn move set constuction
These are harder.
2024-01-29 14:46:41 -08:00
5e3ef9d21e Remove the move lists from bishop, knight, queen, and rook move set construction
These are the easy ones.
2024-01-29 14:46:41 -08:00
cd3cb82192 Add an assert_move_list! macro to help with verifying move lists 2024-01-29 14:46:41 -08:00
d910ff708e Remove the move list argument from MoveList::quiet_moves and capture_moves
Produce an iterator of Moves in MoveList::moves
2024-01-29 14:46:41 -08:00
c558800385 [position] Fix a bug in the pawn pushes move generator 2024-01-29 14:46:22 -08:00
dab787170c [position] Clean up rook unit tests
Use test_position! instead of position!
Spell out the PlacedPiece constructor in the test_position! macro.
2024-01-28 10:28:01 -08:00
ea74b214da [position] Implement generating pawn moves by looking up bitboards in the Library
This enables a bunch of clean up! Remove the MoveGenerationParameters and MoveList
types from move_generator::pawn.

Implement BitBoard::pawn_pushes to look up pawn pushes by square and color.
2024-01-28 10:25:01 -08:00
77f419ad3b [position] Rename FenError → ToFenError
Add an associated type called Error to the ToFen trait. This mirrors the try_from
any try_into traits.
2024-01-28 10:05:51 -08:00
220da08727 Directly rename board -> position 2024-01-28 09:56:57 -08:00