Commit graph

13 commits

Author SHA1 Message Date
164fe94bc0 [board] Implement danger squares for the current player
This concept comes from [1]. Danger squares are the squares a king cannot move to
because it would permit the opposing player to capture the king on their next
turn.

[1]: https://peterellisjones.com/posts/generating-legal-chess-moves-efficiently/
2024-01-28 09:08:22 -08:00
d27c455ce4 Merge branch 'many-crates' 2024-01-24 17:14:30 -08:00
88c0638d83 [board] Check that move is in sight of piece
If it's not, return an error from MoveBuilder::make()
2024-01-24 17:10:10 -08:00
8b2a3926b3 [core,board] Move board::piece to core
Break up types in core into finer grained modules.
Update all the imports.
2024-01-24 17:08:27 -08:00
6f85305912 [board] Clean up a bunch of build errors
Fix imports to refer to core and bitboard crates.
Fix some API use errors.
2024-01-24 09:18:12 -08:00
b0b22048a8 [core] Rename (once again) chess_core → chessfriend_core 2024-01-24 08:48:19 -08:00
106800bcb3 [core,board] Update all use imports referring to Square, Rank, and File 2024-01-24 08:32:09 -08:00
9a8380573b [board] Move MakeMoveBuilder::new() to an impl that specifies NoMove
I can build these now without having to specify a type for M.
2024-01-22 08:18:19 -08:00
dbbf2d4c46 [board] Implement ply and full move counters on Position
Pipe these numbers through the Builders
2024-01-21 15:10:04 -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
683d89b726 [board] Convert a few more Piece and PlacedPiece to pass by ref 2024-01-21 10:39:57 -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