Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I generated a height map with the diamond square algorithm. The thing is i do not manage to create islands, this is, restrict the height other than water level range to a certain value in the center of the map.

I manualy seeded a circle in the middle of the map but the rest of the map still receives heights over the water level.

I dont fully understand the Perlin noise algorithm so i'd like to work with my current implementation of the diamond square algorithm which took me 3 days to interpret and code in PHP. :P


I'm trying to get a gradient and its working (it's late and have to refine it, i'll try tomorrow). I tried to work with gradients but silly me, I had been clamping the affected values to a radius, giving me a circle when generating the map.

The seeding option is NOT working. I may get some bigger landmass, but may be located in any sector in the map, not even close to the center.

Please have in mind that the DSA generates the middle value averaging it's corners, so its not possible to seed the middle of a square.

a     b
c     d

f = (a+b+c+d) / 4 + random(-value,value)

Perhaps that's why seeding it's not working.

share|improve this question
By diamond square, do you mean the simplex noise algorithm? It's like Perlin noise, but operates on a triangular grid. Also, this article may be some use nolithius.com/game-development/world-generation-breakdown and potentially this question too gamedev.stackexchange.com/questions/4628/… . –  The Communist Duck Jan 4 '11 at 16:38
Perlin noise has nothing to do with Diamond-Square, which is a refined Random Midpoint Displacement Fractal algorithm. en.wikipedia.org/wiki/Diamond-square_algorithm –  Zano Jan 4 '11 at 22:37
I didn't think diamond-square sounded like the name of an algorithm, apologies. I'm too used to 'Perlin', 'Simplex', 'Riemann Zeta' or whut. :P –  The Communist Duck Jan 5 '11 at 17:54
add comment

2 Answers

up vote 2 down vote accepted

From your question I infer that you're trying to seed the border/shore of the island. You might want to do that if it's important that the island's shape is fairly circular, otherwise there's no need.

But what you do have to do is seed a point (the highest) inside the island and few points (the lowest) outside the island. The rest will arrange itself.

To simplify, assuming sea-level is 0, highest point 1, this should be enough a seed:

 -1,0                    -1,0


 -1,0                    -1,0

Ignoring randomization, first iteration (square) gives:

 -1,0       [-0,3]       -1,0

[-0,3]        1,0       [-0,3]

 -1,0       [-0,3]       -1,0

Second (diamond):

 -1,0        -0,3        -1,0
      [-0,2]      [-0,2]  
 -0,3         1,0        -0,3
      [-0,2]      [-0,2]  
 -1,0        -0,3        -1,0

Third (square):

 -1,0 [-0,4] -0,3 [-0,4] -1,0
[-0,4] -0,2  [0,1] -0,2 [-0,4]
 -0,3  [0,1]  1,0  [0,1] -0,3
[-0,4] -0,2  [0,1] -0,2 [-0,4]
 -1,0 [-0,4] -0,3 [-0,4] -1,0

A bit of clutter, but you might see the beginning of an island in the middle of the map.

share|improve this answer
Check my update. –  Gabriel A. Zorrilla Jan 5 '11 at 19:10
@Gabriel: Re: your update. It's a matter of implementation. In my example, the first two iterations are seeded, first iteration using the "standard" corners seed, then, instead of calculating the diamond average, the center point's pre-seeded value is used instead. Common trick when you want to specify some important geographical constraints and let the rest be Plasma'd. –  Zano Jan 6 '11 at 2:02
add comment

There are multiple ways to generate islands, if you want a single island you could try to simply add a gradient (multiplying the result by 0 (edges of the map) to 1 (perfect center)) would usually create a single island.

Its also possible to pre-seed certain values, initialize part of the height map with some values and on choosing a new value check before hand if it hasn't been pre-seeded yet, this could create multiple islands (choose a few random places and put large values in them) or a single island (put a large value in the center of the map).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.