Pablo Armando Rodríguez Codes

AI programmer

Procedural Terrain Generator

This project was developed during an internship at the MIDAS research group of the Universidad Politécnica de Madrid, in collaboration with the company Lurtis Rules, during the first term of the last year of my BSc in Computer Science. The project was then continued during the second and last term as Final Degree Project. The project was chosen as it was something I could work on during my generalistic BSc that was specifically related to videogames and artificial intelligence.

The main goals of the project were, first, to show the potential of on-the-fly generation –that is, the ability to generate all the results on runtime from as little definition data as possible–, and second, to develop a tool with rich and dynamic interaction –i.e., with a wide range of inputs to allow the user to control the results in depth.

As a note, the tool was developed using a multithreaded architecture that is used, amongst others, by the level streaming system – the terrain is divided into chunks, and only the visible chunks are loaded and recalculated. The architecture uses coroutines to syncronize the different threads that perform the heavy computations of the different algorithms, abstracting them from the main thread so that the interaction with the UI is kept as fluid as possible.

The tool uses fractalized Perlin noise for the generation of terrain. The algorithm can be controlled using different parameters. Furthermore, the user can define different terrain areas, each one of them with its own values for the different parameters that control the terrain’s generation.

Example of the multiarea editor UI
Results for the given example of the multiarea editor UI

Several self-designed flooding algorithms are used for the generation of water bodies: rivers, lakes, seas, oceans…

Example of river generation
Example of ocean / lakes generation

Roads or paths can be generated using the A* search algorithm. The user can control the generated results by setting a maximum slope the path can have, or a penalty to the algorithm’s cost function for path sections that are constructed as bridges over water bodies.

Example of road generation
Example of road generation as a bridge over a water body