diff --git a/examples/connect5.rs b/examples/connect5.rs
index a569689fad..feb84fbef5 100644
--- a/examples/connect5.rs
+++ b/examples/connect5.rs
@@ -74,6 +74,7 @@ const SCORE_NONE: i32 = -EVAL_INF - 1;
/// DIRECTION 2: top left to bottom right\
/// DIRECTION 3: top right to bottom left
#[rustfmt::skip]
+#[allow(clippy::identity_op)]
const DIRECTION: [[i32; 5]; 4] = [ [1, 2, 3, 4, 5],
[1 * (FILE_SIZE + 1), 2 * (FILE_SIZE + 1), 3 * (FILE_SIZE + 1), 4 * (FILE_SIZE + 1), 5 * (FILE_SIZE + 1)],
[1 * (FILE_SIZE + 2), 2 * (FILE_SIZE + 2), 3 * (FILE_SIZE + 2), 4 * (FILE_SIZE + 2), 5 * (FILE_SIZE + 2)],
@@ -311,7 +312,7 @@ impl Pos {
match self.p_turn {
Color::Black => {
- self.state[mv as usize] = Color::Black;
+ self.state[mv] = Color::Black;
// update black move and remove empty move in bitboard
self.bitboard[black][0][MAPMOVEIDX[0][mv] as usize] |= MAPMOVEVALUE[0][mv];
self.bitboard[empty][0][MAPMOVEIDX[0][mv] as usize] ^= MAPMOVEVALUE[0][mv];
@@ -323,7 +324,7 @@ impl Pos {
self.bitboard[empty][1][MAPMOVEIDX[3][mv] as usize] ^= MAPMOVEVALUE[3][mv];
}
Color::White => {
- self.state[mv as usize] = Color::White;
+ self.state[mv] = Color::White;
// update white move and remove empty move in bitboard
self.bitboard[white][0][MAPMOVEIDX[0][mv] as usize] |= MAPMOVEVALUE[0][mv];
self.bitboard[empty][0][MAPMOVEIDX[0][mv] as usize] ^= MAPMOVEVALUE[0][mv];
@@ -345,11 +346,7 @@ impl Pos {
}
pub fn can_play(&self, from: Square) -> bool {
- if self.state[from as usize] == Color::Empty {
- true
- } else {
- false
- }
+ self.state[from as usize] == Color::Empty
}
}
@@ -421,14 +418,14 @@ fn pos_is_draw(pos: &Pos) -> bool {
break;
}
- if found == false {
+ if !found {
break;
}
}
}
- let mut out: bool = false;
- if found == true && !pos_is_winner(pos) {
+ let mut out = false;
+ if found && !pos_is_winner(pos) {
out = true;
}
@@ -447,19 +444,11 @@ unsafe fn pos_is_draw_avx512(pos: &Pos) -> bool {
// if all empty is 0, all board is filled.
let temp_mask = _mm512_mask_cmpneq_epi32_mask(0b11111111_11111111, answer, board0org);
- if _popcnt32(temp_mask as i32) == 0 && !pos_is_winner_avx512(pos) {
- return true;
- } else {
- return false;
- }
+ _popcnt32(temp_mask as i32) == 0 && !pos_is_winner_avx512(pos)
}
fn pos_is_end(pos: &Pos) -> bool {
- if pos_is_winner(pos) || pos_is_draw(pos) {
- true
- } else {
- false
- }
+ pos_is_winner(pos) || pos_is_draw(pos)
}
fn pos_disp(pos: &Pos) {
@@ -475,7 +464,7 @@ fn pos_disp(pos: &Pos) {
}
}
- println!("");
+ println!();
}
match pos.turn() {
@@ -581,7 +570,7 @@ fn search(pos: &Pos, alpha: i32, beta: i32, depth: i32, _ply: i32) -> i32 {
}
}
- assert!(bm != MOVE_NONE);
+ assert_ne!(bm, MOVE_NONE);
assert!(bs >= -EVAL_INF && bs <= EVAL_INF);
if _ply == 0 {
@@ -605,10 +594,8 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
return -4096;
}
}
- } else {
- if check_patternlive4(pos, def) {
- return -4096;
- }
+ } else if check_patternlive4(pos, def) {
+ return -4096;
}
}
@@ -628,10 +615,8 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
return 2560;
}
}
- } else {
- if check_patternlive4(pos, atk) {
- return 2560;
- }
+ } else if check_patternlive4(pos, atk) {
+ return 2560;
}
}
@@ -651,10 +636,8 @@ fn eval(pos: &Pos, _ply: i32) -> i32 {
return 2560;
}
}
- } else {
- if check_patterndead4(pos, atk) > 0 {
- return 2560;
- }
+ } else if check_patterndead4(pos, atk) > 0 {
+ return 2560;
}
}
@@ -773,11 +756,7 @@ fn check_pattern5(pos: &Pos, sd: Side) -> bool {
}
}
- if n > 0 {
- true
- } else {
- false
- }
+ n > 0
}
/// Check -OOOO-
@@ -809,11 +788,7 @@ fn check_patternlive4(pos: &Pos, sd: Side) -> bool {
}
}
- if n > 0 {
- true
- } else {
- false
- }
+ n > 0
}
/// Check OOOO-, OOO-O, OO-OO, O-OOO, -OOOO
@@ -961,11 +936,7 @@ unsafe fn pos_is_winner_avx512(pos: &Pos) -> bool {
}
}
- if count_match > 0 {
- return true;
- } else {
- return false;
- }
+ count_match > 0
}
#[target_feature(enable = "avx512f,avx512bw")]
@@ -1027,11 +998,7 @@ unsafe fn check_patternlive4_avx512(pos: &Pos, sd: Side) -> bool {
}
}
- if count_match > 0 {
- return true;
- } else {
- return false;
- }
+ count_match > 0
}
#[target_feature(enable = "avx512f,avx512bw")]