[core,board] Update all use imports referring to Square, Rank, and File

This commit is contained in:
Eryn Wells 2024-01-24 08:32:09 -08:00
parent 3c3a62345d
commit 106800bcb3
16 changed files with 40 additions and 40 deletions

View file

@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chess_core = { path = "../chess_core" }

View file

@ -3,8 +3,9 @@
use crate::{
piece::{Piece, PlacedPiece},
r#move::Castle,
Color, File, Position, Rank, Square,
Color, Position,
};
use chess_core::{File, Rank, Square};
use std::fmt::Write;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@ -42,7 +43,7 @@ impl ToFen for Position {
write!(fen_string, "{}", empty_squares).map_err(|err| FenError::FmtError(err))?;
empty_squares = 0;
}
if rank != &Rank::One {
if rank != &Rank::ONE {
write!(fen_string, "/").map_err(|err| FenError::FmtError(err))?;
}
}

View file

@ -16,6 +16,5 @@ mod sight;
pub use piece::{Color, Piece};
pub use position::{MoveBuilder as MakeMoveBuilder, Position, PositionBuilder};
pub use r#move::{Castle, MakeMoveError, Move, MoveBuilder};
pub use square::{File, Rank, Square};
pub(crate) use bitboard::BitBoard;

View file

@ -6,7 +6,7 @@ macro_rules! piece {
$crate::piece::Piece::new($crate::piece::Color::$color, $crate::piece::Shape::$shape)
};
($color:ident $shape:ident on $square:ident) => {
$crate::piece::PlacedPiece::new(piece!($color $shape), $crate::square::Square::$square)
$crate::piece::PlacedPiece::new(piece!($color $shape), chess_core::Square::$square)
}
}

View file

@ -1,10 +1,7 @@
// Eryn Wells <eryn@erynwells.me>
use crate::{
piece::{Piece, PlacedPiece, Shape},
square::Rank,
Square,
};
use crate::piece::{Piece, PlacedPiece, Shape};
use chess_core::{Rank, Square};
use std::fmt;
pub use castle::Castle;
@ -20,7 +17,8 @@ pub enum MakeMoveError {
}
mod castle {
use crate::{Color, Square};
use crate::Color;
use chess_core::Square;
#[repr(u16)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@ -248,8 +246,8 @@ impl MoveBuilder {
Shape::Pawn => {
let from_rank = from.rank();
let to_rank = to.rank();
let is_white_double_push = from_rank == Rank::Two && to_rank == Rank::Four;
let is_black_double_push = from_rank == Rank::Seven && to_rank == Rank::Five;
let is_white_double_push = from_rank == Rank::TWO && to_rank == Rank::FOUR;
let is_black_double_push = from_rank == Rank::SEVEN && to_rank == Rank::FIVE;
if is_white_double_push || is_black_double_push {
Kind::DoublePush
} else {
@ -421,8 +419,8 @@ mod move_formatter {
$crate::piece::Color::$color,
$crate::piece::Shape::$shape,
),
$crate::Square::$from_square,
$crate::Square::$to_square,
chess_core::Square::$from_square,
chess_core::Square::$to_square,
)
.build()
};
@ -432,15 +430,15 @@ mod move_formatter {
$crate::piece::Color::$color,
$crate::piece::Shape::$shape,
),
$crate::Square::$from_square,
$crate::Square::$to_square,
chess_core::Square::$from_square,
chess_core::Square::$to_square,
)
.capturing($crate::piece::PlacedPiece::new(
$crate::piece::Piece::new(
$crate::piece::Color::$captured_color,
$crate::piece::Shape::$captured_shape,
),
$crate::Square::$to_square,
chess_core::Square::$to_square,
))
.build()
};

View file

@ -3,9 +3,9 @@
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
use crate::{
piece::{Color, Piece, PlacedPiece},
square::Direction,
BitBoard, MoveBuilder, Position,
};
use chess_core::Direction;
move_generator_declaration!(ClassicalMoveGenerator);

View file

@ -3,9 +3,9 @@
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
use crate::{
piece::{Color, Piece, PlacedPiece},
square::Direction,
BitBoard, MoveBuilder, Position,
};
use chess_core::Direction;
move_generator_declaration!(ClassicalMoveGenerator);

View file

