blob: c5f7857306fd02ebfe443d8c2fe551a640b9bc10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use std::io::prelude::*;
use std::io::stdin;
use vroomba::command::Command;
use vroomba::*;
fn main() {
for line in stdin().lock().lines() {
let round_number = line
.expect("Failed to read line from stdin: {}")
.parse::<usize>()
.expect("Round number was not an unsigned integer: {}");
let command =
match json::read_state_from_json_file(&format!("./rounds/{}/state.json", round_number))
{
Ok(state) => choose_command(round_number, &state),
Err(e) => {
eprintln!("WARN: State file could not be parsed: {}", e);
Command::Nothing
}
};
println!("C;{};{}", round_number, command);
}
}
|