diff --git a/src/main.rs b/src/main.rs index 0fbd3c9..218d68c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -95,6 +95,7 @@ fn make_move( let mut cache = cache_state.lock().expect("wanted cache to be unlockable"); let gs = cache.get_mut(&msg.game.id).unwrap(); if gs.path.is_none() { + println!("recalculating path"); gs.target = *find_target(&msg); gs.path = find_path(&msg, &head, &gs.target); } @@ -103,23 +104,27 @@ fn make_move( None => { gs.path = None; let target = msg.board.safe_neighbors(&head)[0].0; - Json(battlesnake::MoveResponse { - move_field: battlesnake::Line{ - start: &head, - end: &target, - } - .direction() - .to_string(), - }) - } - Some(next) => Json(battlesnake::MoveResponse { - move_field: battlesnake::Line { + let next_move = battlesnake::Line{ start: &head, - end: &next, + end: &target, } .direction() - .to_string(), - }), + .to_string(); + println!("moving to {}, target: {:?}", next_move, target); + Json(battlesnake::MoveResponse { + move_field: next_move, + }) + } + Some(next) => { + let next_move = battlesnake::Line { + start: &head, + end: &next, + }.direction().to_string(); + println!("moving to {} {:?}, target: {:?}", next_move, next, gs.target); + Json(battlesnake::MoveResponse { + move_field: next_move, + }) + }, } }