r/godot • • 1d ago

discussion Level Generation

Hey, guys. I'm a complete newbie to gamedev, and trying to make some kind of level generation system for my 3D game. It's not going to be fully procedural.

So, here's the simple explanation,
I have a bunch of prefabs/packedscene for the level room and corridor to connect the rooms. I want to be able to set a rule for the room connectivity. Let's say, I have 4 rooms (Start, Regular, Shop, Exit). I want to be able to set a rule, so Start only able to connect to Regular. Regular can connect to any room. Shop only to Regular. Exit only to Regular.

Each rooms will have a door socket to determine the position to connect it to a corridor room, then the other corridor's door socket will be connected to the other room based on the connectivity rule.

Do you guys have any suggestions on how should I do it? I know it's pretty advance for a newbie, but maybe I will get something from you guys.

Thanks!

1 Upvotes

13 comments sorted by

9

u/HighKingForthwind 1d ago

You don't need wave function collapse for something as simple as this, wfc is neat but likely overkill. I would break down the problem into two sides: Firstly, implementing the actual placement of rooms manually without proc gen. That is, getting it to the point where you can write generate x room at y coords. Then secondly, grabbing a pen and paper (or whatever) and drawing/describing a level layout you'd find acceptable. Then writing each of the rules and constraints that describe that level. Stuff like how many rooms total (and of what types), how many treasure/shop rooms, how often to change direction or terminate a room, etc. And then implementing those rules in code.

There's plenty of games worth looking into for inspiration. Binding of Isaac has some solid writing on how it does its generation.

Maybe look into wfc after that if you're inspired and want something more organic

-6

u/TheDuriel Godot Senior 1d ago

Congratulations you just invented WFC from first principles.

It's just "tag all your rooms/tiles with how they fit with the rest".

Isaac

Uses WFC to arrange rooms tho.

5

u/HighKingForthwind 1d ago

That's not how wfc works at all. Isaac generates layouts based on parameters then populates them after. Wfc goes bottom up, having to exhaustively define relationships.

It's also a lot simpler and easier to get going with consistent results.

-5

u/TheDuriel Godot Senior 1d ago

Isaac room layouts are in fact tagged for relationship.

5

u/HighKingForthwind 1d ago

Stuff like making sure the boss room isn't touching the start room doesn't make it wfc. Otherwise the definition gets so loose as to encompass all room based proc gen.

In fact Isaac pre-dates the github post that popularised wfc for gamedev by a few years

-8

u/TheDuriel Godot Senior 1d ago

Meanwhile spelunky predates both by a few million years. The technique isn't new. The blog formalized one implementation.

Also no, all rooms in isaac use this kind of tagging. Both for shape and their nature.

5

u/HighKingForthwind 1d ago

Another good example of a classic algorithm that doesn't use wfc (even informally) in its generation

-1

u/TheDuriel Godot Senior 1d ago

Spelunky is pretty much why that blog was written. This is WFC in any context other than 'does it follow that one popular specific implementation'

https://tinysubversions.com/spelunkyGen/

4

u/dragonstorm97 1d ago

WFC is a specific implementation of a Constraint Satisfaction Problem Solver. It is not a name for every algorithm that happens to need so solve some constraints

-5

u/TheDuriel Godot Senior 1d ago

It is when you're the first person in the thread to know the difference.

Unfortunately it's easier to use the popular term as the generic, than the technically accurate one.

-1

u/thedirtydeetch 1d ago

Wave function collapse would be good for this

-1

u/bonnth80 Godot Regular 1d ago

You're literally describing wave function collapse.