fix: clippy warnings — too_many_arguments + Default impls + needless_borrows

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 15:52:18 +08:00
parent 8144b16b9d
commit 5122c3c06a
4 changed files with 19 additions and 5 deletions
+8 -2
View File
@@ -7,12 +7,18 @@ pub struct KillerTable {
moves: [[Option<Position>; SLOTS_PER_DEPTH]; MAX_DEPTH],
}
impl KillerTable {
pub fn new() -> Self {
impl Default for KillerTable {
fn default() -> Self {
Self {
moves: [[None; SLOTS_PER_DEPTH]; MAX_DEPTH],
}
}
}
impl KillerTable {
pub fn new() -> Self {
Self::default()
}
/// 记录产生剪枝的走法,同一位置不会重复存储
pub fn record(&mut self, depth: usize, pos: Position) {
+8 -2
View File
@@ -6,14 +6,20 @@ pub struct OpeningBook {
positions: HashMap<ZobristHash, Vec<Position>>,
}
impl OpeningBook {
pub fn new() -> Self {
impl Default for OpeningBook {
fn default() -> Self {
let mut book = Self {
positions: HashMap::new(),
};
book.load();
book
}
}
impl OpeningBook {
pub fn new() -> Self {
Self::default()
}
fn load(&mut self) {
let openings: Vec<Vec<(usize, usize)>> = vec![
+2
View File
@@ -79,6 +79,7 @@ impl AiEngine for AlphaBetaAi {
}
impl AlphaBetaAi {
#[allow(clippy::too_many_arguments)]
fn search_depth(
&self,
board: &Board,
@@ -162,6 +163,7 @@ impl AlphaBetaAi {
(best_pos, completed)
}
#[allow(clippy::too_many_arguments)]
fn negamax(
&self,
board: &Board,
+1 -1
View File
@@ -169,7 +169,7 @@ pub fn init_zobrist_table(_board_size: usize) -> &'static Vec<Vec<[ZobristHash;
for x in 0..size {
let mut row = Vec::with_capacity(size);
for _y in 0..size {
row.push([rng.hash_one(&(x, _y, 0u8)), rng.hash_one(&(x, _y, 1u8))]);
row.push([rng.hash_one((x, _y, 0u8)), rng.hash_one((x, _y, 1u8))]);
}
table.push(row);
}