diff --git a/build.rs b/build.rs index f51c4c59..aedee8c8 100644 --- a/build.rs +++ b/build.rs @@ -87,8 +87,12 @@ fn parse_bm_net() { println!("cargo:rerun-if-changed=./nnue.bin"); } +type Layers = Vec; +type Weights = Vec>; +type Psqt = Vec; + #[cfg(feature = "nnue")] -pub fn from_bytes_bm(bytes: Vec) -> (Vec, Vec>, Vec>, Vec) { +pub fn from_bytes_bm(bytes: Vec) -> (Layers, Weights, Weights, Psqt) { let mut layers = vec![]; for layer_size in bytes.chunks(4).take(3) { let layer_size: u32 = unsafe { diff --git a/src/bm/bm_eval/evaluator.rs b/src/bm/bm_eval/evaluator.rs index c913f6a2..37ca65b4 100644 --- a/src/bm/bm_eval/evaluator.rs +++ b/src/bm/bm_eval/evaluator.rs @@ -279,7 +279,7 @@ impl StdEvaluator { }; 'outer: for i in 1..16 { gains[i] = Self::piece_pts(board.piece_on(make_move.from).unwrap()) - gains[i - 1]; - if let Err(_) = board.try_play_unchecked(make_move) { + if board.try_play_unchecked(make_move).is_err() { break; } let color = board.side_to_move(); @@ -383,7 +383,7 @@ impl StdEvaluator { let scale = Self::eval_scale(board); let nnue_out = self.nnue.feed_forward(board, 0); let scaled = (nnue_out as f32 * scale) as i16; - return Evaluation::new(scaled * turn + NNUE_TEMPO); + Evaluation::new(scaled * turn + NNUE_TEMPO) } #[cfg(not(feature = "nnue"))] { diff --git a/src/bm/bm_runner/ab_runner.rs b/src/bm/bm_runner/ab_runner.rs index a925a4cb..8760fa4f 100644 --- a/src/bm/bm_runner/ab_runner.rs +++ b/src/bm/bm_runner/ab_runner.rs @@ -409,7 +409,7 @@ impl AbRunner { depth, nodes, local_context.eval, - best_move.unwrap_or(make_move.unwrap()), + best_move.unwrap_or_else(|| make_move.unwrap()), search_start.elapsed(), ); if (score > alpha && score < beta) || score.is_mate() { diff --git a/src/bm/bm_search/move_gen.rs b/src/bm/bm_search/move_gen.rs index 1747ea87..37aa5ab0 100644 --- a/src/bm/bm_search/move_gen.rs +++ b/src/bm/bm_search/move_gen.rs @@ -253,10 +253,10 @@ impl Iterator for QuiescenceSearchMoveGen { }); self.gen_type = QSearchGenType::Captures; } - return if let Some((make_move, _)) = self.queue.pop() { + if let Some((make_move, _)) = self.queue.pop() { Some(make_move) } else { None - }; + } } } diff --git a/src/bm/uci.rs b/src/bm/uci.rs index 1dc79265..38b57071 100644 --- a/src/bm/uci.rs +++ b/src/bm/uci.rs @@ -416,7 +416,7 @@ impl UciCommand { break; } else if token != "fen" { if token == "moves" { - if let Ok(board) = Board::from_fen(&board.trim(), chess960) { + if let Ok(board) = Board::from_fen(board.trim(), chess960) { chess_board = Some(board); board_end = index; break; @@ -427,7 +427,7 @@ impl UciCommand { } } if chess_board.is_none() { - chess_board = Some(Board::from_fen(&board.trim(), chess960).unwrap()); + chess_board = Some(Board::from_fen(board.trim(), chess960).unwrap()); } let mut moves = vec![]; if board_end < split.len() && split[board_end] == "moves" {