Diamond Square Procedural Map Generation

Show off your games, demos and other (playable) creations.
User avatar
darkfrei
Party member
Posts: 1168
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 12660 times
diamond-square-01.love
(1.33 KiB) Downloaded 294 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1168
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 12633 times
diamond-square-02.love
(2.38 KiB) Downloaded 312 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
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)?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
darkfrei
Party member
Posts: 1168
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
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
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.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
darkfrei
Party member
Posts: 1168
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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
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)?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
pgimeno
Party member
Posts: 3541
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: 1168
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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
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?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 14 guests