def _get_random_xy()

in mujoco_worldgen/util/placement.py [0:0]


def _get_random_xy(random_state, boxes, width, height, placement_margin):
    xy = np.zeros(len(boxes) * 2)
    for t in range(3):
        if t > 0:
            dist = np.abs(np.expand_dims(xy, 1) - np.expand_dims(xy, 0))
            dist /= max(width, height)
            for i in range(dist.shape[0]):
                dist[i, i] = 1.0
        for i, box in enumerate(boxes):
            if t == 0 or np.min(dist[i, :]) < 0.1:
                xy[i] = random_state.uniform(placement_margin,
                                             width - box["size"][0] - placement_margin)
            if t == 0 or np.min(dist[i + len(boxes), :]) < 0.1:
                xy[i + len(boxes)] = random_state.uniform(placement_margin,
                                                          height - box["size"][1] - placement_margin)
    return xy