Find the common parent tile for a sequence of tiles.
551781
def _parent_tile(tiles):
    
    parent = None
    for t in tiles:
        if parent is None:
            parent = t

        else:
            parent = common_parent(parent, t)

    return parent
262297
private static Collection<TileRef> getTiles(Map<Transition, Collection<TileRef>> transitions, Transition transition)
    {
        if (!transitions.containsKey(transition))
        {
            transitions.put(transition, new HashSet<TileRef>());
        }
        return transitions.get(transition);
    }
1002140
int[] getGenerals() {
        return Arrays.stream(tiles)
                .filter(tile1 -> tile1.getClass().equals(GeneralTile.class))
                .sorted(Comparator.comparingInt(t -> t.getOwnerPlayerIndex().get()))
                .mapToInt(Tile::getTileIndex)
                .toArray();
    }
662010
private Collection<Tile> getSharedNeigbors(Tile tile1, Tile tile2)
    {
        final Collection<Tile> neighbors1 = map.getNeighbors(tile1);
        final Collection<Tile> neighbors2 = map.getNeighbors(tile2);
        final Collection<Tile> sharedNeighbors = new HashSet<>(2);
        for (final Tile neighbor : neighbors1)
        {
            if (neighbors2.contains(neighbor))
            {
                sharedNeighbors.add(neighbor);
            }
        }
        neighbors1.clear();
        neighbors2.clear();
        return sharedNeighbors;
    }
1251255
def get_parent(self):
        """"""
        return None if self.zoom == 0 else self.tile_pyramid.tile(
            self.zoom - 1, self.row // 2, self.col // 2
        )
716382
def find_coverage(self, zoom):
        
        # Find a group of adjacent available tiles at this zoom level
        rows = self._query('''SELECT tile_column, tile_row FROM tiles
                              WHERE zoom_level=?
                              ORDER BY tile_column, tile_row;''', (zoom,))
        t = rows.fetchone()
        xmin, ymin = t
        previous = t
        while t and t[0] - previous[0] <= 1:
            # adjacent, go on
            previous = t
            t = rows.fetchone()
        xmax, ymax = previous
        # Transform (xmin, ymin) (xmax, ymax) to pixels
        S = self.tilesize
        bottomleft = (xmin * S, (ymax + 1) * S)
        topright = ((xmax + 1) * S, ymin * S)
        # Convert center to (lon, lat)
        proj = GoogleProjection(S, [zoom])  # WGS84
        return proj.unproject_pixels(bottomleft, zoom) + proj.unproject_pixels(topright, zoom)
80071
private static Collection<TileRef> getTiles(Map<ColorRgba, Collection<TileRef>> colors, ColorRgba color)
    {
        if (!colors.containsKey(color))
        {
            colors.put(color, new HashSet<TileRef>());
        }
        return colors.get(color);
    }
373140
def get_tiles(self):
        """"""
        for x, y in griditer(self.root_tile.x, self.root_tile.y, ncol=self.tiles_per_row):
            yield TileCoordinate(self.root_tile.zoom, x, y)
1065957
def find_pairs(self, tiles_34, first_index=0, second_index=33):
        
        pair_indices = []
        for x in range(first_index, second_index + 1):
            # ignore pon of honor tiles, because it can't be a part of pair
            if x in HONOR_INDICES and tiles_34[x] != 2:
                continue

            if tiles_34[x] >= 2:
                pair_indices.append(x)

        return pair_indices
996999
function tileToBBOX(tile) {
    var e = tile2lon(tile[0] + 1, tile[2]);
    var w = tile2lon(tile[0], tile[2]);
    var s = tile2lat(tile[1] + 1, tile[2]);
    var n = tile2lat(tile[1], tile[2]);
    return [w, s, e, n];
}
963538
def bg(self) -> np.array:
        
        bg = self._tiles["bg"][..., :3]
        if self._order == "F":
            bg = bg.transpose(1, 0, 2)
        return bg
616624
function(){
            var tiles = this.getValidTargetTiles();
            var result = [];
            for (var i = 0; i < tiles.length; i++) {
                var tile = tiles[i];
                var targets = this.getValidTargetsAtPosition(tile.x, tile.y);
                result = result.concat(targets);
                if(this.includeTiles){
                    result.push(tile);
                }
            }
            return result;
        }
201352
def walktree(classes, children, parent):
    """"""
    results = []
    classes.sort(lambda a, b: cmp(a.__name__, b.__name__))
    for c in classes:
        results.append((c, c.__bases__))
        if children.has_key(c):
            results.append(walktree(children[c], children, c))
    return results
341888
def each_tile level
			size = tile_size level
			(0...size).each do |y|
				(0...size).each do |x|
					yield(x, y) if block_given?
				end
			end
		end
1277740
def tile_bbox(self, tile_indices):
        
        (z, x, y) = tile_indices
        topleft = (x * self.tilesize, (y + 1) * self.tilesize)
        bottomright = ((x + 1) * self.tilesize, y * self.tilesize)
        nw = self.unproject_pixels(topleft, z)
        se = self.unproject_pixels(bottomright, z)
        return nw + se
369450
function(tile) {
    var x = tile.x;
    var y = tile.y;
    var xUp = x + 1 < xUpperBound;
    var xDown = x >= 0;
    var yUp = y + 1 < yUpperBound;
    var yDown = y >= 0;

    var adjacents = [];
    if (xUp) {
      adjacents.push({x: x + 1, y: y});
      if (yUp) {
        adjacents.push({x: x + 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x + 1, y: y - 1});
      }
    }
    if (xDown) {
      adjacents.push({x: x - 1, y: y});
      if (yUp) {
        adjacents.push({x: x - 1, y: y + 1});
      }
      if (yDown) {
        adjacents.push({x: x - 1, y: y - 1});
      }
    }
    if (yUp) {
      adjacents.push({x: x, y: y + 1});
    }
    if (yDown) {
      adjacents.push({x: x, y: y - 1});
    }
    return adjacents;
  }
1022156
def count_tiles_by_suits(tiles_34):
    
    suits = [
        {'count': 0, 'name': 'sou',   'function': is_sou},
        {'count': 0, 'name': 'man',   'function': is_man},
        {'count': 0, 'name': 'pin',   'function': is_pin},
        {'count': 0, 'name': 'honor', 'function': is_honor}
    ]

    for x in range(0, 34):
        tile = tiles_34[x]
        if not tile:
            continue

        for item in suits:
            if item['function'](x):
                item['count'] += tile

    return suits