PDA

View Full Version : Procedural Content


Aztlan.Games
07-21-2011, 10:47 AM
Hi everybody,

I would like to get your comments and feedback on procedural content. There are a couple of titles in the App Store, which work extremely well without levels created by a level-designer. Some of you might know that Tiny Wings is for the greater part procedurally generated, which contributes to the high replayability, because every level is unique. And I think that Doodle Jump relies a lot on precedurally generated levels.

Thinking back to developing my last game, I remember painstakingly and painfully creating 45 levels by hand. This somehow influenced my decision a lot to have a look at procedurally generated levels for my next game. For Vermes on Mars (http://forums.toucharcade.com/showthread.php?t=100850) I decided to give it a try and take a portion of the time I would have spent on level design and invest it in coming up with a good mechanism for generating levels automatically.

Procedural generation has a couple of advantages and disadvantages. If you come up with a good method you save a lot of time. This is especially crucial if you do not have that much manpower as it is the case with a lot of indie developers like myself. Procedural generation, once implemented, gives you a powerful tool to quickly generate a huge number of levels.

For me, procedural generation saved indeed a lot of time and provided a lot of fruitful ideas and insights.

In the following, I will give a brief explanation on how levels are generated in our upcoming title Vermes on Mars.

In Vermes on Mars each level is a 2d Martian landscape. Generating such a level has several phases:
1. calculating a very low-res representation of the map
2. increasing granularity by resizing and blurring, which will yield a heightmap, and
3. using the heightmap to compute a very big terrain texture.

Calculating the low-res representation is as follows. A starting width and height is calculated, both are random values. For example width = 10 and
height = 9. The representation is represented by a 10x9 matrix. For each cell in that matrix I then randomly assign a value. Either the cell is an obstacle or it is not. This could look like this:


O.O.O.OOOO
.O.OOO.OOO
.OO.O.OO.O
O.O.OO.OO.
..OO.OO.O.
O.O.O.O.OO
O.OO.O.O..
.O.OOO.OOO
.OO.O.O.O.


Each O is an obstacle, each . is free space. After that I apply a cellular automaton on the matrix, which would than reorganize and create islands. The result would be this:

OOOOOOOOOO
OOOOOO.OOO
OO......OO
OO......OO
OO.....OOO
OO.....OOO
OO...O.OOO
OOOOOOOOOO
OOOOOOOOOO


Now there is plenty of open space in the center of the map. For bigger matrices the result would have been more complex.

In the next step create a heightmap from the matrix by resizing and blurring. This would yield:
http://www.aztlangames.com/wp-content/uploads/2011/07/Heightmap.png

The brighter a pixel the higher the terrain is at that position. White areas are obstacles.

Now I only have to map the heights to colored pixels. I use this lookup-texture:
http://www.aztlangames.com/wp-content/uploads/2011/07/Tiles01.png

For the white pixels I use the dark brown patch, for the black pixels I use the yellow patch, and everything in between is smoothly interpolated. The outcome is:
http://www.aztlangames.com/wp-content/uploads/2011/07/Texture.png

In the game it looks like this:
0ydQrfyFUxs

So, what do you think about procedurally generated content?

ImStrapped
07-21-2011, 01:05 PM
Hm, one thing I don't like about procedural content is the lack of customization and design that can go into it however, I really like your approach here, I think you've done a great job at using procedural content to great a game I'd never guess was auto-generated. Very creative.

awongulous
07-21-2011, 02:13 PM
I've been reading up a lot on Procedural Content and found it pretty interesting when I saw Lost Gardens was using it with their maps. I have yet to integrate something that sophisticated but I am trying to create some random segments in my next game. (Similar to Canabalt.)

Charybdis
07-21-2011, 06:01 PM
Here is my view on the subject:
I am a huge fan of procedural content. And I want to use it a lot.
However, the choice of whether on not to use it depends on the situation.
My latest game 'BlibBlob (http://forums.toucharcade.com/showthread.php?t=101111)', is a platformer, and the level design is a very important part of the fun. It requires creativity and subtle tweaking. I dont believe I could write a function to do that.
However, procedural content has the benefit that each level can be stored as nothing more than a handful of random seeds, or can be arbitrarirly long.
So, in conclusion, I will use procedural content as much as I can but I know that occasionally I will have to resort to map editors.

GlennX
07-21-2011, 06:38 PM
It is possible to do a bit of both. The levels in my first iOS game, Ground Effect, are fractal islands which then have the spline based road blended with them.
This screenshot (http://2496300914985353506-a-1802744773732722657-s-sites.googlegroups.com/site/glenncorpes/ground-effect-development-1/Picture%202.jpg?attachauth=ANoY7coBL8fzWpRRq0Z8esh OSA0q_dnOmndmhHrZsDm_Vsp02LOfVnFCFhU-u9C99JjUEDD6e21EAKa5aYal79oBczvPQYx99-2bVF9N8l6IShsYApCkeNibAR33yyVJrRs0G4uVM9knu-BHvIxtvgxKsPankahtZwo-kYlMxn-Q77yIZMTbnKXMhMzd_TWZ-2t_k8sR0WdZu0ucSkkDQtp6GGum8jSxiAtEGtwtoRdkn7n6s1a F7x0%3D&attredirects=0) shows the editor.The levels is completely fractal with the red/green/yellow/black line the only edited part, the colours denote how the spline is blended with the fractal at any point. Ground Effect levels are a 512x512 floating point heightmap but only take a few thousand bytes each on disc.

Aztlan.Games
07-22-2011, 10:58 AM
I think there are a couple of cases, where procedural content would be aweful. In other cases procedural content would be awesome. In the rest, hybrid strategies would work fine.

GleenX, I like your editor! Generating landscapes is a huge thing when it comes to procedural generation. People did a lot of work there!