Page 1 of 1

Improved Procedural Lavaland Generation

PostPosted: Sat May 18, 2019 12:05 am
by Dagdammit
This would be a more regulated procedural design method that lavaland could use, basically creating a macro-scale blueprint before that part where it lays down all the tunnels and lava. It would integrate the lavaland ruins into a more natural procedural environment, and create an interesting maze of lava rivers while ensuring you can always reach the far end of the map without crossing magma.

Start by chopping lavaland up (conceptually) into a 4x4 grid of 16 sectors, each approx. 64x64 tiles in size. Bottom left sector is still mining outpost, but necropolis/final boss zone is now the top right sector rather than taking up entire top edge of map. West and south edges of the base lavaland map remain a lava coastline of sorts.

STEP 1: Use a find-union process to link random sectors to random neighbors until the SW and NE corners are connected.
Exact steps:
​-Pick random tile. (equal weight to all)
-Check random adjacent tile (out of however many exist), do find-union.
--If new union, mark that border as linked. (each sector tracks whether it's linked to the neighbors on its N and E borders)
-Check if SW and NE sector are in the same set (which will mean that a path exists. If not, repeat.)


STEP 2: ​Choose one random possible path between SW and NE. All the links in chosen path are protected; the borders they cross will never have lava rivers placed along them. (This is to ensure there's always a route from the outpost to the necropolis that doesn't require crossing lava.)
-Start at the SW tile.
-Use random pathfinding to adjacent linked tiles, backtracking at dead ends, until NE tile is reached.
--Do not use A* pathfinding because we don't care if it's the shortest possible path.
--Hell, consider using INVERSE A* where it AVOIDS the options that are likely to be shortest.


STEP 3: Any unlinked borders are designated as lava (for now)

STEP 4: Populate each sector (except for the SW and NE ones) with a randomly chosen core. Cores are medium and large-sized lavaland ruins, possibly including new 'ruins' that are just interesting prebuilt cave formations. Allow each core to update the state of sector borders ("lava" to "linked" or vice versa) based on the core's preferences.
-Each core is randomly placed within its sector, excluding a 4-tile border along each edge.
--This will limit lavaland ruins to a maximum size of 56x56 tiles, which is enough for virtually every ruin besides the infamously oversized wish granter vault. Even the syndie base is only 38x38.

-Cores can flag some or all of their 4 sides as being "lava" or "open." (for example, the syndie base ruin flags all 4 directions as being lava)
--The "open" flag will change the border in that direction to "linked" if it was initially designated as "lava" in step 3. (Useful if you'd prefer the ruin to be accessed from a specific direction)
--The "lava" flag trumps the "open" flag and will make the border in that direction lava, UNLESS it's part of the protected path. If that's the case, the sector rejects that core and picks a new one.

-Each sector will first attempt to use the previous sector's last rejected core (if any). The order in which the 14 sectors are populated is random.


STEP 5: Now that final lava borders are determined, generate lava rivers along each one. To create a more natural-looking environment, start & end these lava rivers at intersect points that randomly deviate from the actual intersections of the sector grid.
-Intersect points will never deviate far enough that traveling in any of the cardinal directions would cause you to hit a neighboring sector's core. This is to ensure that lava rivers and cores never overlap.

STEP 6: For each side of a core that's flagged as "lava" AND has a matching lava border on that side of the sector, generate two more lava rivers from the corners of the sector to the relevant intersect point. Then take the resulting ring of lava rivers and fill the interior with lava as well, creating magma lakes.

STEP 7: Generate tunnels between the cores of any sector with a "linked" border.

STEP 8: Place the contents of the cores. Generate minerals, flora, mobs & some small lavaland ruins using the same procedural mechanisms currently in use.

Re: Improved Procedural Lavaland Generation

PostPosted: Sat May 18, 2019 12:10 pm
by knacker48
Seems kind of reminiscent of how spelunky generates its levels with the whole grid system

Re: Improved Procedural Lavaland Generation

PostPosted: Sat May 18, 2019 5:08 pm
by Dagdammit
Yeah, I studied spelunky’s procedural generation methods back in the day (which isn’t hard, they’re amazingly simple). There’s a measure of direct influence.

To be clear, I don’t currently have the coder chops to implement this myself, but I’d be happy to work with anyone who wanted to try. Should at least be able to provide pseudocode for the precise steps.

Re: Improved Procedural Lavaland Generation

PostPosted: Sat May 18, 2019 11:43 pm
by lmwevil
or we remove lavaland and bring back the asteroid

Re: Improved Procedural Lavaland Generation

PostPosted: Sun May 19, 2019 12:55 am
by Farquaar
lmwevil wrote:or we remove lavaland and bring back the asteroid

Why not have both?

Re: Improved Procedural Lavaland Generation

PostPosted: Sun May 19, 2019 1:28 am
by Shadowflame909
isn't the asteroid technically still there.

Get it since it's just a bunch of space rocks

Re: Improved Procedural Lavaland Generation

PostPosted: Tue Aug 06, 2019 9:05 am
by cacogen
I know this is three months old but I really like this idea and someone should implement it