What is Procedural Generation?

Procedural generation is the method of computing in which one generates data dynamically using algorithmic techniques. This is prevalent in many aspects of computing from basic data generation for system testing purposes to creating complex graphics or infinite worlds within a game. In the context of computer graphics, the focus of this series of blog posts, it may also be referred to as “random generation.” Let’s explore this in more detail.

We may think of procedural generation as either a complex system for creating massive amounts of data very quickly or as a more simple method for creating something such as a random string of characters to use as a password. For example, take a look at the code below.

function generateRandomText() {
    var letters = 'abcdefghijklmnopqrstuvwxyz';
    var letters_arr = letters.split('');
    
    var numChars = Math.floor(Math.random() * 26);
    var txt = '';
    
    for (var i = 0; i < numChars; i++) {
        txt += letters_arr[Math.floor(Math.random() * 26)];
    }
    return txt;
}

This code produces a bit of random text that one can use to perform various tasks such as entering data into a form. By calling this function, we are saying that we want to generate a string of characters where the length of that string is between 0 and 25 and only includes alphabetic characters. The output of the code when called three times is shown below.

generateRandomText(); // "xtgaenpcfplgudtfaahpksa"
generateRandomText(); // "sfbqlkdrrpdpsrtrbkdwsbxtz"
generateRandomText(); // "razkvrdzw"

While this code is simple, it does display some of the basic concepts behind procedural generation such as random length generation and computational determination of data. Almost all data generated this way is entirely random. Some purists may argue that because the above code is not based off of a seed and is completely random and as such one cannot ever expect to derive the same values consistently, it is not procgen. However, for the purposes of our exploration of the topic, it fulfills the basic requirements of the technique.

To recap, we can say that procedural generation is simply a means to produce a random amount of data for use in other programs or systems. The system in which the data is to be used can vary greatly, but the core principles driving the technique are usually consistent between applications.

Leave a Reply

Your email address will not be published. Required fields are marked *