code_games/line_racing/src/main.rs

34 lines
1.3 KiB
Rust

use std::io;
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
fn main() {
loop {
let mut input_line = String::new();
io::stdin().read_line(&mut input_line).unwrap();
let inputs = input_line.split(" ").collect::<Vec<_>>();
let n = parse_input!(inputs[0], usize); // total number of players (2 to 4).
let p = parse_input!(inputs[1], usize); // your player number (0 to 3).
for i in 0..n as usize {
let mut input_line = String::new();
io::stdin().read_line(&mut input_line).unwrap();
let inputs = input_line.split(" ").collect::<Vec<_>>();
let x0 = parse_input!(inputs[0], usize); // starting X coordinate of lightcycle (or -1)
let y0 = parse_input!(inputs[1], usize); // starting Y coordinate of lightcycle (or -1)
let x1 = parse_input!(inputs[2], usize); // starting X coordinate of lightcycle (can be the same as X0 if you play before this player)
let y1 = parse_input!(inputs[3], usize); // starting Y coordinate of lightcycle (can be the same as Y0 if you play before this player)
}
// Write an action using println!("message...");
// To debug: eprintln!("Debug message...");
println!("LEFT"); // A single line with UP, DOWN, LEFT or RIGHT
}
}