[board] Pretty print a board with rank and file notations but no pieces
This commit is contained in:
parent
1575c83d31
commit
cc793fdad6
1 changed files with 22 additions and 1 deletions
|
@ -126,7 +126,28 @@ impl fmt::Debug for Position {
|
||||||
|
|
||||||
impl fmt::Display for Position {
|
impl fmt::Display for Position {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "abcdefg")
|
let mut output = String::new();
|
||||||
|
|
||||||
|
output.push_str(" +-----------------+\n");
|
||||||
|
|
||||||
|
for rank in (0..8).rev() {
|
||||||
|
output.push_str("{rank} | ");
|
||||||
|
|
||||||
|
for file in 0..8 {
|
||||||
|
let square = Square::from_rank_file(rank, file);
|
||||||
|
// TODO: Get piece at square
|
||||||
|
output.push_str(". ");
|
||||||
|
}
|
||||||
|
|
||||||
|
output.push_str("|\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
output.push_str(" +-----------------+\n");
|
||||||
|
output.push_str(" a b c d e f g h\n");
|
||||||
|
|
||||||
|
write!(f, "{}", output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue