-
Notifications
You must be signed in to change notification settings - Fork 0
/
agent.rs
37 lines (27 loc) · 864 Bytes
/
agent.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::io;
use rand::Rng;
fn main() {
let mut buffer = String::new();
io::stdin().read_line(&mut buffer).unwrap();
let mut splits = buffer.split(", ");
let mut board = vec![0; 225];
let mut stone = 0;
let mut time = 0.0;
for i in 0..225 {
board[i] = splits.next().unwrap().parse::<i32>().unwrap();
}
stone = splits.next().unwrap().parse::<i32>().unwrap();
time = splits.next().unwrap().parse::<f64>().unwrap();
// eprintln!("{:?} {} {}", board, stone, time);
let (x, y) = run(board, stone, time);
println!("{} {}", y, x);
}
fn run(board: Vec<i32>, stone: i32, time: f64) -> (usize, usize) {
let [mut x, mut y] = [0, 0];
let mut rng = rand::thread_rng();
while board[y * 15 + x] != 0 {
x = rng.gen_range(0..15);
y = rng.gen_range(0..15);
}
return (x, y);
}