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 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,
})
},
}
}