From 55ff381b08ef620b3424244a7437731cc44e9fd1 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 18 Dec 2019 08:47:51 -0500 Subject: [PATCH] be a bit more verbose --- src/main.rs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) 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, + }) + }, } }