mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-28 16:35:55 +08:00
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:
@@ -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) {
|
||||
|
||||
@@ -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![
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user