More and more developers are leveraging the benefits of procedural world generation techniques for their games. It provides many valuable benefits for gameplay, but can wreak havok on AI decisions and behaviors. AI for platformers is not the most complex there is (by design), but still the quality of the underlying world has a huge impact on the perceived believability of the enemies — as Arcen Games found out while making A VALLEY WITHOUT WIND.
On Sunday, in a live interview broadcast via AiGameDev.com, the game's Lead Developer Chris Park presented the techniques behind the procedural generation of the terrain and building, and how they affected the AI behaviors. In particular in this article, you'll see examples of how procedural generation was originally a problem for A VALLEY WITHOUT WIND, and how Arcen Games resolved these issues.
Screenshot 1: Example generated landscape for the Craggy Highlands area of the game. The Grey color represents the sky, Red is the landscape, and Beige is underground cave area.
Layers of Detail... and Complexity
During the interview, Park explained how the entire game is procedurally generated — from the high level world map to the individual levels.
“There's a world map that's a 2D top-down view, which is generated procedurally a continent at a time as you play. Each tile in the world map is what we call a region. A region is a series of surface chunks, and each chunk itself is procedurally generated with several layers within that.”
On top of this, each part of the game is itself built from layers and layers of processes that combine together to increase the detail and richness in the world, as well as fix possible problems.
“For the exterior terrain, we have overall about a dozen algorithms, and a lot of those take specific parameters as range values. [...] There are also hundreds of rules applied to each phase.”
Compared to manually designed levels, it's the potentially random nature of the environments that cause most challenges for the AI.
Screenshot 2: Example of a landscape from the game itself. A VALLEY WITHOUT WIND generates many layers of structure in the world as well as overlaying detail onto it, in this case a landscape with vegetation.
Enemies and Procedural Generation
As Park explained in the technical interview, it can be particularly challenging to spawn enemies in the right location.
“Your game has to be able to say, this T-Rex would not do well in this narrow stairwell because he's going to get wedged... How did he get here in the first place? But we had beta players report T-Rex's stuck in corridors trying to walk under a low ceiling. That's not really an AI problem; what would you expect from a tyrannosaur in such a tight space? But unfortunately it looks like an AI problem!”
In these cases, as Park continues, it's a procedural seeding problem. That dinosaur had no business being in that hallway in the first place! As well as some enemy design tricks, A VALLEY WITHOUT WIND uses a wide variety of different filters to detect if indeed an enemy can be spawned in that specific location.
“There's another set of algorithms, unrelated to the procedural generation code, that use meta-data from the initial phases to decide how to place enemies. Some tiles have meta-data that indicate what can sensibly be spawned at this location.”
These specific annotations must also be added automatically, and they formed a significant part of the algorithms used to place the enemies in sensible locations. Arcen is planning further updates to A VALLEY WITHOUT WIND, and as the community of players report bugs, Park continues to adjust this part of the code.
Screenshot 3: The tool used during A VALLEY WITHOUT WIND allows each of the steps to be visualized, including those that setup the spawn opportunities for the enemies.
Sensible Combat Space
The process of creating a level that's suitable to the AI is very similar to the rest of the process of creating a procedural generation algorithm. It involves lots of design, speculation, testing, tuning and not least iteration.
In the remainder of the interview, Park talks about many of the aspects of the procedural generation in more details, including:
- Why using a separate tool to implement is essential to get the algorithm looking and playing correctly.
- What the benefits are to splitting up the generation into two distinct phases of generation and clean-up.
- How to optimize the procedural generation to take on average around 600ms on modern hardware.
- When to integrate human-edited patterns or sub-parts to make sure the result is believable.
If you have any questions or comments about generating worlds (or platforms) that are suited for AI enemies to show off their behaviors and entertain the player.