Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jnlt3 committed Dec 26, 2021
1 parent 4a7fda4 commit 4d22b8f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ fn parse_bm_net() {
println!("cargo:rerun-if-changed=./nnue.bin");
}

type Layers = Vec<usize>;
type Weights = Vec<Vec<i8>>;
type Psqt = Vec<i32>;

#[cfg(feature = "nnue")]
pub fn from_bytes_bm(bytes: Vec<u8>) -> (Vec<usize>, Vec<Vec<i8>>, Vec<Vec<i8>>, Vec<i32>) {
pub fn from_bytes_bm(bytes: Vec<u8>) -> (Layers, Weights, Weights, Psqt) {
let mut layers = vec![];
for layer_size in bytes.chunks(4).take(3) {
let layer_size: u32 = unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/bm/bm_eval/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"))]
{
Expand Down
2 changes: 1 addition & 1 deletion src/bm/bm_runner/ab_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/bm/bm_search/move_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ impl<const SEE_PRUNE: bool> Iterator for QuiescenceSearchMoveGen<SEE_PRUNE> {
});
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
};
}
}
}
4 changes: 2 additions & 2 deletions src/bm/uci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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" {
Expand Down

0 comments on commit 4d22b8f

Please sign in to comment.