fix clippy lints

This commit is contained in:
Max Känner 2024-10-03 01:45:46 +02:00
parent 61e5f26bd7
commit accfe7acbb
2 changed files with 4 additions and 12 deletions

View File

@ -137,6 +137,7 @@ pub fn get_move(game: &Game, turn: i32, board: &Board, you: &Battlesnake) -> Opt
info!("actions: {actions:?}"); info!("actions: {actions:?}");
#[allow(clippy::cast_precision_loss)]
let chosen = actions let chosen = actions
.iter() .iter()
.max_by_key(|(_, stat)| OrderedFloat(stat.won as f64 / stat.played as f64)) .max_by_key(|(_, stat)| OrderedFloat(stat.won as f64 / stat.played as f64))
@ -195,7 +196,9 @@ impl Node {
if statistics.played == 0 { if statistics.played == 0 {
return OrderedFloat(f64::INFINITY); return OrderedFloat(f64::INFINITY);
} }
#[allow(clippy::cast_precision_loss)]
let exploitation = statistics.won as f64 / statistics.played as f64; let exploitation = statistics.won as f64 / statistics.played as f64;
#[allow(clippy::cast_precision_loss)]
let exploration = f64::consts::SQRT_2 let exploration = f64::consts::SQRT_2
* f64::sqrt( * f64::sqrt(
f64::ln(self.statistic.played as f64) f64::ln(self.statistic.played as f64)

View File

@ -1,10 +1,7 @@
use std::collections::{BTreeMap, BTreeSet, VecDeque}; use std::collections::{BTreeMap, BTreeSet, VecDeque};
use iter_tools::Itertools; use iter_tools::Itertools;
use rand::{ use rand::{seq::IteratorRandom, Rng};
seq::{IteratorRandom, SliceRandom},
Rng,
};
use crate::{Coord, Direction}; use crate::{Coord, Direction};
@ -84,14 +81,6 @@ impl Board {
} }
} }
pub const fn turn(&self) -> i32 {
self.turn
}
pub fn is_alive(&self, token: SnakeToken) -> bool {
self.snakes.contains_key(&token)
}
pub fn alive_snakes(&self) -> usize { pub fn alive_snakes(&self) -> usize {
self.snakes.len() self.snakes.len()
} }