Commit graph

34 commits

Author SHA1 Message Date
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
220da08727 Directly rename board -> position 2024-01-28 09:56:57 -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
625bfb2446 [bitboard] Move everything in board::bitboard to the bitboard crate 2024-01-24 08:35:28 -08:00
106800bcb3 [core,board] Update all use imports referring to Square, Rank, and File 2024-01-24 08:32:09 -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
3244bfc211 [board] Make the fen module public so clients can access ToFen 2024-01-22 08:19:09 -08:00
8dbf44c741 [board] Rename position::MoveBuilder → MakeMoveBuilder 2024-01-22 08:11:02 -08:00
3dfebb22eb [board] Declare ToFen and implement it on Position and supporting types
I can now print a position in FEN!
2024-01-21 15:10:59 -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
7071f6a742 [board] Cave to pressure and implement fmt::Display for Position
It prints a nice diagram!

Now I can make the position module private.
2024-01-19 18:12:28 -08:00
24cce95a88 [board] Implement a PositionBuilder; refactor piece bitboards into a PieceBitBoards struct
This makes Position immutable, even if declared mut. I think this will also make
it easier to build positions going forward.

Moving to a PieceBitBoards struct also required a lot of places that return owned
BitBoards to return refs. This is basically fine except for adding a few more &
here and there.

This was a huge refactoring project. All the move generators and a bunch of
BitBoard stuff needed to be updated.
2024-01-19 18:09:05 -08:00
2269df2ed9 [board] Move piece! and position! macros to a new macros.rs module 2024-01-19 18:09:05 -08:00
ca9ff94d2a [board] Rename the moves modules → move_generator
Update the imports.
Also update some references to crate symbols in move_generator macros to use $crate.
2024-01-17 08:40:09 -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
a6b98abb95 [board] Create a bitboard! macro and BitBoardBuilder
The Builder enables cleanly building a BitBoard out of squares.
The macro lets you create a BitBoard from a simple list of coordinates:

bitboard!(A1, B2, C3, D4, …)
2024-01-15 17:17:34 -08:00
3ecc263701 [board] Implement piece sight algorithms
Add a new Sight trait, implemented by PlacedPiece. The implementation of this
trait produces a BitBoard representing the squares visible to the placed piece.
2024-01-15 16:03:06 -08:00
5961b1bcd5 [board] Export BitBoard directly off of the crate for internal use
Update all the imports to import from the crate directly.
2024-01-14 10:57:22 -08:00
ddea2c2d63 [board] Declare three new Display-like traits
- ASCIIDisplay → format a type using ASCII only characters
- UnicodeDisplay → format a type using any Unicode characters
- FENDisplay → format a type for inclusion in a FEN string
2024-01-14 10:51:40 -08:00
7c80c61690 [board] Implement a position! macro for creating Positions
For example:

```
let position = position![
    White King on E4,
    Black Rook on E8,
];
```
2024-01-12 22:30:00 -08:00
94ab64d277 [board] Add a piece! macro
This macro implements a tiny DSL for creating Pieces and PlacedPieces.

"White King" → Piece::new(Color::White, Shape::King)
"White King on E4" → PlacedPiece::new(Piece::new(Color::White, Shape::King), Square::E4)
2024-01-12 22:26:13 -08:00
14db74f212 Remove tests module 2024-01-06 16:45:13 -08:00
2105004dc2 Reimplement Square as an enum; implement Rank and File enums
Replace the Square struct with an enum. This implementation is based on this one:

https://github.com/analog-hors/magic-bitboards-demo/blob/main/types/src/square.rs

This reduces a lot of code needed to construct squares, ranks, and files.
2024-01-06 16:08:34 -08:00
72dabfe73f [board] A couple small changes to support the explorer crate
- DiagramFormatter::new
- Make board::position public
2023-12-28 15:11:57 -07:00
5039d657ae [board] Some test helpers that produce Squares from algebraic notiation and assert their validity 2023-12-28 12:08:44 -07:00
dda4cd8a5a [board] Add a MoveGenerator struct 2023-12-27 10:02:37 -07:00
ff59799add [board] Move neighbor::Direction → square::Direction 2023-12-27 08:01:44 -07:00
8d06cbf0f8 [board] Make the piece module public and remove the crate-level export of Color and Piece 2023-12-26 21:36:38 -07:00
758a3d95fc [board] Reorganize bitboard and position modules and export some symbols from the crate
Move position.rs to the position module and create a mod.rs.
Do the same for bitboard.rs in the bitboard modules.
Export Color, Piece, Position, and Square and use crate::Thing directly instead of referring to the symbol in the nested modules.
2023-12-26 11:25:27 -07:00
9bcd0b2148 [board] Add neighbor and piece modules
Add a Direction enum in the neighbor module
Add Color and PieceShape enums, and a Piece struct to the piece module
2023-12-23 09:18:07 -07:00
d776bd18e2 [board] Move bitboard lib to "board" 2023-12-20 11:45:55 -08:00
Renamed from bitboard/src/lib.rs (Browse further)