Finds if particular King is checkmated.

    :type: position: Board
    :type: input_color: Color
    :rtype: bool
348068
def is_checkmate(position, input_color):
    
    return position.no_moves(input_color) and \
        position.get_king(input_color).in_check(position)
1240608
def _check_state(self):
        
        if(self.grid is not None and
           self.configs.configs is not None and
           self.assignments['forward_model'] is not None):
            self.can_model = True

        if(self.grid is not None and
           self.assignments['measurements'] is not None):
            self.can_invert = True
963396
def contains_opposite_color_piece(self, square, position):
        
        return not position.is_square_empty(square) and \
            position.piece_at_square(square).color != self.color
1353459
def matrix_check(table):
    
    try:
        if len(table.keys()) == 0:
            return False
        for i in table.keys():
            if table.keys() != table[i].keys() or vector_check(
                    list(table[i].values())) is False:
                return False
        return True
    except Exception:
        return False
140066
def find_selected(self, event):
        ''''''
        if event.GetId() == self.id():
            self.checked = event.IsChecked()
            return self
        return None
202520
def disambiguate_discovered_check(possibilities)
      DIRECTIONS.each do |attacking_piece, directions|
        attacking_piece = attacking_piece.upcase if self.move.black?

        directions.each do |dir|
          piece, square = first_piece(king_position, dir)
          next unless piece == self.move.piece && possibilities.include?(square)

          piece, _ = first_piece(square, dir)
          possibilities.reject! {|p| p == square } if piece == attacking_piece
        end
      end

      possibilities
    end
283005
def board(self, *, _cache: bool = True) -> chess.Board:
        
        if self.board_cached is not None:
            board = self.board_cached()
            if board is not None:
                return board.copy()

        board = self.parent.board(_cache=False)
        board.push(self.move)

        if _cache:
            self.board_cached = weakref.ref(board)
            return board.copy()
        else:
            return board
534770
def add_castle(self, position):
        
        if self.has_moved or self.in_check(position):
            return

        if self.color == color.white:
            rook_rank = 0
        else:
            rook_rank = 7

        castle_type = {
            notation_const.KING_SIDE_CASTLE: {
                "rook_file": 7,
                "direction": lambda king_square, times: king_square.shift_right(times)
            },
            notation_const.QUEEN_SIDE_CASTLE: {
                "rook_file": 0,
                "direction": lambda king_square, times: king_square.shift_left(times)
            }
        }
        for castle_key in castle_type:
            castle_dict = castle_type[castle_key]
            castle_rook = position.piece_at_square(Location(rook_rank, castle_dict["rook_file"]))
            if self._rook_legal_for_castle(castle_rook) and \
                    self._empty_not_in_check(position, castle_dict["direction"]):
                yield self.create_move(castle_dict["direction"](self.location, 2), castle_key)
256763
def has_match_at_current_position(self, sub):
        
        return self.text.find(sub, self.cursor_position) == self.cursor_position
146094
def _check(self, accepted):
        """"""
        # logging.debug('A check is now happening...')
        # for key in self.statediag[1].trans:
        #    logging.debug('transition to '+`key`+" with "+self.statediag[1].trans[key][0])
        total = []
        if 1 in self.quickresponse:
            total = total + self.quickresponse[1]
        if (1, 0) in self.quickresponse:
            total = total + self.quickresponse[(1, 0)]
        for key in total:
            if (key.id == 1 or key.id == (1, 0)) and key.type == 3:
                if accepted is None:
                    if 2 in key.trans:
                        # print 'Found'
                        return key.trans[2]
                else:
                    for state in accepted:
                        if (2, state) in key.trans:
                            # print 'Found'
                            return key.trans[(2, state)]
        return -1
235309
def play(self):
        
        colors = [lambda: self.white_move(), lambda: self.black_move()]
        colors = itertools.cycle(colors)

        while True:
            color_fn = next(colors)
            if game_state.no_moves(self.position):
                if self.position.get_king(color.white).in_check(self.position):
                    return 1

                elif self.position.get_king(color.black).in_check(self.position):
                    return 0

                else:
                    return 0.5

            color_fn()
1113808
def color_check(color):
    
    if isinstance(color, (tuple, list)):
        if all(map(lambda x: isinstance(x, int), color)):
            if all(map(lambda x: x < 256, color)):
                return list(color)
    if isinstance(color, str):
        color_lower = color.lower()
        if color_lower in TABLE_COLOR.keys():
            return TABLE_COLOR[color_lower]
    return [0, 0, 0]
556484
def is_state(self, state):
        
        state = state.format(relation_name=self.relation_name)
        value = _get_flag_value(state)
        if not value:
            return False
        return self.key in value['conversations']
537232
def is_sorted(self, ranks=None):
        
        ranks = ranks or self.ranks

        return check_sorted(self, ranks)
354223
def choice(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = (), random=random) -> Entry:
        
        chosen_entry = None

        for i, entry in enumerate(self.find_all(board, minimum_weight=minimum_weight, exclude_moves=exclude_moves)):
            if chosen_entry is None or random.randint(0, i) == i:
                chosen_entry = entry

        if chosen_entry is None:
            raise IndexError()

        return chosen_entry
799435
def in_check(self, position, location=None):
        
        location = location or self.location
        for piece in position:

            if piece is not None and piece.color != self.color:
                if not isinstance(piece, King):
                    for move in piece.possible_moves(position):

                        if move.end_loc == location:
                            return True
                else:
                    if self.loc_adjacent_to_opponent_king(piece.location, position):
                        return True

        return False
146278
def is_capture(self, move: Move) -> bool:
        """"""
        return bool(BB_SQUARES[move.to_square] & self.occupied_co[not self.turn]) or self.is_en_passant(move)