fn eval(pos: &Pos, _ply: i32) -> i32 {
    let atk: Side = pos.turn();
    let def: Side = side_opp(atk);

    // check if opp has live4 which will win playing next move
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                if check_patternlive4_avx512(&pos, def) {
                    return -4096;
                }
            }
        } else {
            if check_patternlive4(&pos, def) {
                return -4096;
            }
        }
    }

    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        if check_patternlive4(&pos, def) {
            return -4096;
        }
    }

    // check if self has live4 which will win playing next move
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                if check_patternlive4_avx512(&pos, atk) {
                    return 2560;
                }
            }
        } else {
            if check_patternlive4(&pos, atk) {
                return 2560;
            }
        }
    }

    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        if check_patternlive4(&pos, atk) {
            return 2560;
        }
    }

    // check if self has dead4 which will win playing next move
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                if check_patterndead4_avx512(&pos, atk) > 0 {
                    return 2560;
                }
            }
        } else {
            if check_patterndead4(&pos, atk) > 0 {
                return 2560;
            }
        }
    }

    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        if check_patterndead4(&pos, atk) > 0 {
            return 2560;
        }
    }

    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                let n_c4: i32 = check_patterndead4_avx512(&pos, def);
                let n_c3: i32 = check_patternlive3_avx512(&pos, def);

                // check if opp has 2 dead4 which will win playing next move
                if n_c4 > 1 {
                    return -2048;
                }

                // check if opp has a dead 4 and live 3 which will win playing the next two move
                if n_c4 == 1 && n_c3 > 0 {
                    return -2048;
                }

                if check_patternlive3_avx512(&pos, atk) > 1 {
                    return 2560;
                }

                // check if opp has 2 live3 which will win playing the next two move
                if n_c3 > 1 {
                    return -2048;
                }
            }
        } else {
            let n_c4: i32 = check_patterndead4(&pos, def);
            let n_c3: i32 = check_patternlive3(&pos, def);

            // check if opp has 2 dead4 which will win playing next move
            if n_c4 > 1 {
                return -2048;
            }

            // check if opp has a dead 4 and live 3 which will win playing the next two move
            if n_c4 == 1 && n_c3 > 0 {
                return -2048;
            }

            // check if self has 2 live3 which will win playing the next two move
            if check_patternlive3(&pos, atk) > 1 {
                return 2560;
            }

            // check if opp has 2 live3 which will win playing the next two move
            if n_c3 > 1 {
                return -2048;
            }
        }
    }

    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        let n_c4: i32 = check_patterndead4(&pos, def);
        let n_c3: i32 = check_patternlive3(&pos, def);

        // check if opp has 2 dead4 which will win playing next move
        if n_c4 > 1 {
            return -2048;
        }

        // check if opp has a dead 4 and live 3 which will win playing the next two move
        if n_c4 == 1 && n_c3 > 0 {
            return -2048;
        }

        // check if self has 2 live3 which will win playing the next two move
        if check_patternlive3(&pos, atk) > 1 {
            return 2560;
        }

        // check if opp has 2 live3 which will win playing the next two move
        if n_c3 > 1 {
            return -2048;
        }
    }

    0
}
/// Evaluation function: give different scores to different patterns after a fixed depth.
Evaluation function: give different scores to different patterns after a fixed depth.
Evaluation function : give different scores to different patterns after a fixed depth .
fn eval(pos: &Pos, _ply: i32) -> i32 {
    let atk: Side = pos.turn();
    let def: Side = side_opp(atk);
    // check if opp has live4 which will win playing next move
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                if check_patternlive4_avx512(&pos, def) {
                    return -4096;
                }
            }
        } else {
            if check_patternlive4(&pos, def) {
                return -4096;
            }
        }
    }
    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        if check_patternlive4(&pos, def) {
            return -4096;
        }
    }
    // check if self has live4 which will win playing next move
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                if check_patternlive4_avx512(&pos, atk) {
                    return 2560;
                }
            }
        } else {
            if check_patternlive4(&pos, atk) {
                return 2560;
            }
        }
    }
    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        if check_patternlive4(&pos, atk) {
            return 2560;
        }
    }
    // check if self has dead4 which will win playing next move
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                if check_patterndead4_avx512(&pos, atk) > 0 {
                    return 2560;
                }
            }
        } else {
            if check_patterndead4(&pos, atk) > 0 {
                return 2560;
            }
        }
    }
    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        if check_patterndead4(&pos, atk) > 0 {
            return 2560;
        }
    }
    #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
    {
        if is_x86_feature_detected!("avx512bw") {
            unsafe {
                let n_c4: i32 = check_patterndead4_avx512(&pos, def);
                let n_c3: i32 = check_patternlive3_avx512(&pos, def);
                // check if opp has 2 dead4 which will win playing next move
                if n_c4 > 1 {
                    return -2048;
                }
                // check if opp has a dead 4 and live 3 which will win playing the next two move
                if n_c4 == 1 && n_c3 > 0 {
                    return -2048;
                }
                if check_patternlive3_avx512(&pos, atk) > 1 {
                    return 2560;
                }
                // check if opp has 2 live3 which will win playing the next two move
                if n_c3 > 1 {
                    return -2048;
                }
            }
        } else {
            let n_c4: i32 = check_patterndead4(&pos, def);
            let n_c3: i32 = check_patternlive3(&pos, def);
            // check if opp has 2 dead4 which will win playing next move
            if n_c4 > 1 {
                return -2048;
            }
            // check if opp has a dead 4 and live 3 which will win playing the next two move
            if n_c4 == 1 && n_c3 > 0 {
                return -2048;
            }
            // check if self has 2 live3 which will win playing the next two move
            if check_patternlive3(&pos, atk) > 1 {
                return 2560;
            }
            // check if opp has 2 live3 which will win playing the next two move
            if n_c3 > 1 {
                return -2048;
            }
        }
    }
    #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
    {
        let n_c4: i32 = check_patterndead4(&pos, def);
        let n_c3: i32 = check_patternlive3(&pos, def);
        // check if opp has 2 dead4 which will win playing next move
        if n_c4 > 1 {
            return -2048;
        }
        // check if opp has a dead 4 and live 3 which will win playing the next two move
        if n_c4 == 1 && n_c3 > 0 {
            return -2048;
        }
        // check if self has 2 live3 which will win playing the next two move
        if check_patternlive3(&pos, atk) > 1 {
            return 2560;
        }
        // check if opp has 2 live3 which will win playing the next two move
        if n_c3 > 1 {
            return -2048;
        }
    }
    0
}
fn eval ( pos : & Pos , _ply : i32 ) -> i32 { let atk : Side = pos . turn ( ) ; let def : Side = side_opp ( atk ) ; // check if opp has live4 which will win playing next move # [ cfg ( any ( target_arch " " target_arch " " ) ) ] { if is_x86_feature_detected ! ( " " ) { unsafe { if check_patternlive4_avx512 ( & pos , def ) { return - 4096 ; } } } else { if check_patternlive4 ( & pos , def ) { return - 4096 ; } } } # [ cfg ( not ( any ( target_arch " " target_arch " " ) ) ) ] { if check_patternlive4 ( & pos , def ) { return - 4096 ; } } // check if self has live4 which will win playing next move # [ cfg ( any ( target_arch " " target_arch " " ) ) ] { if is_x86_feature_detected ! ( " " ) { unsafe { if check_patternlive4_avx512 ( & pos , atk ) { return 2560 ; } } } else { if check_patternlive4 ( & pos , atk ) { return 2560 ; } } } # [ cfg ( not ( any ( target_arch " " target_arch " " ) ) ) ] { if check_patternlive4 ( & pos , atk ) { return 2560 ; } } // check if self has dead4 which will win playing next move # [ cfg ( any ( target_arch " " target_arch " " ) ) ] { if is_x86_feature_detected ! ( " " ) { unsafe { if check_patterndead4_avx512 ( & pos , atk ) > 0 { return 2560 ; } } } else { if check_patterndead4 ( & pos , atk ) > 0 { return 2560 ; } } } # [ cfg ( not ( any ( target_arch " " target_arch " " ) ) ) ] { if check_patterndead4 ( & pos , atk ) > 0 { return 2560 ; } } # [ cfg ( any ( target_arch " " target_arch " " ) ) ] { if is_x86_feature_detected ! ( " " ) { unsafe { let n_c4 : i32 = check_patterndead4_avx512 ( & pos , def ) ; let n_c3 : i32 = check_patternlive3_avx512 ( & pos , def ) ; // check if opp has 2 dead4 which will win playing next move if n_c4 > 1 { return - 2048 ; } // check if opp has a dead 4 and live 3 which will win playing the next two move if n_c4 == 1 && n_c3 > 0 { return - 2048 ; } if check_patternlive3_avx512 ( & pos , atk ) > 1 { return 2560 ; } // check if opp has 2 live3 which will win playing the next two move if n_c3 > 1 { return - 2048 ; } } } else { let n_c4 : i32 = check_patterndead4 ( & pos , def ) ; let n_c3 : i32 = check_patternlive3 ( & pos , def ) ; // check if opp has 2 dead4 which will win playing next move if n_c4 > 1 { return - 2048 ; } // check if opp has a dead 4 and live 3 which will win playing the next two move if n_c4 == 1 && n_c3 > 0 { return - 2048 ; } // check if self has 2 live3 which will win playing the next two move if check_patternlive3 ( & pos , atk ) > 1 { return 2560 ; } // check if opp has 2 live3 which will win playing the next two move if n_c3 > 1 { return - 2048 ; } } } # [ cfg ( not ( any ( target_arch " " target_arch " " ) ) ) ] { let n_c4 : i32 = check_patterndead4 ( & pos , def ) ; let n_c3 : i32 = check_patternlive3 ( & pos , def ) ; // check if opp has 2 dead4 which will win playing next move if n_c4 > 1 { return - 2048 ; } // check if opp has a dead 4 and live 3 which will win playing the next two move if n_c4 == 1 && n_c3 > 0 { return - 2048 ; } // check if self has 2 live3 which will win playing the next two move if check_patternlive3 ( & pos , atk ) > 1 { return 2560 ; } // check if opp has 2 live3 which will win playing the next two move if n_c3 > 1 { return - 2048 ; } } 0 }
Evaluation function: give different scores to different patterns after a fixed depth.
Evaluation function : give different scores to different patterns after a fixed depth .
pos
&Pos
_ply
i32
pos
&Pos
_ply
i32