be a bit more verbose

This commit is contained in:
Cadey Ratio 2019-12-18 08:47:51 -05:00
parent 56e3971f87
commit 55ff381b08
1 changed files with 19 additions and 14 deletions

View File

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