Remove Display trait from main structs
This commit is contained in:
40
src/board.rs
40
src/board.rs
@@ -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,
|
||||
|
||||
10
src/game.rs
10
src/game.rs
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user