Commit graph

10 commits

Author SHA1 Message Date
7424236f1d [board] Add MakeMoveError::IllegalSquare(Square) 2024-01-22 08:18:37 -08:00
72316ad5f5 [board] Write a bunch of tests to validate the flag methods on Move
I caught a bunch of bugs while implementing position::MoveBuilder in the flag
methods that Move exports. These tests caught many of them!
2024-01-21 13:01:03 -08:00
f90ea2d1be [board] Add a test for capturing en passant; fix the bugs
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.
2024-01-21 11:21:37 -08:00
fa1c6b452e [board] Remove BoardSide enum; use Castle everywhere
Move Castle to a castle module inside the move module.
Implement into_index() on Castle to turn it into a usize.
2024-01-21 10:38:50 -08:00
21b5266789 [board] Implement position::builders::MoveBuilder
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.
2024-01-21 09:23:39 -08:00
7b8ce3b31d [board] Derive Copy for Move 2024-01-21 09:21:48 -08:00
4fe9be036d [board] Reexport AlgebraicMoveFormatter from the move module 2024-01-17 08:47:48 -08:00
771081a5df [board] Derive Clone and Debug for MoveBuilder 2024-01-17 08:47:35 -08:00
e2f8faad3d [board] Implement Default for move::move_formatter::Style 2024-01-17 08:47:16 -08:00
177a4e32da [board] Implement a u16 based Move
Replace building a Move with the Move struct itself with a MoveBuilder that
builds a Move and returns it.

Update the tests and move formatter.
2024-01-16 18:03:27 -08:00