(self)
return errors
Gets a bitmask of possible problems problems with the position.
        Move making, generation and validation are only guaranteed to work on
        a completely valid board.
Gets a bitmask of possible problems problems with the position.
        Move making, generation and validation are only guaranteed to work on
        a completely valid board.
Gets a bitmask of possible problems problems with the position . Move making generation and validation are only guaranteed to work on a completely valid board .
def status(self):
        """
        Gets a bitmask of possible problems problems with the position.
        Move making, generation and validation are only guaranteed to work on
        a completely valid board.
        """
        errors = STATUS_VALID

        if not self.occupied_co[WHITE] & self.kings:
            errors |= STATUS_NO_WHITE_KING
        if not self.occupied_co[BLACK] & self.kings:
            errors |= STATUS_NO_BLACK_KING
        if sparse_pop_count(self.occupied & self.kings) > 2:
            errors |= STATUS_TOO_MANY_KINGS

        if pop_count(self.occupied_co[WHITE] & self.pawns) > 8:
            errors |= STATUS_TOO_MANY_WHITE_PAWNS
        if pop_count(self.occupied_co[BLACK] & self.pawns) > 8:
            errors |= STATUS_TOO_MANY_BLACK_PAWNS

        if self.pawns & (BB_RANK_1 | BB_RANK_8):
            errors |= STATUS_PAWNS_ON_BACKRANK

        if pop_count(self.occupied_co[WHITE]) > 16:
            errors |= STATUS_TOO_MANY_WHITE_PIECES
        if pop_count(self.occupied_co[BLACK]) > 16:
            errors |= STATUS_TOO_MANY_BLACK_PIECES

        if self.castling_rights & CASTLING_WHITE:
            if not self.king_squares[WHITE] == E1:
                errors |= STATUS_BAD_CASTLING_RIGHTS

            if self.castling_rights & CASTLING_WHITE_QUEENSIDE:
                if not BB_A1 & self.occupied_co[WHITE] & self.rooks:
                    errors |= STATUS_BAD_CASTLING_RIGHTS
            if self.castling_rights & CASTLING_WHITE_KINGSIDE:
                if not BB_H1 & self.occupied_co[WHITE] & self.rooks:
                    errors |= STATUS_BAD_CASTLING_RIGHTS

        if self.castling_rights & CASTLING_BLACK:
            if not self.king_squares[BLACK] == E8:
                errors |= STATUS_BAD_CASTLING_RIGHTS

            if self.castling_rights & CASTLING_BLACK_QUEENSIDE:
                if not BB_A8 & self.occupied_co[BLACK] & self.rooks:
                    errors |= STATUS_BAD_CASTLING_RIGHTS
            if self.castling_rights & CASTLING_BLACK_KINGSIDE:
                if not BB_H8 & self.occupied_co[BLACK] & self.rooks:
                    errors |= STATUS_BAD_CASTLING_RIGHTS

        if self.ep_square:
            if self.turn == WHITE:
                ep_rank = 5
                pawn_mask = shift_up(BB_SQUARES[self.ep_square])
            else:
                ep_rank = 2
                pawn_mask = shift_down(BB_SQUARES[self.ep_square])

            if rank_index(self.ep_square) != ep_rank:
                errors |= STATUS_INVALID_EP_SQUARE

            if not self.pawns & self.occupied_co[self.turn ^ 1] & pawn_mask:
                errors |= STATUS_INVALID_EP_SQUARE

        if not errors & (STATUS_NO_WHITE_KING | STATUS_NO_BLACK_KING | STATUS_TOO_MANY_KINGS):
            if self.was_into_check():
                errors |= STATUS_OPPOSITE_CHECK

        return errors
def status ( self ) : errors = STATUS_VALID if not self . occupied_co [ WHITE ] & self . kings : errors |= STATUS_NO_WHITE_KING if not self . occupied_co [ BLACK ] & self . kings : errors |= STATUS_NO_BLACK_KING if sparse_pop_count ( self . occupied & self . kings ) > 2 : errors |= STATUS_TOO_MANY_KINGS if pop_count ( self . occupied_co [ WHITE ] & self . pawns ) > 8 : errors |= STATUS_TOO_MANY_WHITE_PAWNS if pop_count ( self . occupied_co [ BLACK ] & self . pawns ) > 8 : errors |= STATUS_TOO_MANY_BLACK_PAWNS if self . pawns & ( BB_RANK_1 | BB_RANK_8 ) : errors |= STATUS_PAWNS_ON_BACKRANK if pop_count ( self . occupied_co [ WHITE ] ) > 16 : errors |= STATUS_TOO_MANY_WHITE_PIECES if pop_count ( self . occupied_co [ BLACK ] ) > 16 : errors |= STATUS_TOO_MANY_BLACK_PIECES if self . castling_rights & CASTLING_WHITE : if not self . king_squares [ WHITE ] == E1 : errors |= STATUS_BAD_CASTLING_RIGHTS if self . castling_rights & CASTLING_WHITE_QUEENSIDE : if not BB_A1 & self . occupied_co [ WHITE ] & self . rooks : errors |= STATUS_BAD_CASTLING_RIGHTS if self . castling_rights & CASTLING_WHITE_KINGSIDE : if not BB_H1 & self . occupied_co [ WHITE ] & self . rooks : errors |= STATUS_BAD_CASTLING_RIGHTS if self . castling_rights & CASTLING_BLACK : if not self . king_squares [ BLACK ] == E8 : errors |= STATUS_BAD_CASTLING_RIGHTS if self . castling_rights & CASTLING_BLACK_QUEENSIDE : if not BB_A8 & self . occupied_co [ BLACK ] & self . rooks : errors |= STATUS_BAD_CASTLING_RIGHTS if self . castling_rights & CASTLING_BLACK_KINGSIDE : if not BB_H8 & self . occupied_co [ BLACK ] & self . rooks : errors |= STATUS_BAD_CASTLING_RIGHTS if self . ep_square : if self . turn == WHITE : ep_rank = 5 pawn_mask = shift_up ( BB_SQUARES [ self . ep_square ] ) else : ep_rank = 2 pawn_mask = shift_down ( BB_SQUARES [ self . ep_square ] ) if rank_index ( self . ep_square ) != ep_rank : errors |= STATUS_INVALID_EP_SQUARE if not self . pawns & self . occupied_co [ self . turn ^ 1 ] & pawn_mask : errors |= STATUS_INVALID_EP_SQUARE if not errors & ( STATUS_NO_WHITE_KING | STATUS_NO_BLACK_KING | STATUS_TOO_MANY_KINGS ) : if self . was_into_check ( ) : errors |= STATUS_OPPOSITE_CHECK return errors