We begin our learning adventure with the broad concept of PCG. The key word here is procedural. A procedure in programming, simply put, is an instruction to be executed. Procedures are the main paradigm in computer programming. A script you write in Unity is just a set of instructions or procedures we want Unity to perform.
You use procedures, methods, or functions as a means to communicate the instructions you want the computer to complete. We can use these same procedures to instruct the computer to generate content in many different ways. We can apply this idea to a broad range of programming disciplines such as data visualization, dynamic advertising, and so on, but in this book, we are using it for video games.
If procedural is the how then content is the what. Content can be anything we are presenting to the user. In our Hello World
example later in the chapter, our content will simply be text. However, video games have a wide range of assets that make up the content we want to deliver to a player.
Typically, we think of the levels, character models, and other art assets when we think of content in video games. But there is also textures, music, sounds, story, artificial intelligence, and more that together make up the content of a game. PCG is the concept or paradigm by which all these pieces of content can be generated with some well-written code. PCG can be applied to nearly all aspects of a game through scripting, and you will learn some of the main ways to do this throughout the book.
What's exciting about PCG is that we can let the computer take some of the responsibilities of the designer by giving it some instructions and letting it create parts of the game world on its own. We might even be surprised by the results. As developers, we usually do not like being surprised by our script's actions, but in this case, it's part of the plan.
PCG can also come in a few different forms for practical use. We can generate content from scratch, such as the texture see earlier, or we can generate assets from a set of premade parts, such as generating a tavern scene from premade props such as tables, chairs, barrels, and crates. Another option, though, is providing tools to the player to take on the role of creating content. The player creating content isn't necessarily PCG but you will have created a PCG system that now takes user input as a parameter. A great example of this is the popular game Minecraft developed by Mojang.
Minecraft is also an example of one of the most popular uses of PCG, randomization. Players in Minecraft can make structures and break down the land around them. However, the game's entire landscape is based on randomization. Randomization is used in many games, both virtual and table top. Randomness introduces a chance factor that creates fun out of unpredictability.
However, the most important thing about randomness in video games is that it is almost impossible to achieve true randomness on a computer system. This is why we refer to them as pseudo random numbers, because they are technically not random. We will explore this aspect of randomness, or pseudo randomness, later in the chapter with PRNs.