Diamond Square Procedural Map Generation

Show off your games, demos and other (playable) creations.
User avatar
darkfrei
Party member
Posts: 312
Joined: Sat Feb 08, 2020 11:09 pm

Diamond Square Procedural Map Generation

Post by darkfrei »

Hi all!

I've tried to make Diamond Square Procedural Map Generation

Based on this video: https://www.youtube.com/watch?v=4GuAV1PnurU


Attachments
2021-06-20T16_21_27.png
2021-06-20T16_21_27.png (377.13 KiB) Viewed 4759 times
diamond-square-01.love
(1.33 KiB) Downloaded 92 times
User avatar
darkfrei
Party member
Posts: 312
Joined: Sat Feb 08, 2020 11:09 pm

Re: Diamond Square Procedural Map Generation

Post by darkfrei »

The colored version:

Press W and S to change the resolution;
Press R to regenerate map on current resolution;
Press F11 for fullscreen;
Press K to make a lua file with current map as array with values [0 .. 255]. See folder %AppData%\LOVE

Attachments
2021-06-20T22_33_57.png
2021-06-20T22_33_57.png (141.53 KiB) Viewed 4732 times
diamond-square-02.love
(2.38 KiB) Downloaded 77 times
User avatar
Gunroar:Cannon()
Party member
Posts: 407
Joined: Thu Dec 10, 2020 1:57 am

Re: Diamond Square Procedural Map Generation

Post by Gunroar:Cannon() »

Nice, is it possible for me to make this converted to grids for a map where a character can move on(for collisions and things)?
Why can't pirates code in lua? Because they spend to much time at C! :P

-It might look like nonsense :roll: but there's so much proof.
-Some more if you pls... :? .
It has to be real then, all that talk about the end :shock: .
-How to be saved :huh:
User avatar
darkfrei
Party member
Posts: 312
Joined: Sat Feb 08, 2020 11:09 pm

Re: Diamond Square Procedural Map Generation

Post by darkfrei »

Gunroar:Cannon() wrote: Tue Jun 22, 2021 10:45 am Nice, is it possible for me to make this converted to grids for a map where a character can move on(for collisions and things)?
Yes, right now here is float from 0 to 1, but if you press "k", it will be saved as as integers 0-255. It can be very easy changed to (for example) 16 levels. See also the link: https://www.youtube.com/watch?v=4GuAV1PnurU
User avatar
Gunroar:Cannon()
Party member
Posts: 407
Joined: Thu Dec 10, 2020 1:57 am

Re: Diamond Square Procedural Map Generation

Post by Gunroar:Cannon() »

So it's like Perlin/Simplex noise. Can it go on forever or only a defined size can be generated when you want it(good either way).

Does it have biomes? Can biomes be added if not.
Why can't pirates code in lua? Because they spend to much time at C! :P

-It might look like nonsense :roll: but there's so much proof.
-Some more if you pls... :? .
It has to be real then, all that talk about the end :shock: .
-How to be saved :huh:
User avatar
darkfrei
Party member
Posts: 312
Joined: Sat Feb 08, 2020 11:09 pm

Re: Diamond Square Procedural Map Generation

Post by darkfrei »

Gunroar:Cannon() wrote: Tue Jun 22, 2021 7:32 pm So it's like Perlin/Simplex noise. Can it go on forever or only a defined size can be generated when you want it(good either way).

Does it have biomes? Can biomes be added if not.
You can add another square near the old one.
Smallest field is 3x3, the next one is 5x5, the next one is 17x17. Yeah, side = 2^N + 1.

But you can make sides just as a = 2^N + 1 and b = 2^M + 1 and it will be nice filled.

Biomes can be calculated as result of two different value (the hight is value too) maps.

Three maps (hight, temperature, humidity) can describe biomes very nice. High temperature and high humidity is tropical area, but high temperature and low humidity is a desert. If it's too high, then it's always cold and dry.
User avatar
Gunroar:Cannon()
Party member
Posts: 407
Joined: Thu Dec 10, 2020 1:57 am

Re: Diamond Square Procedural Map Generation

Post by Gunroar:Cannon() »

Any code implementation of biomes?(if you're willing of course.)
And can I zoom out the map, to make it show a larger area in a smaller space (sacrificing resolution)?
Why can't pirates code in lua? Because they spend to much time at C! :P

-It might look like nonsense :roll: but there's so much proof.
-Some more if you pls... :? .
It has to be real then, all that talk about the end :shock: .
-How to be saved :huh:
User avatar
pgimeno
Party member
Posts: 2681
Joined: Sun Oct 18, 2015 2:58 pm

Re: Diamond Square Procedural Map Generation

Post by pgimeno »

darkfrei wrote: Tue Jun 22, 2021 8:12 pm Smallest field is 3x3, the next one is 5x5, the next one is 17x17. Yeah, side = 2^N + 1.
Wait, that's 2^2^N + 1, otherwise after 5x5 the next one would be 9x9.
User avatar
darkfrei
Party member
Posts: 312
Joined: Sat Feb 08, 2020 11:09 pm

Re: Diamond Square Procedural Map Generation

Post by darkfrei »

pgimeno wrote: Wed Jun 23, 2021 1:48 pm
darkfrei wrote: Tue Jun 22, 2021 8:12 pm Smallest field is 3x3, the next one is 5x5, the next one is 17x17. Yeah, side = 2^N + 1.
Wait, that's 2^2^N + 1, otherwise after 5x5 the next one would be 9x9.
You are right, the field 5x9 is also possible.
User avatar
Gunroar:Cannon()
Party member
Posts: 407
Joined: Thu Dec 10, 2020 1:57 am

Re: Diamond Square Procedural Map Generation

Post by Gunroar:Cannon() »

The map always seems incomplete, even at a high field.
I'm not familiar with this diamond-square, is there a possible way for me to show more of the map in a smaller area?
Why can't pirates code in lua? Because they spend to much time at C! :P

-It might look like nonsense :roll: but there's so much proof.
-Some more if you pls... :? .
It has to be real then, all that talk about the end :shock: .
-How to be saved :huh:
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests