From e746190a4a20ab135904059a09401064449a14bd Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 27 Apr 2023 19:13:06 -0400 Subject: [PATCH] Add coordinates to the board printout --- flake.nix | 1 + kifu/kifu-core/src/types.rs | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index d44619f..e223b90 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,7 @@ pkgs.pkg-config pkgs.sqlite pkgs.rustup + pkgs.cargo-nextest pkgs.crate2nix ]; LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; diff --git a/kifu/kifu-core/src/types.rs b/kifu/kifu-core/src/types.rs index 5cb2bce..68b05bc 100644 --- a/kifu/kifu-core/src/types.rs +++ b/kifu/kifu-core/src/types.rs @@ -170,7 +170,17 @@ pub struct Board { impl std::fmt::Display for Board { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + print!(" "); + for c in 'A'..'U' { + if c == 'I' { + continue; + } + print!(" {}", c); + } + println!(""); + for row in 0..self.size.height { + print!(" {:2}", row); for column in 0..self.size.width { match self.stone(Coordinate { column, row }) { None => write!(f, " .")?, @@ -366,6 +376,8 @@ mod test { ] .into_iter(), ); + println!("{}", board); + assert!(false); let test_cases = vec![ ( board.clone(), @@ -458,25 +470,20 @@ mod test { liberties ); } + } + + fn surrounding_a_stone_removes_it() { assert!(false); } - #[test] - fn surrounding_a_stone_remove_it() { - assert!(false); - } - - #[test] fn sorrounding_a_group_removes_it() { assert!(false); } - #[test] fn suicide_is_forbidden() { assert!(false); } - #[test] fn captures_preceed_self_capture() { assert!(false); }