Commit graph

18 commits

Author SHA1 Message Date
f27d22d57f [board] Implement some TryInto traits for Square for u8, u16, u32, and u64 2024-01-17 08:35:21 -08:00
0bc7e8d542 [board] Implement some castling checks on Move
Define some constants in Square that refer to the starting positions of the two
kings, and the target castling squares. Then implement the following methods that
use those constants to determine if a move is a castle.

- Move::is_kingside_castle()
- Move::is_queenside_castle()
- Move::is_castle()

These checks only apply to King moves, and if the king is moving from and to
specific squares.
2024-01-10 13:37:18 -08:00
8cc7e64ba6 [board] Fix a handful of linter warnings by allowing them
The linter also requires non-compliant formatting of the constants produced in
the coordinate_enum macro to be marked as allowed.
2024-01-06 20:51:23 -08:00
e4a4477157 [board] Remove an unused BitBoard import from square.rs 2024-01-06 20:34:44 -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
1689da9908 [board] Derive Ord and PartialOrd on Square 2024-01-06 08:50:27 -08:00
e232d3e19b [board] Implement Into<BitBoard> on Squares
Returns a BitBoard representing the square.
2024-01-05 18:29:03 -08:00
3b3062108a [board] Implement fmt::Display on Square
Prints the square in algebraic notation
2024-01-05 18:29:01 -08:00
41421dddbb [board] Clean up interfaces of pieces and square structs 2023-12-29 09:17:33 -08:00
ff59799add [board] Move neighbor::Direction → square::Direction 2023-12-27 08:01:44 -07:00
9d0761f8c6 [board] Rename from_algebraic_string → from_algebraic_str 2023-12-26 13:28:25 -07:00
e0f1e1f6ff [board] Derive a bunch of traits for Color, Shape, Piece, and Square 2023-12-26 09:15:24 -07:00
1da827a3bb [board] Implement a BitScanner on u64
This struct implements an Iterator that returns the positions of the 1 bits in the u64.
BitBoard takes this iterator and maps it into Squares in the pieces() method.

This is laying the groundwork for an iterator over the pieces in a Position. 👀
2023-12-23 23:04:18 -07:00
153e21b693 [board] Implement finding a neighbor of a square
Use the Direction enum to calculate the neighbor of a square with bounds checking.
Remove the unused rank_index() and file_index methods.
Add Square::from_rank_file and Square::from_index_unsafe to support tests.
Unify the Square*OutOfBounds error types
2023-12-23 09:30:45 -07:00
341d8211ad [board] Fix algebraic square parsing
I got very confused about which one is the rank and which one is the file. 🙃
2023-12-23 09:27:56 -07:00
0a42adf1fa [board] Re-do the Square implementation
- Rank and file are 0-indexed values
- Add an index property, a 1D index into an array
- Add from_index() and from_algebraic_string()
2023-12-21 08:15:51 -08:00
d776bd18e2 [board] Move bitboard lib to "board" 2023-12-20 11:45:55 -08:00
Renamed from bitboard/src/square.rs (Browse further)