From 880f43e87614e2d256eff61f4bb5f4052de02e59 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Tue, 6 Aug 2019 14:34:06 +0200 Subject: New command type --- src/bin/benchmark.rs | 2 +- src/command.rs | 15 +++++++-------- src/json.rs | 1 + src/main.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin/benchmark.rs b/src/bin/benchmark.rs index 52e360f..0cee8d6 100644 --- a/src/bin/benchmark.rs +++ b/src/bin/benchmark.rs @@ -16,7 +16,7 @@ fn main() { let _ = choose_move(&new_board, None, start_time, max_time); } Err(e) => { - //eprintln!("WARN: State file could not be parsed: {}", e); + eprintln!("WARN: State file could not be parsed: {}", e); } }; } diff --git a/src/command.rs b/src/command.rs index 1ffdd35..c0315db 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,18 +1,18 @@ -use std::fmt; use crate::geometry::Direction; use crate::geometry::Point2d; +use std::fmt; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct Command { pub worm: Option, - pub action: Action + pub action: Action, } impl fmt::Display for Command { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.worm { Some(worm) => write!(f, "select {};{}", worm, self.action), - None => write!(f, "{}", self.action) + None => write!(f, "{}", self.action), } } } @@ -21,15 +21,12 @@ impl Command { pub fn with_select(worm: i32, action: Action) -> Command { Command { worm: Some(worm), - action + action, } } pub fn new(action: Action) -> Command { - Command { - worm: None, - action - } + Command { worm: None, action } } } @@ -39,6 +36,7 @@ pub enum Action { Dig(Point2d), Shoot(Direction), Bomb(Point2d), + Snowball(Point2d), DoNothing, } @@ -50,6 +48,7 @@ impl fmt::Display for Action { Dig(p) => write!(f, "dig {} {}", p.x, p.y), Shoot(dir) => write!(f, "shoot {}", dir), Bomb(p) => write!(f, "banana {} {}", p.x, p.y), + Snowball(p) => write!(f, "snowball {} {}", p.x, p.y), DoNothing => write!(f, "nothing"), } } diff --git a/src/json.rs b/src/json.rs index 73d28e9..66864cf 100644 --- a/src/json.rs +++ b/src/json.rs @@ -114,6 +114,7 @@ pub struct Cell { pub enum CellType { Air, Dirt, + Lava, DeepSpace, } diff --git a/src/main.rs b/src/main.rs index 03d08ff..280df8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ fn main() { } }, Err(e) => { - //eprintln!("WARN: State file could not be parsed: {}", e); + eprintln!("WARN: State file could not be parsed: {}", e); Command::new(Action::DoNothing) } }; -- cgit v1.2.3