```
{
cavePoints = new int[width, height];
int seed = Random.Range(0, 1000000);
System.Random randChoice = new System.Random(seed.GetHashCode());
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
if (x == 0 || y == 0 || x == width - 1 || y == height - 1)
{
cavePoints[x, y] = 1;
}else if (randChoice.Next(0, 100) < randFillPercent)
{
cavePoints[x, y] = 1;
}else
{
cavePoints[x, y] = 0;
}
}
}
for (int i = 0; i < smoothCycles; i++)
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
int neighboringWalls = GetNeighbors(x, y);
if (neighboringWalls > threshold)
{
cavePoints[x, y] = 1;
}else if (neighboringWalls < threshold)
{
cavePoints[x, y] = 0;
}
}
}
}
}
private int GetNeighbors(int pointX, int pointY)
{
int wallNeighbors = 0;
for (int x = pointX - 1; x <= pointX + 1; x++)
{
for (int y = pointY - 1; y <= pointY + 1; y++)
{
if (x >= 0 && x < width && y >= 0 && y < height)
{
if (x != pointX || y!= pointY)
{
if (cavePoints[x,y] == 1)
{
wallNeighbors++;
}
}
}
else
{
wallNeighbors++;
}
}
}
return wallNeighbors;
}
private void PlaceGrid()
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
if (cavePoints[x,y] == 1)
{
tileMap.SetTile(new Vector3Int(-x + width / 2, -y + height / 2, 0),tileRule);
}
}
}
}```
im pretty knew to perlin noise...and i even tried it myself few time, i moreless know what i need to do, but i dont know how i to implement it.
if someone could help , i will be thankful.
```

Choose your favorite “falloff function” and multiply its output to the Perlin noise field at all points.

For instance, if you chose 1 / r ^ 2 as your falloff and the center as your origin, you could compute an attenuation like so:

```
float perlinX, perlinY; // however you calculate these to feed into Perlin... I didn't look above.
float rSquared = perlinX * perlinX + perlinY * perlinY;
float attenuation = 1.0f / rSquared;
```

Now you would multiply the output from the noise function by attenuation as calculated at each point.

You can of course substitute any other origin or falloff function you want in place of this simple one.