Procedurally Generated Content in Crooked

New releases and general discussions.

Post » Fri Mar 13, 2009 10:39 am

Much like the original discussion of procedurally generated content at the Game Developer's Conference by Will Wright was an excuse for him to show off Spore, this is going to be an excuse for me to show off my work. :P

I'd asked a few months ago if dynamically generated content was possible in Construct and got some mixed replies...it took me a few months to nail the game idea, which obviously has a bearing on progress towards completing it. Needless to say, after nailing the aforementioned idea, and realizing my game was going to be set in the modern era - 1930's to now possibly - not sure exactly when - I set off to make a city generator.

The entire map is held in a 100x100 square array which I feed into a loop to display on the screen. The sprites you see are just 10x10 pixel sprites of solid colors, eventually I will make them about 128x128 and give them art.

The generation process consists of four steps. First I fill the array with blanks, pretty simple. Second is the longest step - the roads. I start out by making a dual lane highway, which right now will always form a cross. Eventually there will be the possibility of straight and maybe turning highways. Then the program will pick a random highway or road, decide what directions are possible for it to go from that point, then branch off in a possible direction and keep going in that direction until it hits something - another street or the boundary of the map. A process which is a lot easier said than done in Construct events. :shock: This process will loop about 20-40 times until you get a grid similar to the one you see. The third step is that blank buildings are placed at random along these smaller roads, they don't cluster yet but they should. The fourth and last step is probably the second most complicated one. RCI - Residential, Commercial, Industrial - which is probably a term some of you remember from SimCity. My game is not a strategy game, but for realism I will need these various facilities and thus thought it necessary to add them. The game will choose centers for each zone, and spread the zones into the blank buildings by proximity to these centers...the ones furthest from the centers will be considered "Light Residential", "Light Industrial", or "Light Commercial". Those are the lighter colors you see.

Ladies and gentlemen, I present to you, in no certain order: Brightbourne, Whitemere, Lakegate, and Mossbridge. Four cities I generated in about one percent of the amount of time it took me to make this picture and write this post.



All of which you may or may not see in my game Crooked sooner or later, depending on how the generator treats you. Crooked is going to be a combination of Trilby: The Art of Theft, Zelda 2, and Spelunky - in that order. That is, assuming I ever finish the game. :D



Yes...I exaggerated the logo specifically to let you know it's pronounced with two syllables. But back to the subject at hand, procedural generation. A few things I've learned so far. I looked on the web for algorithms, and ended up not finding any...you won't really, especially if you have specific needs. Even if you did find one, it's not going to translate into Construct very well, because Construct is almost conversational in implementation. You just have to imagine how you would draw it, or how it would be. I opened up paint, drew up some roads, and realized I was using 90 degree angles from random points, and that's where I began. Thinking of things literally in that way made it much easier to translate into Construct than trying to think of it mathematically or programmatically. Another thing - doing natural generation has to be a lot easier than doing man-made stuff I would imagine. Random terrain must be a snap compared to this. Anyway, if any of you have any questions, tips, or suggestions, please leave them.

Edit: Posted in general because I don't have a cleanly commented *.cap to upload yet, and while I have plans on making one - this isn't a tutorial yet either.
B
5
S
2
G
5
Posts: 221
Reputation: 2,272

Post » Fri Mar 13, 2009 11:09 am

Seems really cool and if it works well im very very interested and when you are ready to publish it please do it as freeware :P
B
11
S
3
G
4
Posts: 622
Reputation: 3,186

Post » Fri Mar 13, 2009 11:27 am

HELL YES. I've been a huge advocate for procedural generation, because it is capable of absolutely incredible things, especially in 3D. Interesting city generation thing... I wonder how procedural terrain generation could work in Construct while actually looking nice?
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Fri Mar 13, 2009 6:15 pm

[quote="Candescence":2fp0wu39]I wonder how procedural terrain generation could work in Construct while actually looking nice?[/quote:2fp0wu39]

lol arsonide your thing doesn't look nice :P

At this point it's pretty much purely an algorithm. He does plan on making each building/road/etc a tile (or 3D box as the case may be).
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Mar 14, 2009 3:07 am

[quote="deadeye":3kzt2gbp]
lol arsonide your thing doesn't look nice :P

At this point it's pretty much purely an algorithm. He does plan on making each building/road/etc a tile (or 3D box as the case may be).[/quote:3kzt2gbp]
The algorithm is the hard part, applying art to those little dots will be a snap.
B
5
S
2
G
5
Posts: 221
Reputation: 2,272

Post » Sat Mar 14, 2009 5:51 pm

http://www.youtube.com/watch?v=GlXVgtlCHPM - Whabam! A snap I say! Whipped this up before work specifically for deadeye.

Wish I could keep working on it, but unfortunately Construct requires a running computer - and therefore electricity - and therefore money.
B
5
S
2
G
5
Posts: 221
Reputation: 2,272

Post » Sat Mar 14, 2009 6:25 pm

Looking pretty good so far, man :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Mar 14, 2009 9:06 pm

While a good start, you need curves in order to keep the world from being too boxy. I do procedural generation all the time (I work on cell phones) and the simplest way to add curves to your system is with partial circles.


You just need to generate a circle starting at point A and then at the opposite side, point B. The red portions of the circle are what you can erase or ignore, and by doing so you have a curved road.

Might take a while to get right, but having curves will make the world that much more enjoyable.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Sat Mar 14, 2009 10:02 pm

Or one quarter of the circle for gentle turns. But how do you define a circle in a 2D array without it looking ugly? Especially if you're using low resolution arrays.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Mar 14, 2009 10:18 pm

Don't actually draw the circle in the array, just the key points of it.

I guess I don't know exactly how he has his system set up, maybe he would need a second system for curves, but the point is to just use the array for key points in the circle (NSEW).

He is applying art to the array, so I would imagine he can work out a way to place the circles correctly.

For example, he could make it really easy and just set a few sizes (like 4) and then just line the correct art up to the points of the curve.
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest