Compare commits

..

2 Commits

Author SHA1 Message Date
e00eefb990 warn instead of error on unknown latency 2024-10-06 21:25:17 +02:00
f6845b5126 fast response with no movement option 2024-10-06 21:05:45 +02:00

View File

@ -17,7 +17,7 @@ use std::{
time::{Duration, Instant},
};
use log::{error, info};
use log::{error, info, warn};
use ordered_float::OrderedFloat;
use rand::thread_rng;
use serde_json::{json, Value};
@ -126,7 +126,7 @@ pub fn get_move(
game.ruleset.name == "constrictor",
);
let possible_actions = board.possible_actions().get(&game_info.my_token).cloned()?;
if possible_actions.len() == 1 {
if possible_actions.len() <= 1 {
info!("Only one movement option exists in turn {turn}. Skipping Tree evaluation");
return possible_actions.first().map(|direction| Action {
r#move: *direction,
@ -141,7 +141,7 @@ pub fn get_move(
|mut guard| {
let target_latency = game.timeout / 2;
let latency = you.latency.parse().unwrap_or_else(|e| {
error!("Unable to parse latency: {e}");
warn!("Unable to parse latency: {e}");
target_latency
});
let last_computation_time = u32::try_from(guard.as_millis()).unwrap_or(0);