Commit graph

155 commits

Author SHA1 Message Date
127dea25b4 Add validation error detail in 'FenError' 2024-04-01 22:20:39 +01:00
714feedbd2 Add 'ChessBoard::validate' 2024-04-01 22:20:39 +01:00
d3386bcb52 Add 'chess_board::InvalidError' 2024-04-01 22:20:39 +01:00
463b2a1a8f Move 'ChessBoard' to its own sub-folder 2024-04-01 22:20:39 +01:00
46ff51552a Check all piece counts in 'ChessBoard::is_valid' 2024-04-01 22:20:39 +01:00
3fa56b36a4 Check for invalid pawns in 'ChessBoard::is_valid' 2024-04-01 22:20:39 +01:00
33eb5d0707 Add 'print-board' GDB command 2024-04-01 22:20:39 +01:00
dcd76c5bef Add 'Bitboard.at' in GDB utils 2024-04-01 22:20:39 +01:00
a1005c1bec Add convenience 'Square' constructor in GDB utils 2024-04-01 22:20:39 +01:00
83a29cae2a Add 'CastleRights' GDB pretty-printing 2024-04-01 22:20:39 +01:00
52772167a6 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 22:20:39 +01:00
9dea85054d Add 'ChessBoard::checkers' 2024-04-01 22:20:39 +01:00
f582a76e70 Test for opponent being in check during validation 2024-04-01 22:20:39 +01:00
58d8743106 Use 'ChessBoard::occupancy' 2024-04-01 22:20:39 +01:00
d9e4f16ec8 Add 'ChessBoard::occupancy' 2024-04-01 22:20:39 +01:00
08ce3787df Check kings' position in 'ChessBoard::is_valid' 2024-04-01 22:20:39 +01:00
6976c60fe6 Add 'TryInto<Square>' for 'Bitboard' 2024-04-01 22:20:39 +01:00
bc67ee3e9a Test 'ChessBoard::{do,undo}_move' machinery 2024-04-01 22:20:39 +01:00
c1419f0e44 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 22:20:39 +01:00
3cd2601f07 Add 'ChessBoard::is_valid' 2024-04-01 22:20:39 +01:00
ddcef6f9c0 Add 'FenError::InvalidPosition' variant 2024-04-01 22:20:39 +01:00
c112ddc4cd Implement 'Default' for 'ChessBoard' 2024-04-01 22:20:39 +01:00
ce3ebf05ee Add 'ChessBoard::{,un}do_move' 2024-04-01 22:20:39 +01:00
d44461e35c Add 'ChessBoard' 2024-04-01 22:20:39 +01:00
64e93b39fd Add FEN castling rights parsing 2024-04-01 22:20:39 +01:00
7c896d5dba Add FEN piece type parsing 2024-04-01 22:20:39 +01:00
b5365f8a82 Add FEN en-passant target square parsing 2024-04-01 22:20:39 +01:00
3c2a5a412e Add FEN side to move parsing 2024-04-01 22:20:39 +01:00
bd662fdd27 Introduce 'FenError' enum 2024-04-01 22:20:39 +01:00
0fd9766db0 Add 'FromFen' trait 2024-04-01 22:20:39 +01:00
de27c186d3 Add 'Move' GDB pretty-printing 2024-04-01 22:20:39 +01:00
3b530b324f Add 'Piece' GDB pretty-printing 2024-04-01 22:20:39 +01:00
93e9a51589 Add 'Rank' GDB pretty-printing 2024-04-01 22:20:39 +01:00
d3c3790db4 Add 'File' GDB pretty-printing 2024-04-01 22:20:39 +01:00
8f3687d862 Add 'Color' GDB pretty-printing 2024-04-01 22:20:39 +01:00
4d69d34fa0 Add 'Move' 2024-04-01 22:20:39 +01:00
be8024d176 Deny warnings in 'clippy' pre-commit hook 2024-04-01 22:20:39 +01:00
0b9318cdf3 Add 'Bitboard::has_more_than_one' 2024-04-01 22:20:39 +01:00
e673e20a63 Add 'Color::third_rank' 2024-04-01 22:20:39 +01:00
0cc1fcf912 Add 'CastleRights::with_{king,queen}_side' 2024-04-01 22:20:39 +01:00
072a1ea13c Add '*Assign' operators to 'Bitboard' 2024-04-01 22:20:39 +01:00
02768b6d96 Remove all useless 'allow(unused)' 2024-04-01 22:20:39 +01:00
af421a9452 Tighten item visibilities 2024-04-01 22:20:39 +01:00
3b1735da79 Add 'BitboardIterator::new' 2024-04-01 22:20:39 +01:00
06087358de Add bitboard-based move generation 2024-04-01 22:20:39 +01:00
459b878342 Expose magic bitboard generation to parent module 2024-04-01 22:20:39 +01:00
2bdfbbf467 Add 'MagicMoves' 2024-04-01 22:20:39 +01:00
d519cfb817 Make 'Magic' 'pub(crate)' 2024-04-01 22:20:39 +01:00
25494700d7 Add missing derives to 'Magic' 2024-04-01 22:20:39 +01:00
028c4543e7 Move 'Magic' to 'wizardry' submodule 2024-04-01 22:20:39 +01:00