© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
C. PittProcedural Generation in Godothttps://doi.org/10.1007/978-1-4842-8795-8_1

1. Hand-Crafted Content vs. Procedural Content

Christopher Pitt1  
(1)
Durbanville, South Africa
 

There are many popular games that place the player in sprawling worlds. Examples of this are World of Warcraft and Red Dead Redemption. An interesting thing about these games is their hand-crafted content. A team of designers have worked to create every hill and valley. A computer made none of it via an algorithm.

Hand-crafted content is the kind of content that is intentionally made. This could be someone drawing a game character, or creating a 3D model of a car. It also includes the design of the game world, or smaller sections contained in it.

In this book, we’re going to focus mostly on designing the game world. If you’ve ever played a strategy game, the concept of a map will be familiar to you. It’s the space in which you build your buildings and command your units.

There are other games that build on this concept, though it might not be immediately clear. Each of Super Mario Bros’ worlds is a kind of map. The race tracks in Need for Speed are maps. If it’s a space you, as the player, can move around in, you can think of it as a map.

There’s a level of quality in hand-crafted content that only human hands can achieve. A predictable map also leads to environments and events that feel more natural to the player.

Let’s take a closer look at a game built on hand-crafted maps.

Example: Limbo

Limbo is a puzzle-platformer game, released in 2010. You wake up, alone, and need to solve puzzles to understand what is happening to you. It’s particularly memorable for its black-and-white color palette and sound design.

A grayscale image exhibits a toddler sitting on a stranded watercraft.

Sailing in Limbo

Limbo is full of interesting puzzles, each more difficult than the last. There are stretches of gameplay, where the player must navigate the world in limited time. This combines with stretches where the player can relax and sightsee.

This is possible due to the order of sections of the map and predictable layout of each section. Every playthrough is similar, and later playthroughs are easier if you recall the solutions to puzzles.

A grayscale image of a toddler child escaping from a spider.

Running from a spider in Limbo

Procedural Content Generation

When algorithms generate content, instead of a designer, we call this procedural generation. All procedural generation begins with a designer creating content, but the algorithm takes over at some point.

This content can take many forms:
  • Basic layouts that the algorithm can combine and rearrange

  • The functions that create these arrangements

  • Checks to ensure the generated content is acceptable

  • Functions that spawn player characters, nonplayable characters, and enemies into the generated areas

These will be the main focus of this book. This isn't an exhaustive list of things considered procedural generation, but it's a start.

Generated content has the potential to create limitless replayability for your games. A solo game developer can delegate content creation to a machine and focus on other parts of their game. The flip side to this is that generated content can also be messy, imprecise, and buggy.

It’ll also be harder to design the pacing, events, and triggers of your game well. You’ll need to balance these concerns to create a robust set of tools.

Let’s take a look at a game that demonstrates balanced procedural content generation.

Example: Oxygen Not Included

Oxygen Not Included is a colony management simulator, released in 2017. You start off managing three colonists, with varying skills and characteristics. I enjoy the humorous interactions they have with each other and the perilous situations they can find themselves in.

An interface from the colony management simulator, oxygen is not included.

Supervising in Oxygen Not Included

There are two main kinds of starting data that Oxygen Not Included uses to generate its maps from:
  • The starting area, where everything is safe and there’s a bit of water and oxygen

  • The configuration of a handful of structures that later aid the player in expansion

The rest is a rich generation algorithm that builds beautiful worlds to play in. Every playthrough is different. That is, unless you recreate the exact same world on purpose.

The interface of the management simulator, oxygen is not included, It includes the asteroid details and the immediate surroundings dialog box.

Selecting a seed in Oxygen Not Included

Newer versions of the game have added more world options, but it’s still generated content at the core. When you start a new game, you’re faced with an array of questions:
  • “How will this new map look?”

  • “What geysers will I have around me?”

  • “Will this map be easy or hard to survive in?”

This is what makes the game so enjoyable and replayable. It’s all thanks to the robust content generation algorithm.

How Much of Each?

Perhaps you’re wondering how much content you should design and how much you should generate. It’s a good question, without an easy answer.

Crafted content will usually be higher quality than generated content, but it’s also more expensive to make. If you’re building something on your own, you want to figure out how much of it you can generate.

Same thing if you’re entering a game jam.

We’ve already seen a good example of how you could mix them in Oxygen Not Included. There will be sections of your maps that you want to be safe, or to host a special event. You should craft these to avoid complexity.

You could generate the rest, or you could even use crafted sections combined in random ways. There are many examples of this last approach.

Example: Diablo 2

Diablo 2 is an action role-playing game, released in 2000. It’s a story-rich game where you are a warrior of light, battling an army of darkness. It’s memorable for its dark atmosphere and gothic aesthetic.

The remastered version was released in 2021.

An interface of diablo 2 game.

Slaying demons in Diablo 2: Resurrected

Diablo 2 has a mix of crafted and generated content. It takes place in five main locations of a fictional world.

Each location (called act) has its own look and feel. The acts are also broken up into a set order of smaller sections (or zones), each with their own visual traits.

For example, act two has a desert theme. You begin your adventuring alongside sand dunes and decaying limestone structures. One of the zones takes you deep into an underground tunnel system. Another takes you into the city’s dark sewer system.

A simulation game interface from the revived Diablo 2.

Exploring the deserts of act two in Diablo 2: Resurrected

These areas are full of interesting crafted assets, randomly placed and weighted. There’s only one entrance to that underground tunnel system, but you’ll have to discover where that is each time you load the game.

The game has a fast-travel mechanic, which you access through randomly placed teleport platforms. Finding these, and the entrances to special story areas, is a core part of the game’s mechanics.

Yet each act starts you off in a crafted safe area. These are always the same, so you can quickly navigate them on your frequent trips “back to town.”

An interface for a dialogue window in a safe zone in Diablo 2 resurrection.

Starting (safe) zone of act five in Diablo 2: Resurrected

The typical structure of each act and zone varies, but here is a non-exhaustive list of zones in act one:

A flow diagram of a criminal camp serves as the basis for the game's numerous basic graphics.

Crafted and generated areas of act one in Diablo 2: Resurrected

There are definitely more generated sections of the game, but the crafted sections help to connect them together. They are the setting for important events in the story.

Most of the enemies you’ll encounter are randomly generated, but each type belongs to a specific zone or act. You encounter simple skeletons and zombies in act one, lightning beetles in act two, tree ents in act three, etc.

Some zones have a high chance to spawn special enemies. In the Stony Field of act one, you will always encounter a special enemy called Rakanishu. He guards the entrance to Tristram and has a lightning attack.

Each act has a handful of these special enemies, as well as a final boss. The final bosses are also in crafted locations. Generated loot drops from slain enemies, with a small selection of crafted items, called legendaries.

Where We Go from Here

We’re going to build a toolset that balances crafted and generated content. That means we’ll create some crafted assets and combine them in ways that can lead to random configurations.

We’ll learn how to build explicit seeding systems, as seen in Oxygen Not Included, so that friends can share experiences with us.

We’ll learn about things like tile maps and nodes and how to make them interact. We’ll learn about how to inspect generated maps to be able to figure out how to answer questions like
  • "What is the right direction to move it?"

  • "How do I get over to that part of the generated map?"

  • "Where is a good place to spawn enemies?"

We’ll learn how to make click-to-move, keyboard-based, and path-based movement.

As we learn more tricks, we’ll recreate games from different genres. By the time you're done reading this book, you'll have made four different 2D games.

Buckle up!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.216.163