5
\$\begingroup\$

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

UPDATE:

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
   f
c     d

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

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

\$\endgroup\$
3

2 Answers 2

2
\$\begingroup\$

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                    -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.

\$\endgroup\$
2
  • \$\begingroup\$ Check my update. \$\endgroup\$
    – Gabriel
    Jan 5, 2011 at 19:10
  • \$\begingroup\$ @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. \$\endgroup\$
    – Zano
    Jan 6, 2011 at 2:02
0
\$\begingroup\$

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).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .