diff --git a/core/src/ai/killer.rs b/core/src/ai/killer.rs index d8afe6e..207bf41 100644 --- a/core/src/ai/killer.rs +++ b/core/src/ai/killer.rs @@ -7,12 +7,18 @@ pub struct KillerTable { moves: [[Option; 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) { diff --git a/core/src/ai/opening.rs b/core/src/ai/opening.rs index 3a9a5e6..1a4177a 100644 --- a/core/src/ai/opening.rs +++ b/core/src/ai/opening.rs @@ -6,14 +6,20 @@ pub struct OpeningBook { positions: HashMap>, } -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![ diff --git a/core/src/ai/search.rs b/core/src/ai/search.rs index f229486..462747e 100644 --- a/core/src/ai/search.rs +++ b/core/src/ai/search.rs @@ -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, diff --git a/core/src/types.rs b/core/src/types.rs index 5c65f9b..2901c87 100644 --- a/core/src/types.rs +++ b/core/src/types.rs @@ -169,7 +169,7 @@ pub fn init_zobrist_table(_board_size: usize) -> &'static Vec