8835d8b40e
[board] Add position::tests::rook_for_castle
2024-01-21 10:39:24 -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
7b8ce3b31d
[board] Derive Copy for Move
2024-01-21 09:21:48 -08:00
32ee25539d
[board] Fix some en passant related stuff in the the sight module
2024-01-21 09:21:27 -08:00
d298a55254
[board] Clean up some stray muts and imports in the bishop move generator module
2024-01-21 09:20:31 -08:00
4a5ae8ec59
[board] Move position builders into a builders module
...
Move PositionBuilder to position_builder.rs and export it from the builders module.
2024-01-21 09:20:03 -08:00
1a907844d6
[board] Update a bunch of methods to take &Piece instead of plain Piece
2024-01-21 09:18:16 -08:00
f7951d6110
[board] Implement some is_shape getters on Piece and PlacedPiece
2024-01-21 09:15:41 -08:00
620701057d
[board] Rehash BitBoard's std::ops implementations
...
Implement bitwise AND and OR for all permutations of BitBoard and &BitBoard.
Refer to the std::ops traits by fully-qualified path rather than requiring the
module to import those traits to implement them.
Implement bitwise AND and OR assignment (&= and |=) for BitBoard and &BitBoard.
Implement XOR and XOR assignment for BitBoards.
2024-01-21 09:14:02 -08:00
918b68f300
[board] Use Castle as the interface type for methods related to castling
...
Use BoardSide as an internal type for looking up generated bitboards, target squares, etc.
2024-01-21 09:05:42 -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
7f4485ed51
[board] Make the trailing comma in bitboard! optional
...
This a neat trick!
2024-01-19 18:09:22 -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
939fac80d7
[board] Implement Default for BitBoard and Color
2024-01-19 18:09:05 -08:00
c413db0bf1
[board] Clean up Display and Debug implementations on BitBoard, Flags, Position, and PlacedPiece
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
e56b3259e2
[board] Implement FromIterator for BitBoard
2024-01-17 08:48:46 -08:00
f337b8053d
[board] Break getting the square the king is on into a separate helper method
...
Implement Position::king_square() and use it in is_king_in_check()
2024-01-17 08:48:23 -08:00
4fe9be036d
[board] Reexport AlgebraicMoveFormatter from the move module
2024-01-17 08:47:48 -08:00
771081a5df
[board] Derive Clone and Debug for MoveBuilder
2024-01-17 08:47:35 -08:00
e2f8faad3d
[board] Implement Default for move::move_formatter::Style
2024-01-17 08:47:16 -08:00
71e93925b9
[board] Clean up a handful of things in position.rs
...
- Remove unused std::fmt::Write import
- Refer to the piece! macro with $crate (I didn't know this was legal??)
- Remove the doc comments on Position::flags
- Remove {set,clear}_player_has_right_to_castle_flag
- Remove an extraneous local variable from Position::place_piece()
2024-01-17 08:46:41 -08:00
ac5d8cc9d5
[board] Implement a move generator test for a single king
2024-01-17 08:44:51 -08:00
3ba6722697
[board] Implement a bunch of sight tests
2024-01-17 08:44:27 -08:00
2174bcf009
[board] Update all the move generator submodules to use MoveBuilder instead of Move
...
Along the way update "manual" piece creation to use the macros instead.
2024-01-17 08:43:48 -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
2d4ad70994
[board] Refer to Position with $crate in the position! macro
2024-01-17 08:36:00 -08:00
c8db5a430d
[board] Fix a silly build error in position.rs
...
An extra closing brace.
2024-01-17 08:35:42 -08:00
f27d22d57f
[board] Implement some TryInto traits for Square for u8, u16, u32, and u64
2024-01-17 08:35:21 -08:00
3a15fca10a
[board] Remove the intermediate string in the Debug implementation for Position
2024-01-17 08:24:53 -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
96b04379a4
[board] Implement Position::is_king_in_check()
...
Returns true if the king of the current player is in check.
2024-01-15 20:10:58 -08:00
81d544f0d5
[board] Rename BitBoard::has_piece_at → is_set
2024-01-15 17:42:27 -08:00
98fce9acde
[board] Fix the shape_into_char test
2024-01-15 17:18:18 -08:00
e9607573c2
[board] Use absolute paths with $crate in the piece! macro
2024-01-15 17:17:57 -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
9ef53b76f5
[board] Rename BitBoard::place_piece_at and BitBoard::remove_piece_at
...
→ set_square
→ clear_square
2024-01-15 17:16:14 -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
3b40aacd52
Quick text file of all the Unicode chess characters
2024-01-14 10:58: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
64b47a8d70
[board] Remove unused PlacedPiece::bitboard()
2024-01-14 10:27:04 -08:00
e56d256812
[board] Fix two build errors
2024-01-14 10:26:36 -08:00
284b3b68a0
[board] Add another test to the position flags
2024-01-14 10:19:20 -08:00
953c2f1522
[board] Move position flags to a Flags struct in its own module
2024-01-13 11:15:09 -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
d2ee9244c2
[board] Update Position::player_has_right_to_castle callsites
2024-01-11 08:37:22 -08:00
094131822c
[board] Implement move_formatter::AlgebraicMoveFormatter
2024-01-11 08:33:58 -08:00