diff --git a/board/src/lib.rs b/board/src/lib.rs index 0585d6f..d91df46 100644 --- a/board/src/lib.rs +++ b/board/src/lib.rs @@ -8,8 +8,7 @@ mod r#move; mod macros; mod move_generator; pub mod piece; -#[macro_use] -pub mod position; +mod position; mod sight; mod square; diff --git a/board/src/position/position.rs b/board/src/position/position.rs index ee76ed9..c2cb5dc 100644 --- a/board/src/position/position.rs +++ b/board/src/position/position.rs @@ -4,10 +4,11 @@ use super::{flags::Flags, piece_sets::PieceBitBoards, Pieces}; use crate::{ move_generator::Moves, piece::{Color, Piece, PlacedPiece, Shape}, + position::DiagramFormatter, sight::Sight, BitBoard, Move, Square, }; -use std::cell::OnceCell; +use std::{cell::OnceCell, fmt}; /// A lateral side of the board relative to the player. Kingside is the side the /// player's king starts on. Queenside is the side of the board the player's @@ -211,6 +212,12 @@ impl Default for Position { } } +impl fmt::Display for Position { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", DiagramFormatter::new(self)) + } +} + #[cfg(test)] mod tests { use crate::position; diff --git a/explorer/src/main.rs b/explorer/src/main.rs index 7eebb2b..9da6a64 100644 --- a/explorer/src/main.rs +++ b/explorer/src/main.rs @@ -1,5 +1,4 @@ use board::piece::{Color, Piece, Shape}; -use board::position::DiagramFormatter; use board::{Position, Square}; use clap::{Arg, Command}; use rustyline::error::ReadlineError; @@ -80,8 +79,7 @@ fn main() -> Result<(), String> { let mut pos = Position::empty(); loop { - let diagram = DiagramFormatter::new(&pos); - println!("{}", diagram); + println!("{}", &pos); let readline = editor.readline("? "); match readline {