Remove Display trait from main structs

This commit is contained in:
2024-06-29 16:13:46 +03:00
parent 07af7294fa
commit 349007a445
3 changed files with 2 additions and 51 deletions

View File

@@ -1,4 +1,3 @@
use std::fmt;
use u64 as Bitboard;
use crate::attack::{
@@ -139,28 +138,7 @@ impl Default for Board {
}
}
impl fmt::Display for Board {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for piece in &self.white_pieces {
writeln!(
f,
"Color: {:?}\nKind: {:?}\n{piece}",
piece.color, piece.kind
)?;
}
writeln!(f)?;
for piece in &self.black_pieces {
writeln!(
f,
"Color: {:?}\nKind: {:?}\n{piece}",
piece.color, piece.kind
)?;
}
writeln!(f)
}
}
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Piece {
pub bitboard: Bitboard,
pub kind: Kind,
@@ -177,21 +155,7 @@ impl Piece {
}
}
impl fmt::Display for Piece {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for rank in (0..8).rev() {
for file in 0..8 {
let square = 1 << (rank * 8 + file);
let position = if square & self.bitboard != 0x0 { 1 } else { 0 };
write!(f, "{} ", position)?;
}
writeln!(f)?;
}
writeln!(f)
}
}
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Kind {
Pawn,
Knight,

View File

@@ -79,16 +79,6 @@ impl State {
}
}
use std::fmt;
impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f,
"side_to_move: {:?}\ncastling_ability: {:?}\nen_passant_target_square: {:b}\nhalfmove_clock: {}\nfullmove_counter: {}\n",
self.side_to_move, self.castling_ability, 1_u64 << self.en_passant_target_square.unwrap_or(0), self.halfmove_clock, self.fullmove_counter)
}
}
impl Default for State {
fn default() -> Self {
Self::new()

View File

@@ -150,16 +150,13 @@ pub fn init_magic_arrays() {
for idx in 0..64 {
let rook_magic_number =
find_rook_magic_numbers(ROOK_RELEVANT_BITS[idx], 1_u64 << (idx), &mut state);
println!("0x{:x},", rook_magic_number);
unsafe {
ROOK_MAGIC_INIT[idx] = rook_magic_number;
}
}
println!("\n\n");
for idx in 0..64 {
let bishop_magic_number =
find_bishop_magic_numbers(BISHOP_RELEVANT_BITS[idx], 1_u64 << (idx), &mut state);
println!("0x{:x},", bishop_magic_number);
unsafe {
BISHOP_MAGIC_INIT[idx] = bishop_magic_number;
}