pub fn try_declare_winning(&self, c: Color) -> bool {
        if c != self.side_to_move {
            return false;
        }

        let king_pos = self.find_king(c);
        if king_pos.is_none() {
            return false;
        }

        let king_pos = king_pos.unwrap();
        if king_pos.relative_rank(c) >= 3 {
            return false;
        }

        let (mut point, count) =
            PieceType::iter()
                .filter(|&pt| pt != PieceType::King)
                .fold((0, 0), |accum, pt| {
                    let unit = match pt {
                        PieceType::Rook
                        | PieceType::Bishop
                        | PieceType::ProRook
                        | PieceType::ProBishop => 5,
                        _ => 1,
                    };

                    let bb = &(&self.type_bb[pt.index()] & &self.color_bb[c.index()])
                        & &BBFactory::promote_zone(c);
                    let count = bb.count() as u8;
                    let point = count * unit;

                    (accum.0 + point, accum.1 + count)
                });

        if count < 10 {
            return false;
        }

        point += PieceType::iter()
            .filter(|pt| pt.is_hand_piece())
            .fold(0, |acc, pt| {
                let num = self.hand.get(Piece {
                    piece_type: pt,
                    color: c,
                });
                let pp = match pt {
                    PieceType::Rook | PieceType::Bishop => 5,
                    _ => 1,
                };

                acc + num * pp
            });

        let lowerbound = match c {
            Color::Black => 28,
            Color::White => 27,
        };
        if point < lowerbound {
            return false;
        }

        if self.in_check(c) {
            return false;
        }

        true
    }
/// Checks if a player with the given color can declare winning.
///
/// See the section 25 in http://www.computer-shogi.org/wcsc26/rule.pdf for more detail.
Checks if a player with the given color can declare winning.
Checks if a player with the given color can declare winning .
pub fn try_declare_winning(&self, c: Color) -> bool {
        if c != self.side_to_move {
            return false;
        }
        let king_pos = self.find_king(c);
        if king_pos.is_none() {
            return false;
        }
        let king_pos = king_pos.unwrap();
        if king_pos.relative_rank(c) >= 3 {
            return false;
        }
        let (mut point, count) =
            PieceType::iter()
                .filter(|&pt| pt != PieceType::King)
                .fold((0, 0), |accum, pt| {
                    let unit = match pt {
                        PieceType::Rook
                        | PieceType::Bishop
                        | PieceType::ProRook
                        | PieceType::ProBishop => 5,
                        _ => 1,
                    };
                    let bb = &(&self.type_bb[pt.index()] & &self.color_bb[c.index()])
                        & &BBFactory::promote_zone(c);
                    let count = bb.count() as u8;
                    let point = count * unit;
                    (accum.0 + point, accum.1 + count)
                });
        if count < 10 {
            return false;
        }
        point += PieceType::iter()
            .filter(|pt| pt.is_hand_piece())
            .fold(0, |acc, pt| {
                let num = self.hand.get(Piece {
                    piece_type: pt,
                    color: c,
                });
                let pp = match pt {
                    PieceType::Rook | PieceType::Bishop => 5,
                    _ => 1,
                };
                acc + num * pp
            });
        let lowerbound = match c {
            Color::Black => 28,
            Color::White => 27,
        };
        if point < lowerbound {
            return false;
        }
        if self.in_check(c) {
            return false;
        }
        true
    }
pub fn try_declare_winning ( & self , c : Color ) -> bool { if c != self . side_to_move { return false ; } let king_pos = self . find_king ( c ) ; if king_pos . is_none ( ) { return false ; } let king_pos = king_pos . unwrap ( ) ; if king_pos . relative_rank ( c ) >= 3 { return false ; } let ( mut point , count ) = PieceType :: iter ( ) . filter ( | & pt | pt != PieceType :: King ) . fold ( ( 0 , 0 ) , | accum , pt | { let unit = match pt { PieceType :: Rook | PieceType :: Bishop | PieceType :: ProRook | PieceType :: ProBishop => 5 , _ => 1 , } ; let bb = & ( & self . type_bb [ pt . index ( ) ] & & self . color_bb [ c . index ( ) ] ) & & BBFactory :: promote_zone ( c ) ; let count = bb . count ( ) as u8 ; let point = count * unit ; ( accum . 0 + point , accum . 1 + count ) } ) ; if count < 10 { return false ; } point += PieceType :: iter ( ) . filter ( | pt | pt . is_hand_piece ( ) ) . fold ( 0 , | acc , pt | { let num = self . hand . get ( Piece { piece_type : pt , color : c , } ) ; let pp = match pt { PieceType :: Rook | PieceType :: Bishop => 5 , _ => 1 , } ; acc + num * pp } ) ; let lowerbound = match c { Color :: Black => 28 , Color :: White => 27 , } ; if point < lowerbound { return false ; } if self . in_check ( c ) { return false ; } true }
Checks if a player with the given color can declare winning.
Checks if a player with the given color can declare winning .
&self
c
Color