for (i in roomCount) {

do {
    width = random.Next(minSize, maxSize);
// same for height

    x1 = random.Next(gridWidth- width);
// same for y1

AABB aabb = new(x1, y1, x1 + width, y1 + height);
} while (attempts++ < 10 && intersects(aabb, aabbs, i));
}