Commit graph

109 commits

Author SHA1 Message Date
cc520ea413 Use 'ChessBoardBuilder' in validation tests
The various tests for overlapping can't be triggered with the builder
API, so those have stayed unchanged.
2024-04-01 22:15:41 +01:00
8962fd90f4 Add 'ChessBoardBuilder' 2024-04-01 21:19:55 +01:00
bce690d363 Use 'ChessBoard::validate' in tests
This makes the test more explicit and exact in what they're testing.
2024-04-01 20:43:05 +01:00
4b13bd9a0b Fix 'ChessBoard' validation test
It wasn't actually testing the right thing due to the typo...
2024-04-01 20:43:05 +01:00
90a9ac0f7a Add validation error detail in 'FenError' 2024-04-01 20:43:05 +01:00
4098f188ce Add 'ChessBoard::validate' 2024-04-01 20:43:05 +01:00
5ddab6af0e Add 'chess_board::InvalidError' 2024-04-01 20:43:05 +01:00
c3a9a55be1 Move 'ChessBoard' to its own sub-folder 2024-04-01 19:56:48 +01:00
009cb44eab Check all piece counts in 'ChessBoard::is_valid' 2024-04-01 19:44:24 +01:00
ea301659c0 Check for invalid pawns in 'ChessBoard::is_valid' 2024-04-01 19:11:37 +01:00
afa0172f6a Add 'print-board' GDB command 2024-04-01 14:53:09 +01:00
9056747448 Add 'Bitboard.at' in GDB utils 2024-04-01 14:38:26 +01:00
905cca4576 Add convenience 'Square' constructor in GDB utils 2024-04-01 14:37:39 +01:00
66fff65a55 Add 'CastleRights' GDB pretty-printing 2024-04-01 13:59:41 +01:00
a1065baff5 Pre-generate the magic bitboard seeds
My naive RNG implementation takes about ~40 seconds to generate the
magic bitboards for both bishops and rooks (or ~1 second in release
mode).

If we pre-generate the seeds, we can instead make it ~instantaneous.

The self-modifying code is inspired by matklad [1].

[1]: https://matklad.github.io/2022/03/26/self-modifying-code.html
2024-04-01 13:59:41 +01:00
2ab1f363ea Add 'ChessBoard::checkers' 2024-04-01 13:59:41 +01:00
eb53e27f9d Test for opponent being in check during validation 2024-04-01 13:59:41 +01:00
b75136f7d6 Use 'ChessBoard::occupancy' 2024-04-01 13:59:41 +01:00
23a4e857a0 Add 'ChessBoard::occupancy' 2024-04-01 13:59:41 +01:00
c115e357e1 Check kings' position in 'ChessBoard::is_valid' 2024-04-01 13:59:41 +01:00
aaab439764 Add 'TryInto<Square>' for 'Bitboard' 2024-04-01 13:59:41 +01:00
0d8feca6b1 Test 'ChessBoard::{do,undo}_move' machinery 2024-04-01 13:59:41 +01:00
fb78e03656 Add FEN board parsing
Unfortunately, given that I *don't* want to expose all the `ChessBoard`
fields to the rest of the crate, this implementation will have to live
alongside its module instead of inside `crate::fen`...
2024-04-01 13:59:41 +01:00
2e1b732996 Add 'ChessBoard::is_valid' 2024-04-01 13:59:41 +01:00
4b2eb4604f Add 'FenError::InvalidPosition' variant 2024-04-01 13:59:41 +01:00
63380cabbc Implement 'Default' for 'ChessBoard' 2024-04-01 13:59:41 +01:00
22de0785fa Add 'ChessBoard::{,un}do_move' 2024-04-01 13:59:41 +01:00
5a9b3a7d97 Add 'ChessBoard' 2024-04-01 13:59:41 +01:00
bbf5149f71 Add FEN castling rights parsing 2024-04-01 13:59:41 +01:00
4ed3105111 Add FEN piece type parsing 2024-04-01 13:59:41 +01:00
3ab73a08d8 Add FEN en-passant target square parsing 2024-04-01 13:59:41 +01:00
8866c35423 Add FEN side to move parsing 2024-04-01 13:59:41 +01:00
e8a7825215 Introduce 'FenError' enum 2024-04-01 13:59:41 +01:00
43fb428749 Add 'FromFen' trait 2024-04-01 13:59:41 +01:00
a26c532015 Add 'Move' GDB pretty-printing 2024-04-01 13:59:41 +01:00
e1a1532872 Add 'Piece' GDB pretty-printing 2024-04-01 13:59:41 +01:00
1a71854589 Add 'Rank' GDB pretty-printing 2024-04-01 13:59:41 +01:00
ca68ccf92c Add 'File' GDB pretty-printing 2024-04-01 13:59:41 +01:00
a7ed24c752 Add 'Color' GDB pretty-printing 2024-04-01 13:59:41 +01:00
ddc8ecc474 Add 'Move' 2024-04-01 12:21:33 +01:00
856c3a873d Deny warnings in 'clippy' pre-commit hook 2024-04-01 12:21:33 +01:00
19d0e1bd34 Add 'Bitboard::has_more_than_one' 2024-04-01 12:21:33 +01:00
be5e9722de Add 'Color::third_rank' 2024-04-01 12:21:33 +01:00
80ea35babe Add 'CastleRights::with_{king,queen}_side' 2024-04-01 12:21:33 +01:00
54d2e78954 Add '*Assign' operators to 'Bitboard' 2024-04-01 12:21:33 +01:00
4de41a5544 Remove all useless 'allow(unused)' 2024-04-01 12:21:33 +01:00
be506747f8 Tighten item visibilities 2024-04-01 12:21:33 +01:00
6feca16b61 Add 'BitboardIterator::new' 2024-04-01 12:21:33 +01:00
9cf5fc3852 Add bitboard-based move generation 2024-04-01 12:21:33 +01:00
8fe444c59a Expose magic bitboard generation to parent module 2024-04-01 12:21:33 +01:00