Commit graph

361 commits

Author SHA1 Message Date
9f62996175 [bitboard] Return a copy of a BitBoard from BitBoard::ray() 2025-05-02 14:28:31 -07:00
53c637f424 [bitboard] Make BitBoard::EMPTY and BitBoard::FULL private; export BitBoard::full() 2025-05-02 14:23:29 -07:00
90657e3818 [position] Rewrite sight methods in terms of Board and pass BitBoard arguments by value 2024-07-13 12:08:20 -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
f96fa79dc1 [position] Remove fen.rs 2024-07-13 08:14:33 -07:00
634f9e02f4 [board] Mailbox-related changes 2024-07-13 08:10:59 -07:00
ee51a13870 Rename Square::from_index → from_index_unchecked 2024-07-13 08:10:21 -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
7c65232c35 [core] Improve API of Shape and Color
Clean up type and method declarations by using better type spelling. Use more
standard method spelling for iterators. Implement some useful traits.
2024-07-13 07:34:50 -07:00
534c022981 [core] Add #[must_use] to several methods in coordinates 2024-07-13 07:21:21 -07:00
7e45e49502 [BitBoard] Build out the documentation 2024-07-13 07:20:18 -07:00
daf5c86792 [BitBoard] Clean up the API; implement some traits
Clean up the BitBoard API by renaming methods with simpler names.
run-help Redo
Redo the implementation of a couple methods to be more succinct.
2024-07-13 07:19:47 -07:00
480a009e63 [BitBoard] Address a bunch of rust-analyzer suggestions
Add #[must_use] to many methods
2024-07-13 07:17:43 -07:00
14ab669763 Clean up BitBoard's bit ops impl macros
Declare the `forward_ref` crate as a dependency (my first external dependency!)
and use it to clean up the infix, assign, and unary op impls. This crate
automatically implements A+&B, &A+B, and &A+&B for me.
2024-07-13 07:08:18 -07:00
2480ef25e9 Remove BitBoardBuilder
It's unused except for the macro, and BitBoard itself can be declared mutable,
and implements Copy and Clone. So, I don't think having a separate Builder type
helps much.
2024-07-13 07:05:57 -07:00
19feff9591 Solidify PieceSet and supporting types 2024-07-12 15:52:41 -07:00
b3c472fbce Fix some imports in the moves package
Castle and EnPassant moved to the board package. Reference these types there.
Add the board packages as a dependency to the moves package.
2024-04-26 09:50:42 -04:00
1d82d27f84 Move a whole bunch of stuff to the new chessfriend_board package 2024-04-25 13:28:24 -07:00
797606785e Empty board package 2024-04-25 09:32:27 -07:00
a2d0c638d0 [core] Address clippy suggestions; clean up unit tests
In coordinates.rs:

- Add some [must_use] decorators to some getters
- Rewrite some unit tests to remove the .expect() and use ? instead
2024-04-25 08:05:07 -07:00
1b63f56042 [bitboard, core] Make library getters const; parameterize Library attributes
- Add chessfriend_core::Color::NUM
- All the library getters can be const.
- Use the constants from the core library to define the length of the slices in
  the Library struct.
2024-04-25 07:59:39 -07:00
cad040e454 [bitboard] Fix some warnings and clippy suggestions in library.rs
- Add allow(dead_code) to LIGHT_SQUARES and DARK_SQUARES. These aren't used yet
  but I have a feeling they'll come in handy.
- Add some separators to long numeric literals.
- Lightly reformat BitBoard -> Bitboard in the module documentation
2024-04-25 07:23:59 -07:00
1f3c90ff35 [position] Print the chess board diagram with box drawing characters 2024-03-25 10:38:02 -07:00
21b58a6422 [position] Update the danger_squares unit test to use assert_eq_bitboards!() 2024-03-14 17:01:28 -07:00
27a36565f3 [bitboard,core,position] Address a bunch of clippy warnings 2024-03-14 17:00:46 -07:00
d0abbd8f93 [position] Rever the const-ness of Position's initializers
Apparently you can't actually do that. :( You can't call trait methods in const
contexts.
2024-03-10 09:18:08 -07:00
89802be53d [core] Address some clippy linter errors in core/coordinate.rs 2024-03-10 09:16:21 -07:00
a65c0c8ef1 [position] Make the Position initializer methods const
Position::empty() and Position::starting can both be const. Neat!
2024-03-08 08:18:49 -08:00
82aa7a2b01 [core] Rewrite Direction as a coordinate_enum!
- Order the values of Direction in a clockwise fashion
- Implement Direction::opposite() to return the opposing direction
- Make some small changes to the macros in this file to improve readability, maybe.
2024-03-08 08:17:54 -08:00
3f6ffef9f3 [bitboard] Write some documentation; mark some methods const
- Implement BitBoard::is_populated(), the opposite of ::is_empty()
- Write a bit of documentation for the BitBoard Library and for some methods on BitBoard
- Mark a few methods as const
2024-03-08 08:15:45 -08:00
20182d4035 [position] Implement an assert_eq_bitboards! macro
This one helps with printing BitBoards if the assertion fails.
2024-03-08 08:08:52 -08:00
069f94e8c2 [position] Refactor sight routines
- Break out the actual routines into file-private helper functions
- Declare traits for each piece type that call the corresponding helper function
- Implement these traits on PlacedPiece

The sight routines changed slightly such that they include the player's own pieces
in the resulting BitBoard. The tests neeeded to be updated to account for this.
2024-03-08 08:04:21 -08:00
f0b9681cef [position] Add a doc comment to PieceBitBoards::all_pieces; remove unused empty_squares 2024-03-01 15:26:01 -08:00
349d82304d [bitboard] Implement From<Option<Square>> for BitBoard
Return an empty BitBoard if the input is None.
2024-03-01 15:25:33 -08:00
d20119dfe3 [position] Make Shape::to_ascii() const 2024-03-01 15:24:43 -08:00