[position] Print the chess board diagram with box drawing characters

This commit is contained in:
Eryn Wells 2024-03-25 10:38:02 -07:00
parent 21b58a6422
commit 1f3c90ff35

View file

@ -14,23 +14,23 @@ impl<'a> DiagramFormatter<'a> {
impl<'a> fmt::Display for DiagramFormatter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, " +-----------------+\n")?;
write!(f, " ╔═════════════════╗\n")?;
for rank in Rank::ALL.iter().rev() {
write!(f, "{rank} | ")?;
write!(f, "{rank} ")?;
for file in File::ALL.iter() {
let square = Square::from_file_rank(*file, *rank);
match self.0.piece_on_square(square) {
Some(placed_piece) => write!(f, "{} ", placed_piece.piece())?,
None => write!(f, ". ")?,
None => write!(f, "· ")?,
}
}
write!(f, "|\n")?;
write!(f, "\n")?;
}
write!(f, " +-----------------+\n")?;
write!(f, " ╚═════════════════╝\n")?;
write!(f, " a b c d e f g h\n")?;
Ok(())