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
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
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
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
3a15fca10a
[board] Remove the intermediate string in the Debug implementation for Position
2024-01-17 08:24:53 -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
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
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
e56d256812
[board] Fix two build errors
2024-01-14 10:26:36 -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
caef0af244
[board] Implement Default for Position
...
Default returns an empty position.
2024-01-11 08:18:31 -08:00
31e5771d30
[board] Implement all the bit twiddling to track whether castling is allowed for each player and side of the board
2024-01-10 11:01:19 -08:00
359bab9173
[board] Implement rook::ClassicalMoveGenerator
...
Implement a rook move generator using the "classical" approach.
This approach walks each ray to find blockers and then masks out friendly pieces.
This is not efficient compared to other approaches, but it's much easier to implement.
2024-01-06 19:51:06 -08:00
14db74f212
Remove tests module
2024-01-06 16:45:13 -08:00
aac1a85507
In Position::place_piece, take piece and square by value
...
Use values for BitBoards and other things too.
2024-01-06 16:24:46 -08:00
750b16970f
[board] Create const arrays for Shape that return &'static to its enum cases
2023-12-31 11:44:47 -08:00
878d771d86
[board] Replace Moves' separate properties with a Vec of Iterators
...
This makes iteration easier. Move to the next iterator if the current one returns None.
No tests for Moves yet though.
2023-12-31 11:44:47 -08:00
41421dddbb
[board] Clean up interfaces of pieces and square structs
2023-12-29 09:17:33 -08:00
65a7bec5f9
[board] Implement Position::move_generator
2023-12-29 08:59:13 -08:00
1a986e4c27
[board] Implement Position::occupied_squares and Position::empty_squares
...
These methods return bitboards marking the occupied and empty squares, made by ORing the two pieces_per_color bitboards.
2023-12-29 08:58:34 -08:00
2296be23cc
[board] Rename BitBoard::from_bit_field → ::new
2023-12-28 21:42:18 -07:00
af53eb932c
[board] Populate the color bitboards when placing pieces
2023-12-28 21:41:55 -07:00
50a6be2f72
[board] Pass piece argument to Position::bitboard_for_piece() by value instead of by reference
2023-12-27 08:31:02 -07:00
4bec1538a1
[board] Add the missing trailing } to fmt::Debug for Position
2023-12-27 08:01:44 -07:00
b9ba2629c4
[board] Fix the King's position in the Position::starting()
...
I wrote a test of the starting position for DiagramFormatter and discovered that Position::starting() was placing the king incorrectly. Fixed it!
2023-12-27 08:01:44 -07:00
19c48b9816
[board] Implement a DiagramFormatter that writes a graphical diagram of a Position
...
Remove fmt::Display from Position and move display to a DiagramFormatter type that implements that trait and writes a position to a formatter.
2023-12-26 21:37:22 -07:00
17511e9d63
[board] Implement a rather dumb Position::piece_on_square
...
This method does an iteration over all piece colors and shapes to find the piece on a given square.
2023-12-26 21:34:01 -07:00
a963cee1e7
Merge branch 'main' into pretty-print-position
2023-12-26 13:28:55 -07:00
9d0761f8c6
[board] Rename from_algebraic_string → from_algebraic_str
2023-12-26 13:28:25 -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