[core,board] Move board::piece to core
Break up types in core into finer grained modules. Update all the imports.
This commit is contained in:
parent
6f85305912
commit
8b2a3926b3
25 changed files with 235 additions and 227 deletions
|
@ -1,17 +1,22 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use crate::{
|
||||
piece::{Color, PlacedPiece, Shape},
|
||||
Position,
|
||||
};
|
||||
use crate::Position;
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::Direction;
|
||||
use chessfriend_core::{Color, Direction, PlacedPiece, Shape};
|
||||
|
||||
pub(crate) trait Sight {
|
||||
pub(crate) trait SightExt {
|
||||
fn sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
|
||||
fn white_pawn_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
fn black_pawn_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
fn knight_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
fn bishop_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
fn rook_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
fn queen_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
fn king_sight_in_position(&self, position: &Position) -> BitBoard;
|
||||
}
|
||||
|
||||
impl Sight for PlacedPiece {
|
||||
impl SightExt for PlacedPiece {
|
||||
fn sight_in_position(&self, position: &Position) -> BitBoard {
|
||||
match self.shape() {
|
||||
Shape::Pawn => match self.color() {
|
||||
|
@ -25,9 +30,7 @@ impl Sight for PlacedPiece {
|
|||
Shape::King => self.king_sight_in_position(position),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PlacedPiece {
|
||||
fn white_pawn_sight_in_position(&self, position: &Position) -> BitBoard {
|
||||
let pawn: BitBoard = self.square().into();
|
||||
let pawn = pawn.shift_north_west_one() | pawn.shift_north_east_one();
|
||||
|
@ -175,9 +178,9 @@ mod tests {
|
|||
}
|
||||
|
||||
mod pawn {
|
||||
use crate::sight::Sight;
|
||||
use crate::{sight::SightExt, test_position};
|
||||
use chessfriend_bitboard::{bitboard, BitBoard};
|
||||
use chessfriend_core::Square;
|
||||
use chessfriend_core::{piece, Square};
|
||||
|
||||
sight_test!(e4_pawn, piece!(White Pawn on E4), bitboard!(D5, F5));
|
||||
|
||||
|
@ -235,8 +238,9 @@ mod tests {
|
|||
|
||||
#[macro_use]
|
||||
mod knight {
|
||||
use crate::sight::Sight;
|
||||
use crate::sight::SightExt;
|
||||
use chessfriend_bitboard::bitboard;
|
||||
use chessfriend_core::piece;
|
||||
|
||||
sight_test!(
|
||||
f6_knight,
|
||||
|
@ -246,8 +250,9 @@ mod tests {
|
|||
}
|
||||
|
||||
mod bishop {
|
||||
use crate::sight::Sight;
|
||||
use crate::sight::SightExt;
|
||||
use chessfriend_bitboard::bitboard;
|
||||
use chessfriend_core::piece;
|
||||
|
||||
sight_test!(
|
||||
c2_bishop,
|
||||
|
@ -257,8 +262,9 @@ mod tests {
|
|||
}
|
||||
|
||||
mod rook {
|
||||
use crate::sight::Sight;
|
||||
use crate::sight::SightExt;
|
||||
use chessfriend_bitboard::bitboard;
|
||||
use chessfriend_core::piece;
|
||||
|
||||
sight_test!(
|
||||
g3_rook,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue