Procedural content generation: a practical approach
Procedural generation sounds great at first. Generating infinit content, the dream of every designer (or nightmare if your job get obsolete). But the reality tells an other story. Once you start developing your own procedural content generation you will realize quite fast, that most of it is just boring. The issue is, that players want meaningful content, not just huge amount of random content, and getting meaning into procedural content is really hard.
But it depends on where the player seeks meaning, and this depends on the human nature, where we as human individual seek meaning.
Lets start with a forest. When you walk through a forest, the meaning of this forest could be a location where you can feel good and free, a safe habour, a place you know. There's a natural order in a forest, the distance between trees, the light which reaches the ground determines the vegetation, but most people will not count the leafs on the ground, because the forest arised in a random manner depending on some existing parameter (i.e. biome). This is something we can try to capture with procedural content generation quite easily.
On the other hand think about an university. A great campus, with many buildings, different field of research gathered in only one or two building complexes. The cafeteria, parking slots, means of transport are structured in certain ways, sometimes in a logical way, sometimes historically based. Even if it is easy to generate buildings, streets, parking slots etc. it will be hard to generate a meaningful combination of it to represent an university. This introduce two difficulties, first how to generate something which has been designed by humans and how to combine smaller meaningful parts into something greater without loosing the meaning. Think about a parking slot, which has the meaing of, yeah, park your car to reach your destination on foot. Generating the parking slot 25 km of your destination would loose any meaning, on the other hand adding a fast traffic connection between parking slot and target destination would introduce a meaning.
The first class of PCG, natural content like forest, terrain, islands is easy, but the second class of PCG, human designed content, needs more engineering.
A practical approach is to start with designed content and try to break it up and recombine it in a meaningful way. The trick is, to start with designed content and don't try to generate designed content first.
In our campus example we would divide the campus into different areas like parking slots, mensa, research complex, inhabitants, traffic stations etc. The second step would be to define rules of combinations, i.e. the parking slots should be near the research complex, the inhabitants needs a connecting to traffic stations etc. When done, pick a part and try to break it up in a similar way, i.e. the inhabitants, they could be made up of different building types, a supermarket, a small park etc. This way you break up your target content in a top-down manner, but sometimes it will really hard to break it up any further.
The rescue comes in form of templates, that are small, meaningful, designed pieces of content. That's it, don't try to break up everything, sometimes it is much better and easier to design a bag full of meaningful templates instead of generating complex, chaotic, meaningless content.
Implementation of the rules are the hardest part. Different content will require different rules which will eventually requires different algorithms and approaches, there's no best way to do it. But I found graphs really useful when recombining structured data. There're lot of graph algorithms (i.e. kruskal, dijkstra, A* etc) around which will help you to solve certain problems.
- use designed content in form of templates
- design rules of combinations
- work top-down, not bottom-up
- never loose the focus on meaning