Commit graph

22 commits

Author SHA1 Message Date
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
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
27a36565f3 [bitboard,core,position] Address a bunch of clippy warnings 2024-03-14 17:00:46 -07:00
89802be53d [core] Address some clippy linter errors in core/coordinate.rs 2024-03-10 09:16:21 -07: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
d20119dfe3 [position] Make Shape::to_ascii() const 2024-03-01 15:24:43 -08:00
2a6b098cb8 Fix the pawn unit tests 2024-02-25 10:51:27 -08:00
0201668563 [core] Move the Unicode piece table to a helper to_unicode() method on Piece 2024-02-11 09:58:18 -07:00
a5e8f33afe [core] Implement Square::file_rank()
Returns a tuple of the square's file and rank.
2024-02-05 13:59:58 -08:00
1d7dada987 [bitboard, core, position] Implement proper castle move generation
Add a field to MoveSet called special that flags special moves that should be
generated in the iter() method. This field is a u8. It only tracks castles in
the first and second bits (kingside and queenside, respectively). The move iterator
chains two maps over Option<()> that produce the kingside and queenside castle
moves.

With that done, finish the implementation of Position::player_can_castle by
adding checks for whether the squares between the rook and king are clear, and
that the king would not pass through a check. This is done with BitBoards!

Finally, implement some logic in PositionBuilder that updates the position's
castling flags based on the positions of king and rooks.

Supporting changes:
- Add Color:ALL and iterate on that slice
- Add Castle::ALL and iterator on that slice
- Add a CastlingParameters struct that contains BitBoard properties that describe
  squares that should be clear of pieces and squares that should not be attacked.
2024-01-29 14:46:41 -08:00
1f78d4811a [core] Declare Rank::PAWN_STARTING_RANKS
This is a slice that declares the pawn starting ranks for each color.
2024-01-29 14:46:16 -08:00
21c81f237a [core] Implement as_index() for range_bound_struct 2024-01-29 14:46:16 -08:00
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
f08a4c66a1 [core] Use TryFromCharError in TryFrom<char> for Color 2024-01-26 12:58:51 -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
b0b22048a8 [core] Rename (once again) chess_core → chessfriend_core 2024-01-24 08:48:19 -08:00
eab30cc33b [core] Rename the directory chess_core → core
I think this is sufficient.
2024-01-24 08:33:07 -08:00
3c3a62345d [core] Rename core → chess_core 2024-01-24 08:29:16 -08:00
406631b617 [core] Move the contents of board::square to core::coordinates
Export Square, Rank, and File from the core crate.
2024-01-24 08:25:56 -08:00
7e08a9adc4 [core] Create a core crate 2024-01-24 08:24:59 -08:00