Chapter 11 More Interesting Dungeons

Hands-on Rust — by Herbert Wolverson (80 / 120)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Wrap-Up | TOC | Creating Traits 👉

It’s the hero’s twentieth descent into yet another dungeon in search of the mythical Amulet of Yala — not surprisingly, both you and the hero are bored. Despairingly, the hero cries out, “Surely, not every dungeon is a bunch of rectangular rooms with dog-leg corridors?”

So far, your dungeons have all used the same room-based generation system that you created in Chapter 5, Build a Dungeon Crawler. This system works, but it makes for entirely predictable — maybe even boring — maps. So, how do you generate a map where the player can explore a field of underground fungal trees, a sprawling city, or a dark forest? As it turns out, there’s an entire field of game development known as procedural generation that’s built around using algorithms to create exciting environments like these — and game developers have been using it since the 1980s.

Using different procedural generation algorithms allows you to inject variety into your game. Rooms and corridors look designed, implying a sentient builder. Other algorithms generate a more natural-looking map. Varying the map keeps the player interested.

In this chapter, you’ll learn to use traits to easily substitute your room-based generator with other map builders. You’ll learn two of the more popular map generation algorithms — Cellular Automata and Drunkard’s Walk — as you learn how to place…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.