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],
|
moves: [[Option<Position>; SLOTS_PER_DEPTH]; MAX_DEPTH],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KillerTable {
|
impl Default for KillerTable {
|
||||||
pub fn new() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
moves: [[None; SLOTS_PER_DEPTH]; MAX_DEPTH],
|
moves: [[None; SLOTS_PER_DEPTH]; MAX_DEPTH],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl KillerTable {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
|
||||||
/// 记录产生剪枝的走法,同一位置不会重复存储
|
/// 记录产生剪枝的走法,同一位置不会重复存储
|
||||||
pub fn record(&mut self, depth: usize, pos: Position) {
|
pub fn record(&mut self, depth: usize, pos: Position) {
|
||||||
|
|||||||
@@ -6,14 +6,20 @@ pub struct OpeningBook {
|
|||||||
positions: HashMap<ZobristHash, Vec<Position>>,
|
positions: HashMap<ZobristHash, Vec<Position>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OpeningBook {
|
impl Default for OpeningBook {
|
||||||
pub fn new() -> Self {
|
fn default() -> Self {
|
||||||
let mut book = Self {
|
let mut book = Self {
|
||||||
positions: HashMap::new(),
|
positions: HashMap::new(),
|
||||||
};
|
};
|
||||||
book.load();
|
book.load();
|
||||||
book
|
book
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OpeningBook {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
|
||||||
fn load(&mut self) {
|
fn load(&mut self) {
|
||||||
let openings: Vec<Vec<(usize, usize)>> = vec![
|
let openings: Vec<Vec<(usize, usize)>> = vec![
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ impl AiEngine for AlphaBetaAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AlphaBetaAi {
|
impl AlphaBetaAi {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn search_depth(
|
fn search_depth(
|
||||||
&self,
|
&self,
|
||||||
board: &Board,
|
board: &Board,
|
||||||
@@ -162,6 +163,7 @@ impl AlphaBetaAi {
|
|||||||
(best_pos, completed)
|
(best_pos, completed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn negamax(
|
fn negamax(
|
||||||
&self,
|
&self,
|
||||||
board: &Board,
|
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 {
|
for x in 0..size {
|
||||||
let mut row = Vec::with_capacity(size);
|
let mut row = Vec::with_capacity(size);
|
||||||
for _y in 0..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);
|
table.push(row);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user