Worldgen Rewrite

Hallo, this is Angle from bay12. I promised I’d do a worldgen Rewrite, and I think I’m about ready to follow up on that. Before I started, though, I figured I should talk to y’all and see what you think about my proposed course of action. The things I’m going to do are:

[spoiler]A) Make it so that each overmap tile can have a list of different tile types. I.E. a tile could be a [forest, creek, campsite, fungus] or a [road, checkpoint, sessile triffid] or whatever. I’m not sure whether to use arrays or vectors or something else for this, I’ll need to see how they affect performance.

B) Altering the tilegen code so that multiple tilegens run in sequence have sensible outcomes, I.E. If you have a house in a forest, it doesn’t completely remove the forest… or have trees in the living room.

C) Moving all the map extras into tile types and having them be handled the same as everything else.

D) Editing the worldgen code to make the placements of tiles make more sense. This may or may not be necessary, we’ll see.

E) Adding additional functionality for varying regions.

F) Adding many more tile types and the worldgen code to handle them. This includes creeks, trails, evidence of looting and carnage, etc.

G) Maybe add an additional region type, Heavy Forest?

H) Edit the processes that make multi tile things like mansions, labs, hospitals, cities, etc. so that they make more sense. No more mansions with nothing but dining rooms, etc.

I) Possibly tackle Z-Levels? I’m not sure how exactly to go about this. I might try editing cataclysms map system to work like the system I had programmed for my own roguelikes that I never made. We’ll see.[/spoiler]

I went ahead and made a github repo, so you can track my progress: https://github.com/Angular-Angel/Cataclysm-DDA

Those all sound like features we’d love to have.
I recall we chatted about this and were on the same page, but just to be a stick in the mud, some guidelines for large scale overhauls:
Map content stays easy to add, trending toward easier if at all possible. (probably not hard to improve on what we have now)
Progress needs to be incremental, each change needs to be manageable in size and improve the state of the code.
No major regressions in map generation features. If certain things make things very hard, we can drop a few things, but we’re not going to shed a lot of content in order to make things easier and plan to add it back later.

It should contain everything the game already does by the time it’s ready to be merged. As I said, I’m in favor of more content, not less, so I don’t plan to drop anything.

Biggest thing I can suggest for worldgen is to rewrite how cities get generated so that they can properly support overmap specials (multitile buildings) inside cities. My original intent for those is that you would specify a range of city sizes, then a few tags like required and unique that would control how buildings are placed in cities. So you could specify a city hall structure that goes in cities sized 6-10, unique so only one spawns, and required so one has to spawn per city in that range.

Rewriting worldgen sounds like a really big project.

A) Data structure wouldn’t affect performance much. Vector would be fine, assuming you did everything else OK.
B) Making them work together would probably be easy. Harder part would probably be splitting mapgen into passes.
C) This one sounds good. A fair bit of work, but probably not that hard.

F) Evidence of looting could be better as some sort of “tile template” than having a separate tile for “looted house”.

I) Don’t start Z-levels with mapgen. You’d probably want hills or deep water or something like that and this would only show how lacking Z-levels currently are.

Yeah, the way I’d implement looting is by just having a standard “Looting” tile that would be placed on top of anything worth looting. It’d just go through and remove items and wreck stuff.

And yeah, I’d do the whole Z-level update first of course, it doesn’t sound to difficult. But that’s the last thing on my list anyway, so we’ll see.

Whales originally had a concept of zones, which never really got implemented. I picked up the idea and started working with it a little in a PR, but haven’t finished it yet, you can see where I was going with it at https://github.com/CleverRaven/Cataclysm-DDA/pull/7892

Looks cool. Are you still working n it, or have you given up on it?

I intend to go back to it after I finish my computer rework. But, if you want to build on it, be my guest.

I haven’t looked at the code yet, but I’ll probably aim for a similar effect with an entirely different code base. The way I’d do it, is that there’s your normal tiles, which are placed in more or less the same way they are now, and then the game goes over and places various add-ons on top, like “Looting” or “Fungus” or “Triffids” or whatever, and that modifies the underlying tile. You could have different intensities, like “Heavy Looting” or “Mild Fungus” or whatever.

Yeah, that’s pretty close to what I had in mind. Each zone would have an epicenter with a density factor based on distance from the epicenter. I got hung up on trying to figure out a good system to make certain zones expand or contract (notably the triffid and fungal zones), and to make zones interact with each other.

This sounds cool.

If you make it so that those can be applied to existing (generated) terrain, this could easily be re-used for progressive fungification/triffidization/blobification of terrain and species wars.

Welp, I’ve gotten my previous project to a point where I can let it be for a while, so I’m gonna go ahead and get started on this. Wish me luck!

Good luck!

gl!

Good luck!

Alright, so things are coming along pretty well. Right now I’m going through the mapgen functions and replacing things like (t_north == “prison_b_entrance”) with (t_north.has(“prison_b_entrance”)). is there a macro or something that I could use to do this, or do I need to do the entire thing manually?

I bet there’s a regular expression that could do this.
Or you could just use a semi-manual method: replace all "t_north == " with “t_north.has(”, add missing parentheses and repeat for south, west and east. Most editors do have a replace function.

Yeah, I just used the search and replace. It’s still a lot of work, though. Whoever managed to add all this originally must have been made of iron…

Well, it was incremental work over years and years, so certainly much less of an undertaking than doing it all at once.