Help with procedurally generated cities.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Help with procedurally generated cities.

Post by bobbyjones »

So I want to make procedurally generated cities but there is lacking a lot if literature on that subject. Does anyone here have some experience with procedural generation? I could really use some help. I don't have a code snippet to show as I don't even know where to begin.
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Help with procedurally generated cities.

Post by ArchAngel075 »

Look into Cataclysm DDA, it has city generation, perhaps you can also think of the idea as cave/maze/dungeon generation but with other features?

My approach would create road layouts and then insert buildings alongside, or perhaps placing road segments onto existing road segments while placing a building attached to the new segment, that way each building expands the road purposefully?

Ive only experience in one flat tile by tile room generation i attempted in C# (UnityEngine)
Ive never tried city gen.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Help with procedurally generated cities.

Post by kikito »

2d or 3d?

I don't have any code, but I know several resources that might get you inspired:

My favourite 3d writeup is the series starting here (some of the concepts are applicable to 2d too)

http://www.shamusyoung.com/twentysidedtale/?p=2940

The first videos of Introversion's "Subversion" (a failed project) are also interesting:

http://www.introversion.co.uk/subversion/

Finally, there's also Ultima Ratio Regum. It has some examples of generated cities:

http://www.ultimaratioregum.co.uk/game/ ... districts/

http://www.ultimaratioregum.co.uk/game/ ... er-cities/
Last edited by kikito on Thu Jun 25, 2015 12:55 pm, edited 1 time in total.
When I write def I mean function.
User avatar
zorg
Party member
Posts: 3446
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Help with procedurally generated cities.

Post by zorg »

I personally would view this from two perspectives:

1. how to break the world up into parts
2. how to generate said parts

The first one means dealing with what to generate, and in what order; should districts, buildings/space for them or roads/paths be generated first?
Also, defining the attributes to those types of generative things, like districts maybe having a type like urban, suburban, agricultural, industrial, etc.; buildings having designs or colours, or perhaps more complex features like roof types, etc.; roads being dirt, asphalt/tarmac or something else.
Of course, one can also have unique stuff, that are not procedurally generated as well, like unique landmarks (though they should be checked for some things, like if there are placed or land, or if they'd be in the middle of the ocean :D)

The second issue is in so many words, having something big be made from something less. Now i personally don't know much about other solutions, but the most often used one is using PRNGs or pseudorandom number generators to create the world.
Often they are made hierarchical, like i could use one (with its own internal state), give it a seed, and that would generate 5 numbers, and use those as seeds for 5 other PRNGs, and those would generate different aspects of the world. Note that if you always give the same seed to the "root" PRNG, then you'll always get the same world.
You want that, and you want to not store all assets on your harddrive; that's the beauty of procedural generation, it sacrifices some time in exchange for less space... though overly complex stuff are usually not done this way, since it would take too long to generate them.
Keep in mind two things though, you need to consider that the generated values should optimally be in the same range as what the PRNG's seed is. The other is how to actually use the final random number in a meaningful way.

I won't post code either, because i can't at the moment, but i will say, that looking at [wiki]love.math.newRandomGenerator[/wiki] might help with the second point; as for the first, i can only say to experiment.

Edit: I'd also want to add, that you can proc.gen. individual parts of your game, or all of it as well, both separately or otherwise.
Graphics: going down to even the vertices of a model, though that may very well be overkill for a smaller game.
Audio: usually the folley/ambience/background music, not the sound effects, but that could be also
Dialogue: using dialogue trees or more complex structures, since those technically are procedurally generated for npcs; the paths taken, not the sentences themselves. (they could be though, but that would be more complex)
Game Rules: a not-really procedural example would be subsidies in Transport Tycoon/Deluxe/OpenTTD; an event where accomplishing the given goal will give you a bonus. A better example would be starbound's radiation/heat/freeze statuses on such planets; without gear, you'll get damaged.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Help with procedurally generated cities.

Post by bobbyjones »

The main difficulty I'm having is designing an algorithm that can make something look realistic. It's 2d by the way. I'll read the resources have provided and take a second stab at generating a city grid today. Which I think doing the grid first is probably the best way but I'm not too sure. What do y'all think?
Grubby
Prole
Posts: 35
Joined: Sat Jun 01, 2013 2:46 am

Re: Help with procedurally generated cities.

Post by Grubby »

I thought twice about doing this, but I have to point out that 'Cataclysm DDA' has been my dark secret addiction since long before 0A. Despite its initial hiccups and the fact its roguelike with almost no graphics to speak of, it proves a game/simulation doesn't need a high powered 3d engine to do the job. Actually, I doubt you could combine a 3d engine with the complexity of Cataclysm DDA and end up with anything good. Some things are timeless just the way they are.

--> Off soap box
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Help with procedurally generated cities.

Post by bobbyjones »

Anyone know of an algorithm that I can base my road work off of? And I watched the subversion videos and thats more or less what I want, but in 2d. From the frequency of his videos and posts I'm assuming the algorithm took a long time to do. So I would love a base to start off of.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests