summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2019-08-06 14:34:06 +0200
committerJustin Worthe <justin@worthe-it.co.za>2019-08-06 14:34:06 +0200
commit880f43e87614e2d256eff61f4bb5f4052de02e59 (patch)
tree6c4a807297bc409b57ddf3fbfc43c509403aab29
parent1e851a758e32834d909740df342831fef3d0e4b5 (diff)
New command type
-rw-r--r--src/bin/benchmark.rs2
-rw-r--r--src/command.rs15
-rw-r--r--src/json.rs1
-rw-r--r--src/main.rs2
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<i32>,
- 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<i8>),
Shoot(Direction),
Bomb(Point2d<i8>),
+ Snowball(Point2d<i8>),
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)
}
};