# Generating lakes and rivers on 2D grid

I recently posted a question about how to technically represent a generated terrain similar to the game kingdoms and castles.

I got some great advice and decided to create a 1x1 cube at each coordinate since I will have very small maps, for now 50x50.

I wrote some code to generate terrain, this is super basic atm and simply instantiates either grass or water tiles depending on the noise value at the coordinate:

public static class Noise
{

public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale)
{
float[,] noiseMap = new float[mapWidth, mapHeight];

if (scale <= 0)
scale = .0001f;

for (int y = 0; y < mapHeight; y++)
{
for (int x = 0; x < mapWidth; x++)
{
float sampleX = x / scale;
float sampleY = y / scale;

float perlinValue = Mathf.PerlinNoise(sampleX, sampleY);
noiseMap[x, y] = perlinValue;
}
}

return noiseMap;
}
}

public class MapGenerator : MonoBehaviour
{
public int mapWidth;
public int mapHeight;
public float noiseScale;

[Space]
public GameObject grassTile, waterTile;

public void GenerateMap()
{
float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, noiseScale);

for (int x = 0; x < mapWidth; x++)
{
for (int y = 0; y < mapHeight; y++)
{
if (noiseMap[x,y] >= .3)
Instantiate(grassTile, new Vector3(x, 0, y), Quaternion.identity);
else
Instantiate(waterTile, new Vector3(x, -1, y), Quaternion.identity);
}
}
}
}


It generate something like this:

Now this obviously does not look like a realistic landscape. My question is, how do I decide which values should represent water, and which should represent grass, in order to get a landscape that makes sense?

What I would like my landmass to look like something that has lakes and maybe rivers, instead of these random puddles you see in the image above, more something like this:

EDIT:

Setting a higher scale value lead to this:

• What Scale did you use in the end? Commented May 17, 2020 at 12:48