@ -3,9 +3,9 @@
use super::{move_generator_declaration, MoveGeneratorInternal, MoveSet};
use crate::{
piece::{Color, Piece, PlacedPiece},
square::Direction,
BitBoard, MoveBuilder, Position,
};
use chess_core::Direction;
move_generator_declaration!(ClassicalMoveGenerator);
@ -62,9 +62,8 @@ impl<'pos> MoveGeneratorInternal for ClassicalMoveGenerator<'pos> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
piece::Piece, position, position::DiagramFormatter, BitBoard, Color, Position, Square,
};
use crate::{piece::Piece, position, position::DiagramFormatter, BitBoard, Color, Position};
use chess_core::Square;
#[test]
fn classical_single_rook_bitboard() {

View file

@ -1,9 +1,7 @@
// Eryn Wells <eryn@erynwells.me>
use crate::{
display::{ASCIIDisplay, FENDisplay, UnicodeDisplay},
Square,
};
use crate::display::{ASCIIDisplay, FENDisplay, UnicodeDisplay};
use chess_core::Square;
use std::fmt;
use std::slice::Iter;

View file

@ -4,9 +4,9 @@ use crate::{
piece::{PlacedPiece, Shape},
position::flags::Flags,
r#move::Castle,
square::Direction,
BitBoard, Color, MakeMoveError, Move, Piece, Position, Square,
BitBoard, Color, MakeMoveError, Move, Piece, Position,
};
use chess_core::{Direction, Square};
/// A position builder that builds a new position by making a move.
#[derive(Clone)]

View file

@ -5,9 +5,9 @@ use crate::{
piece::{PlacedPiece, Shape},
position::{flags::Flags, piece_sets::PieceBitBoards},
r#move::Castle,
square::{Direction, Rank},
BitBoard, Color, MakeMoveError, Move, Piece, Position, Square,
BitBoard, Color, MakeMoveError, Move, Piece, Position,
};
use chess_core::{Rank, Square};
use std::collections::BTreeMap;
#[derive(Clone)]
@ -100,7 +100,7 @@ impl Builder {
// Pawns cannot be placed on the first (back) rank of their side,
// and cannot be placed on the final rank without a promotion.
let rank = piece.square().rank();
return rank != Rank::One && rank != Rank::Eight;
return rank != Rank::ONE && rank != Rank::EIGHT;
}
true

View file

@ -1,6 +1,7 @@
// Eryn Wells <eryn@erynwells.me>
use crate::{File, Position, Rank, Square};
use crate::Position;
use chess_core::{File, Rank, Square};
use std::fmt;
pub struct DiagramFormatter<'a>(&'a Position);

View file

@ -2,8 +2,9 @@
use crate::{
piece::{Piece, PlacedPiece},
BitBoard, Color, Square,
BitBoard, Color,
};
use chess_core::Square;
#[derive(Debug, Eq, PartialEq)]
pub enum PlacePieceStrategy {

View file

@ -3,7 +3,7 @@
use super::Position;
use crate::piece::{Color, Piece, PlacedPiece, Shape};
use crate::BitBoard;
use crate::Square;
use chess_core::Square;
pub struct Pieces<'a> {
color: Color,
@ -76,7 +76,6 @@ impl<'a> Iterator for Pieces<'a> {
mod tests {
use super::*;
use crate::piece::{Color, Piece, Shape};
use crate::Square;
use crate::{Position, PositionBuilder};
use std::collections::HashSet;

View file

@ -7,8 +7,9 @@ use crate::{
position::DiagramFormatter,
r#move::Castle,
sight::Sight,
BitBoard, Move, Square,
BitBoard, Move,
};
use chess_core::Square;
use std::{cell::OnceCell, fmt};
#[derive(Clone, Debug, Eq, PartialEq)]
@ -266,7 +267,8 @@ impl fmt::Display for Position {
#[cfg(test)]
mod tests {
use crate::{position, Castle, Color, Position, Square};
use crate::{position, Castle, Color, Position};
use chess_core::Square;
#[test]
fn piece_on_square() {

View file

@ -2,9 +2,9 @@
use crate::{
piece::{Color, PlacedPiece, Shape},
square::Direction,
BitBoard, Position,
};
use chess_core::Direction;
pub(crate) trait Sight {
fn sight_in_position(&self, position: &Position) -> BitBoard;
@ -174,7 +174,8 @@ mod tests {
}
mod pawn {
use crate::{sight::Sight, BitBoard, Square};
use crate::{sight::Sight, BitBoard};
use chess_core::Square;
sight_test!(e4_pawn, piece!(White Pawn on E4), bitboard!(D5, F5));