[position] Print the chess board diagram with box drawing characters
This commit is contained in:
parent
21b58a6422
commit
1f3c90ff35
1 changed files with 5 additions and 5 deletions
|
@ -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(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue