Commit graph

246 commits

Author SHA1 Message Date
5c5d9d5018 [board] Remove some dead code from Board 2025-05-23 14:14:49 -07:00
b8a51990a3 [board, position] Implement some methods to check for whether a king is in check
Remove some dead code from Position.
2025-05-23 09:57:48 -07:00
0abe9b6c19 [board, position] Add a color argument to opposing_sight
New convention: active_color_ methods operate on the active color of the Board.
Methods without that prefix take a color parameter and operate on that.

Refactor opposing_sight to do this.
2025-05-23 09:56:47 -07:00
a92ec9aba3 [board] Add an option to display a board with ASCII characters 2025-05-23 09:53:59 -07:00
ddd14e8999 [board] Define two new types for the Clock properties of Board
Helpful for other parts of the code.
2025-05-23 09:53:29 -07:00
d5c0330fbe [board] Add PieceSet::find_pieces
Takes a Piece and returns a BitBoard representing where pieces of that shape and
color are on the board.
2025-05-23 09:52:22 -07:00
e89bca9877 [board] Remove empty errors module 2025-05-21 10:09:55 -07:00
dbca7b4f88 [position, board] Move castle, movement, and sight modules to the board crate
Nothing about this code depends on Position, so push it down to a lower layer.
2025-05-21 10:08:59 -07:00
7c9c5484ba [position, board] Remove a bunch of dead code 2025-05-20 19:29:39 -07:00
54ac88aaf7 [board] Remove some old PlacedPiece code 2025-05-19 16:50:44 -07:00
0c1863acb9 [board, core, moves, position] Implement castling
Implement a new method on Position that evaluates whether the active color can castle
on a given wing of the board. Then, implement making a castling move in the position.

Make a new Wing enum in the core crate to specify kingside or queenside. Replace the
Castle enum from the board crate with this one. This caused a lot of churn...

Along the way fix a bunch of tests.

Note: there's still no way to actually make a castling move in explorer.
2025-05-19 16:50:30 -07:00
6e0e33b5f9 [board] Remove the FromIterator<PlacedPiece> impl for PieceSet 2025-05-19 08:37:04 -07:00
67448b44d7 [board] Clean up variables names in piece_sets.rs so creating an error is a little more succinct 2025-05-19 08:36:44 -07:00
c7be0e3e2b [board] Remove the PlacedPiece import from fen.rs 2025-05-19 08:35:56 -07:00
b229049e27 [board, core] Update error types to use thiserror::Error 2025-05-19 08:34:32 -07:00
5553bab659 [board] Teach DiagramFormatter how to highlight and mark squares
Add two BitBoard attributes to the struct that mark squares that should be marked
or highlighted.

Empty marked squares are shown with an asterisk (*). Marked squares with a piece
don't have any change of appearance. (Something I'm still thinking about.)

Highlighted squares are shown with the ANSI escape sequence for Reverse Video.
2025-05-16 07:49:09 -07:00
3b5b2f16a3 [board] Add occupancy methods that return BitBoards 2025-05-16 07:47:28 -07:00
424d348b2d WIP 2025-05-08 17:37:59 -07:00
091cc99cb3 WIP 2025-05-08 17:37:51 -07:00
867deafd13 [board] A ton of API refinements 2025-05-03 16:02:56 -07:00
99dd2d1be2 [board] Remove the Builder 2025-05-03 15:48:06 -07:00
b0c4039920 [board] Remove Board::new() 2025-05-02 15:42:06 -07:00
bb8d5a6aa3 [board] Replace Flags with castle::Rights 2025-05-02 15:41:45 -07:00
cd60a453aa [board] Replace active player and move properties on Board with MoveCounter instance 2025-05-02 15:18:37 -07:00
58cbe07136 [board] Implement PieceSet::mailbox() method to return a reference to its Mailbox 2025-05-02 15:05:39 -07:00
bf535f876a [board] Update call to BitBoard::occupied_squares to take an IterationDirection 2025-05-02 15:05:05 -07:00
0b100d5f14 [board] Remove Flags struct, replace it with Castle and supporting structs
Encapsulate castling rights within a small module. Castle provides the API to the
rest of the board package. Rights encodes the castling rights for each player.
Parameters defines castling parameters for each player.
2025-05-02 15:03:48 -07:00
9f2bfc0457 [board] Replace the length of the Builder::kings array with Color::NUM instead of constant 2 2025-05-02 14:49:16 -07:00
46b19ff616 [board] Implement Mailbox::from_iter as a reduce (aka fold) over the incoming iterator 2025-05-02 14:48:37 -07:00
72fd938238 [board] Implement Copy for Mailbox struct 2025-05-02 14:48:01 -07:00
c733342fca [board] Add MoveCounter struct to track current color, half move counter, and full move counter 2025-05-02 14:42:31 -07:00
30188d478e [board] Convert &BitBoard to BitBoard for several Board methods
I don't think passing by reference buys much for BitBoard. So simplify the
logic and borrowing semantics to make these easier to work with.
2024-07-13 12:03:19 -07:00
7ec72035ae [board] Remove en passant test helper method 2024-07-13 12:01:01 -07:00
d221de700d [board] Copy edit and add new documentation to Board 2024-07-13 12:00:02 -07:00
c297e4cbfa [board] Replace implementation of Board::piece_on_square with a simpler one
Now that board has a Mailbox, the implementation of this routine can be greatly
simplified. Instead of needing to iterate through all BitBoards to find the
occupied square, just consult the mailbox.
2024-07-13 11:57:57 -07:00
3785502ea0 [board] Declare Board::flags() pub(crate) instead of pub 2024-07-13 11:56:31 -07:00
26ae79e17d [board] Remove explicit #[inline] from several Board methods
Trust the compiler to inline where appropriate, until I know otherwise.
2024-07-13 11:54:58 -07:00
7a46d52e8d [board] Make the flags and macros modules public 2024-07-13 11:54:00 -07:00
fb6d1ad2f0 [board] Make the display module public 2024-07-13 11:53:43 -07:00
a14cb30781 [board] Implement PieceSet::iter() as an iterator over its Mailbox 2024-07-13 11:53:16 -07:00
fff2e084b5 [board] Remove turbofish from PieceSet pipeline in Builder::build() 2024-07-13 11:52:50 -07:00
da4e2f1d50 [core] Use Color::default() instead of Color::White in Board::default() 2024-07-13 11:52:25 -07:00
90e33d1202 [board] Replace Pieces iterator with Mailbox::iter()
Mailbox can use a standard iterator because it's just a slice. So nice!
2024-07-13 11:52:02 -07:00
51de32fa0a [board] Update reference to PieceBitBoard → PieceSet
This isn't all of them...
2024-07-13 11:50:38 -07:00
634f9e02f4 [board] Mailbox-related changes 2024-07-13 08:10:59 -07:00
c290f00b9e [board] fen declaration 2024-07-13 08:09:02 -07:00
e8c3d2b8db [board] Add documentation to the types in castle.rs 2024-07-13 08:08:48 -07:00
d9c2cfb90c [board] Copy fen.rs here from the position crate 2024-07-13 08:08:26 -07:00
3a2ead2668 [board] Replace Builder's BTreeMap with a Mailbox
More efficient and easier to work with. :)
2024-07-13 08:08:12 -07:00
19feff9591 Solidify PieceSet and supporting types 2024-07-12 15:52:41 -07:00