Skip to content

Adds a new procedural generation algorithm that will be used to generate a more cave-system like Lavaland#262

Merged
ZeWaka merged 20 commits into
tgstation:masterfrom
CabinetOnFire:step1
May 30, 2026
Merged

Adds a new procedural generation algorithm that will be used to generate a more cave-system like Lavaland#262
ZeWaka merged 20 commits into
tgstation:masterfrom
CabinetOnFire:step1

Conversation

@CabinetOnFire

Copy link
Copy Markdown
Contributor

This PR adds a layered terrain generation system that allows us to generate nice looking connected caverns.

It essentially performs the following steps to generate terrain:

  1. Generate Binary Space Partitioning with limits on ratio and size to split the area up into nice leaves of space
image
  1. Create a room/rectangle of a random scale with random offsets in each of these leaves. These are the pockets that will be used to generate the actual cave pockets.
image
  1. Generate corridors between these pockets
image
  1. Apply cellular noise to the result of the above. Except instead of normal cellular noise where things are either dead or alive, we add 2 more states "Definitely dead" and "Definitely alive". Neighboring tiles treat these as if they were just dead or alive. but the tiles themselves are immutable. This lets us ensure that the center of the pocket and the corridors cannot be changed, and means the "golden path" is always going to be floor rather than wall.
image

Along side this, I added support to pass in a prefab json. This JSON lets you pass in data regarding structure that already exist in the grid, and should be either treated as definitely dead or definitely alive. This lets the ruins influence the generation to make them look more natural.

This looks like the following in DM:
list( "cx" = center_turf.x, "cy" = center_turf.y, "w" = active_ruin.width, "h" = active_ruin.height, "isEnclosed" = active_ruin.enclosed_for_terrain, )

cx = center of ruin x
cx = center of ruin y
w = width of ruin
h = height of ruin
isenclosed = Whether the ruin is definitely alive (not enclosed) or definitely dead (enclosed)

Finaly result in TGstation looks like below
https://streamable.com/vgduo2

@CabinetOnFire

Copy link
Copy Markdown
Contributor Author

░░░░░░░░░░░░▄▄
░░░░░░░░░░░█░░█
░░░░░░░░░░░█░░█
░░░░░░░░░░█░░░█
░░░░░░░░░█░░░░█
███████▄▄█░░░░░██████▄
▓▓▓▓▓▓█░░░░░░░░░░░░░░█
▓▓▓▓▓▓█░░░░ Zewaka, ░░░░█
▓▓▓▓▓▓█░░░░Add This░░░░█
▓▓▓▓▓▓█░░░░Please!░░░░░█
▓▓▓▓▓▓█░░░░░░░░░░░░░░█
▓▓▓▓▓▓█████░░░░░░░░░█
██████▀░░░░▀▀██████▀

@Absolucy Absolucy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nowhere near a comprehensive review, just two surface-level improvements

Comment thread src/lavaland_generator.rs Outdated
Comment thread src/lavaland_generator.rs Outdated
Comment thread src/lavaland_generator.rs Outdated
Comment thread src/cave_system_generator.rs
Comment thread src/lib.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread Cargo.toml Outdated
Comment thread src/lib.rs Outdated
@CabinetOnFire

Copy link
Copy Markdown
Contributor Author

@SmArtKar has threatened to beat me if I don't get this PR merged. :*( they are so violent

@ZeWaka

ZeWaka commented May 14, 2026

Copy link
Copy Markdown
Collaborator

@SmArtKar has threatened to beat me if I don't get this PR merged. :*( they are so violent

Tempting to delay so the beatings continue... >:)

@SmArtKar

Copy link
Copy Markdown
Member

@SmArtKar has threatened to beat me if I don't get this PR merged. :*( they are so violent

Tempting to delay so the beatings continue... >:)

My wrath shall fall upon you both (this isn't urgent as we can't actually update rust-g past 4.something on /tg/ anyways, so the PR that requires this will be on hold until then)

@ZeWaka

ZeWaka commented May 19, 2026

Copy link
Copy Markdown
Collaborator

clippy warnings

ZeWaka added 2 commits May 21, 2026 17:15
Force specific version of kiddo to hopefully make kiddo nicer to me

Makes the args into a new type

clippy...be kind..

Formatting

clippy does not want to run locally so I'm doing it like this like a champ

flaky test?
@ZeWaka

ZeWaka commented May 27, 2026

Copy link
Copy Markdown
Collaborator

sorry forgot about this will look today

@ZeWaka ZeWaka merged commit e04c5c1 into tgstation:master May 30, 2026
4 checks passed
@Kapu1178

Copy link
Copy Markdown
Contributor

streamable is a shit website pls embed video directly

@CabinetOnFire

Copy link
Copy Markdown
Contributor Author

github always shits itself when I try to upload videos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants