summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2020-03-28 21:11:47 +0200
committerJustin Wernick <justin@worthe-it.co.za>2020-03-28 21:11:47 +0200
commit6cb8ec85751b3936bc72f2a4aa052e08a575532e (patch)
tree5458b772809edfd47b83b232dfa15dc227ff7c20 /src/main.rs
Initial commit from starter bot
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..5d29529
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,27 @@
+use std::io::prelude::*;
+use std::io::stdin;
+
+mod command;
+mod json;
+
+use command::*;
+use json::*;
+
+fn main() {
+ for line in stdin().lock().lines() {
+ let round_number = line.expect("Failed to read line from stdin: {}");
+ let command =
+ match read_state_from_json_file(&format!("./rounds/{}/state.json", round_number)) {
+ Ok(state) => choose_command(state),
+ Err(e) => {
+ eprintln!("WARN: State file could not be parsed: {}", e);
+ Command::Nothing
+ }
+ };
+ println!("C;{};{}", round_number, command);
+ }
+}
+
+fn choose_command(state: State) -> Command {
+ Command::Accelerate
+}