diff --git a/src/chokudAI.rs b/src/chokudAI.rs index 2b3bd6a..b960cfd 100644 --- a/src/chokudAI.rs +++ b/src/chokudAI.rs @@ -26,11 +26,7 @@ pub fn run_chokudai() { // run(client, join_resp); } -pub fn run(client: Client, join_resp: Response, prep: Preprocess){ - - - let mut router = super::routing::Router::new(); - +pub fn run(client: Client, join_resp: Response, mut prep: Preprocess){ let all = join_resp.info.ability.potential; let shoot = 64; let mut heal = 10; @@ -51,8 +47,7 @@ pub fn run(client: Client, join_resp: Response, prep: Preprocess){ //COMMANDS while resp.stage != 2 { - - resp = client.command(&chokud_ai(&resp, &id, &my_role, &mut e_data, &prep, &mut router)); + resp = client.command(&chokud_ai(&resp, &id, &my_role, &mut e_data, &mut prep)); //dbg!(&resp); } } @@ -62,7 +57,7 @@ fn dist(a: &Ship, b: &Ship) -> i32{ return (a.pos.0 - b.pos.0).abs() + (a.pos.1 - b.pos.1).abs(); } -fn chokud_ai(resp: &Response, id: &i32, my_role: &i32, e_data: &mut EnemyData, prep: &Preprocess, router: &mut super::routing::Router) -> Vec { +fn chokud_ai(resp: &Response, id: &i32, my_role: &i32, e_data: &mut EnemyData, prep: &mut Preprocess) -> Vec { let mut myship = resp.state.ships[0].clone(); let mut enemyship = resp.state.ships[0].clone(); @@ -156,7 +151,7 @@ fn chokud_ai(resp: &Response, id: &i32, my_role: &i32, e_data: &mut EnemyData, p if e_data.go_near { eprintln!("Go Near!"); - let (dvx, dvy) = router.doit(&myship, &enemyship); + let (dvx, dvy) = prep.router.doit(&myship, &enemyship); addx = dvx; addy = dvy; } diff --git a/src/wata.rs b/src/wata.rs index 341cbb4..ba3de19 100644 --- a/src/wata.rs +++ b/src/wata.rs @@ -55,7 +55,8 @@ pub fn test_naive(mut x: i32, mut y: i32, mut dx: i32, mut dy: i32, gx: &Vec>, gy: Vec>, - dp: Vec>>> + dp: Vec>>>, + pub router: crate::routing::Router, } fn preprocess() -> Preprocess { @@ -157,8 +158,10 @@ fn preprocess() -> Preprocess { } } eprintln!("preprocessed: {}", count); + + let router = crate::routing::Router::new(); eprintln!("time: {:.3}", get_time() - stime); - Preprocess { gx, gy, dp } + Preprocess { gx, gy, dp, router } } fn rec(x: i32, y: i32, dx: i32, dy: i32, last_ax: i32, last_ay: i32, d: usize, prep: &Preprocess) -> (i32, usize) {