Gets a set of attackers of the given color for the given square.

        Pinned pieces still count as attackers.

        Returns a :class:`set of squares <chess.SquareSet>`.
196783
def attackers(self, color: Color, square: Square) -> "SquareSet":
        
        return SquareSet(self.attackers_mask(color, square))
856237
def get_piece(self, piece_type, input_color):
        
        for loc in self:
            piece = self.piece_at_square(loc)

            if not self.is_square_empty(loc) and \
                    isinstance(piece, piece_type) and \
                    piece.color == input_color:
                return loc

        raise Exception("{} \nPiece not found: {}".format(self, piece_type))
251881
def blankets
      colour_next_vertex! until painted?
      qv_blocks = Hash.new 0
      g_blocks  = Hash.new 0
      @qv_colours.each { |vertex, colour| qv_blocks[colour] |= vertex }
      @g_colours.each  { |vertex, colour| g_blocks[colour]  |= vertex }
      [Blanket.new(qv_blocks.values), Blanket.new(g_blocks.values)]
    end
351906
def get_pk_index(self, collection):
        
        cls = self.collections[collection]

        if not cls.get_pk_name() in self.indexes[collection]:
            self.create_index(cls.get_pk_name(), collection)
        return self.indexes[collection][cls.get_pk_name()]
329808
def toRanks(A):
    
    AA=sp.zeros_like(A)
    for i in range(A.shape[1]):
        AA[:,i] = st.rankdata(A[:,i])
    AA=sp.array(sp.around(AA),dtype="int")-1
    return AA
316935
private static int[] getRGBs(IndexColorModel pColorModel) {
        int[] rgb = new int[pColorModel.getMapSize()];
        pColorModel.getRGBs(rgb);

        return rgb;
    }
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
979549
def score(self):
        ''
        working_board = np.copy(self.board)
        while EMPTY in working_board:
            unassigned_spaces = np.where(working_board == EMPTY)
            c = unassigned_spaces[0][0], unassigned_spaces[1][0]
            territory, borders = find_reached(working_board, c)
            border_colors = set(working_board[b] for b in borders)
            X_border = BLACK in border_colors
            O_border = WHITE in border_colors
            if X_border and not O_border:
                territory_color = BLACK
            elif O_border and not X_border:
                territory_color = WHITE
            else:
                territory_color = UNKNOWN  # dame, or seki
            place_stones(working_board, territory_color, territory)

        return np.count_nonzero(working_board == BLACK) - np.count_nonzero(working_board == WHITE) - self.komi
578810
function getBoardWithPieces(board, pieces) {
    return mapBoard(board, function (p) {
        var x = p.x,
            y = p.y;

        var piece = Position.getPositionFromPositions(pieces, p);
        return piece ? { x: x, y: y, isBlack: piece.isBlack } : { x: x, y: y };
    });
}
1064798
def pick_target_decoy(tfeature, dfeature):
    """"""
    tscore, dscore = get_score(tfeature), get_score(dfeature)
    if tscore == dscore:
        # same score or both False
        return False
    elif False in [tscore, dscore]:
        # return the non-False feature
        return [v for k, v in {tscore: tfeature, dscore: dfeature}.items()
                if k is not False][0]
    elif tscore > dscore:
        return tfeature
    elif tscore < dscore:
        return dfeature
    else:
        # in case uncaught edgecase occurs
        print('WARNING, target score {} and decoy score {} could not be '
              'compared'.format(tscore, dscore))
        return False
971411
static int index() {
    int probe = UnsafeAccess.UNSAFE.getInt(Thread.currentThread(), PROBE);
    if (probe == 0) {
      ThreadLocalRandom.current(); // force initialization
      probe = UnsafeAccess.UNSAFE.getInt(Thread.currentThread(), PROBE);
    }
    return (probe & ARENA_MASK);
  }
1314996
def get_versus(self):
        
        # game
        game_image = self._game_image_from_screen('versus')
        if game_image is None:
            return None, None, None, None  # nothing else will work
        # board
        board = self._board_from_game_image(game_image)  # may be None
        # safety check. there should be no blanks in a versus board
        if board:
            for p, tile in board.positions_with_tile():
                if tile.is_blank():
                    board = None
        # actors
        player = self._actor_from_game_image('player', game_image)
        opponent = self._actor_from_game_image('opponent', game_image)
        # extra actions
        extra_actions = self._count_extra_actions(game_image)
        return board, player, opponent, extra_actions
142201
def solve(self):
        
        # Create a new, empty board.
        board = Board(self.length, self.height)

        # Iterate through all combinations of positions.
        permutations = Permutations(self.pieces, self.vector_size)
        for positions in permutations:

            # Reuse board but flush all pieces.
            board.reset()

            for level, (piece_uid, linear_position) in enumerate(positions):
                # Try to place the piece on the board.
                try:
                    board.add(piece_uid, linear_position)
                # If one of the piece can't be added, throw the whole set, skip
                # the rotten branch and proceed to the next.
                except (OccupiedPosition, VulnerablePosition, AttackablePiece):
                    permutations.skip_branch(level)
                    break

            else:
                # All pieces fits, save solution and proceeed to the next
                # permutation.
                self.result_counter += 1
                yield board
499062
def material_advantage(self, input_color, val_scheme):
        

        if self.get_king(input_color).in_check(self) and self.no_moves(input_color):
            return -100

        if self.get_king(-input_color).in_check(self) and self.no_moves(-input_color):
            return 100

        return sum([val_scheme.val(piece, input_color) for piece in self])
1243628
@Transactional(readOnly = true)
	public Collection<Attack> findAll() {
		return em.createQuery("FROM Attack", Attack.class).getResultList();
	}
258056
def controls(self, move):
    ''''''
    to_move = self.board.turn
    analysis_board = chess.Board(self.board.fen())
    analysis_board.push(move)
    squares = 0
    for square in chess.SQUARES:
      if move.to_square in analysis_board.attackers(to_move, square):
        squares |= chess.BB_SQUARES[square]
    return SquareSet(squares)
1093053
static int[] toArray(BitSet set) {
        int[] vertices = new int[set.cardinality()];
        int i = 0;

        // fill the cyclic vertices with the bits that have been set
        for (int v = 0; i < vertices.length; v++) {
            if (set.get(v)) {
                vertices[i++] = v;
            }
        }

        return vertices;
    }