Turns out I was doing the starting position really wrong. In an upcoming commit,
I will implement FEN output for Positions. While doing that work, I found several
issues that were causing the output of the FEN formatter to return garbage.
Implement a handful of unit tests to track down the errors.
Rename Shape::_ascii_representation() → Shape::to_ascii.
Implement to_ascii() on Piece.
I wrote a test for capturing en passant that revealed some bugs. Cool!
Implement the missing part of move validation that checks for an en passant move.
Implement PositionBuilder::to_move() to set player_to_move.
The most difficult part of this fix was finding the logic error in
Move::is_en_passant(). Instead of checking for non-zero, check for equality against
the en passant flag value. Checking for non-zero was causing this method to return
true in the double push case.
This builder takes a Position and a Move, validates the move, and makes the move
in that position. Its build() method returns a new Position with the move made.
Implement bitwise AND and OR for all permutations of BitBoard and &BitBoard.
Refer to the std::ops traits by fully-qualified path rather than requiring the
module to import those traits to implement them.
Implement bitwise AND and OR assignment (&= and |=) for BitBoard and &BitBoard.
Implement XOR and XOR assignment for BitBoards.
This makes Position immutable, even if declared mut. I think this will also make
it easier to build positions going forward.
Moving to a PieceBitBoards struct also required a lot of places that return owned
BitBoards to return refs. This is basically fine except for adding a few more &
here and there.
This was a huge refactoring project. All the move generators and a bunch of
BitBoard stuff needed to be updated.
- Remove unused std::fmt::Write import
- Refer to the piece! macro with $crate (I didn't know this was legal??)
- Remove the doc comments on Position::flags
- Remove {set,clear}_player_has_right_to_castle_flag
- Remove an extraneous local variable from Position::place_piece()