fix computation time calculation
This commit is contained in:
parent
5cb9c3d202
commit
da8edf92d6
@ -121,25 +121,14 @@ pub fn get_move(game: &Game, turn: i32, board: &Board, you: &Battlesnake) -> Opt
|
||||
}
|
||||
|
||||
// do some latency compensation
|
||||
let deadline = start
|
||||
+ game_info.calculation_time.lock().map_or_else(
|
||||
|_| Duration::from_millis(u64::from(game.timeout) / 2),
|
||||
|mut guard| {
|
||||
let new_duration = *guard
|
||||
+ Duration::from_millis(
|
||||
u64::from(game.timeout) * 7 / 8
|
||||
- you
|
||||
.latency
|
||||
.parse()
|
||||
.unwrap_or(u64::from(game.timeout) * 7 / 8),
|
||||
);
|
||||
*guard = new_duration.clamp(
|
||||
Duration::from_millis(1),
|
||||
Duration::from_millis(u64::from(game.timeout) * 7 / 8),
|
||||
);
|
||||
*guard
|
||||
},
|
||||
);
|
||||
let latency = you.latency.parse().unwrap_or_else(|e| {
|
||||
error!("Unable to parse latency: {e}");
|
||||
game.timeout
|
||||
}) + 100;
|
||||
let target_latency = game.timeout * 3 / 4;
|
||||
let computation_time = target_latency - latency;
|
||||
let deadline =
|
||||
start + Duration::from_millis(u64::from(computation_time.clamp(1, game.timeout)));
|
||||
|
||||
let mut tree = Node::default();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user