[board, core, moves, position] Implement castling
Implement a new method on Position that evaluates whether the active color can castle on a given wing of the board. Then, implement making a castling move in the position. Make a new Wing enum in the core crate to specify kingside or queenside. Replace the Castle enum from the board crate with this one. This caused a lot of churn... Along the way fix a bunch of tests. Note: there's still no way to actually make a castling move in explorer.
This commit is contained in:
parent
6816e350eb
commit
0c1863acb9
18 changed files with 499 additions and 258 deletions
|
@ -3,22 +3,5 @@
|
|||
mod parameters;
|
||||
mod rights;
|
||||
|
||||
pub use parameters::Parameters;
|
||||
pub use rights::Rights;
|
||||
|
||||
use chessfriend_core::Color;
|
||||
use parameters::Parameters;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub enum Castle {
|
||||
KingSide = 0,
|
||||
QueenSide = 1,
|
||||
}
|
||||
|
||||
impl Castle {
|
||||
pub const ALL: [Castle; 2] = [Castle::KingSide, Castle::QueenSide];
|
||||
|
||||
pub fn parameters(self, color: Color) -> &'static Parameters {
|
||||
&Parameters::BY_COLOR[color as usize][self as usize]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue