forked from cadey/pneuma
be a bit more verbose
This commit is contained in:
parent
56e3971f87
commit
55ff381b08
33
src/main.rs
33
src/main.rs
|
@ -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,
|
|
||||||
end: &target,
|
|
||||||
}
|
|
||||||
.direction()
|
|
||||||
.to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Some(next) => Json(battlesnake::MoveResponse {
|
|
||||||
move_field: battlesnake::Line {
|
|
||||||
start: &head,
|
start: &head,
|
||||||
end: &next,
|
end: &target,
|
||||||
}
|
}
|
||||||
.direction()
|
.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,
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue