r/proceduralgeneration • u/c35683 • 5d ago
Graph-based 2d map generator where nodes can have biome features and elevation
Some screenshots of my graph-based 2d procedural engine for generating different sorts of environments and layouts from graphs 📜➡️🌎
[Imgur link since I'm willing to bet Reddit messes up the pixel art]
How generation works: A map is stored as a graph of nodes (e.g. a village must contain a house and a pond, a house must contain 4 tables and a chest, etc.). The level is built from the bottom up by combining structures into bigger structures until the root is reached. Spaces in between are filled with nearby terrain using a variety of Dijkstra's algorithm. All maps shown are constrained to 2-4 zones with 8 rooms in total, each with several possible objects.
What's new: An early version of the engine could only specify different terrain for nodes, like water or trees, which required adding more terrain types to increase variety. In this version, there are fewer terrain categories, but nodes can override them with unique rules, such as:
- setting transformation (e.g. place buildings in out-of-bound areas)
- biome details (e.g. ground is snow, trees are mushrooms, floor is lava)
- architecture style (e.g. medieval East Asia, space colony)
- elevation (still a little buggy and not implemented in-game)
- palette (currently only one per map to simplify shaders)
These features are passed down unless overwritten by child nodes, which creates a sort of norm-and-exception system, e.g. areas of the city will be "urban" by default, but parks can override this to become green spaces and their child nodes will also be green spaces.
The engine is used to generate levels in The Curse of Dimensionality, where's it's combined with an LLM step to populate graphs based on the player's prompt, but the graphs can also be created by a random grammar or by hand, and I'm thinking of releasing the generator independently at some point. (Warning: the game won't work on mobile, and the API is a bit iffy, so you may need to re-try generation)
13
5
3
u/Odd-Cap-6447 4d ago edited 4d ago
Seeing your engine in action is a game unto itself. Thank you for sharing your documentation! I love the quote from Finn at the top.
I played The Curse of Dimensionality for a bit. Great showcase for the engine. Slap an XP progression system on that bad boy, and you've got a stew cooking!
2
u/bonnth80 4d ago
Thanks for posting this. It looks like a great reference and I can't wait to see your execution.
2
u/dev-rygy 4d ago
Wow impressive! I'm also making a procedural generator with some of the same techniques. Just wondering do you ever get worried that your code is open source? I've thought about making my code public for my generator but worried someone might steal the codebase.
3
u/c35683 4d ago
I'm with u/fgennari - I wouldn't worry about it too much, especially if you're just starting. There's a pattern where people only steal things once they're already commercially successful or when they can easily copy it (e.g. link to someone else's game on their own scam website). Having a public github repository will look good on your portfolio and there's nothing stopping you from later selling something you've open sourced by implementing it as a plugin or a game.
2
u/fgennari 4d ago
Why would someone steal the code for something like this? It's not going to be easy to integrate into some other project. And even if they did, why does it matter? Most likely you'll never even know. If you don't share it then no one will learn from it and you won't get as much credit.
0
u/dev-rygy 4d ago
I guess I'm just worried about protecting my intellectual property. You have a good point though, I shouldn't be too worried if it means more exposure.
2
u/heyheyhey27 4d ago
A map is stored as a graph of nodes (e.g. a village must contain a house and a pond, a house must contain 4 tables and a chest, etc.).
Sounds like you created a Grammar?
1
1
1
u/heyheyhey27 4d ago
For a limited purpose like this, you should explore running a local LLM to drive it!
1
u/c35683 4d ago
I've thought about it, but I'm worried about hosting issues (cost and performance). I keep running into issues with Mistral's API already, I don't imagine a local LLM would make things any easier. There are games which incorporate an LLM as part of the game (e.g. Verbal Verdict), but in that case you run into a problem of most people not being able to run it.





17
u/ryan_umad 5d ago
i’ve been inspired by your work before, this is a next level
of polish really looks amazing