Sunday, 12 May 2013

Hanging the Floor

One of my favourite games and big inspirations for this project is a game by Tarn Adams called Dwarf Fortress. The game includes procedurally generated worlds that are so detailed and rich that there's a game mode specifically dedicated to reading through the historical events of the kingdoms. This is the game that enlightened me to procedural generation (from here on called PG) which has quickly become one of my favourite aspects of game design and programming.

How much do I like it?

I used a random title generator for this entry.

A Grand Design

In a game like Wanderer, exploration is key to the premise. Procedural generation allows the player to explore a new world each time they play the game which is obviously integral to a game about exploration and survival. This is the primary strength of PG, it keeps things fresh and, in the appropriate genre, is almost required.

Procedurally generated worlds have drawbacks though. It's impossible to reach the level of intimacy that a handcraft world possesses. The landscapes of the Half-Life franchise wouldn't be nearly as memorable if designed by a computer. On the contrary, Half-Life 2's big strengths were it's memorable set pieces and attention to detail. No algorithm could possibly recreate Half-Life's Ravenholm.

In regard to The Wanderer, I plan to and already use PG for certain aspects of the game. I don't think I'll ever manage the level of detail exhibited in Dwarf Fortress but I don't think I'll ever be a playboy billionaire either. I keep my expectations grounded.

The Here And Now

Pictured: A screen shot from The Wanderer.

Right now, I use PG to generate the game spaces available for the player to explore. I do this by splitting each map into a grid of 8x8 blocks. Each space in the block is a 16x16 pixel spaces. Each block then checks if there should be a building in that position or if it should be blank. Once the generating function decides there should be a building, the game fills in the 64 spaces appropriately.

Each space has a different probability of being taken by a wall. For example, spaces next to filled spaces have a higher chance of being filled and edge spaces have the highest chance of being filled. This is done to give each building a more distinct man-made (irony...) shape while still creating a damaged, post-apocalyptic level.

While filling in the building with walls, empty spaces can be filled with ghouls and caches of food and ammunition. This is the final step in generating a building. Once this is completed the generator moves on to the next block.

When transitioning between levels, the maps have to be stored in the game folder so that the player can return to areas already explored. This is done by storing the grid information in a ".wap" file (a portmanteu of "Wanderer" and "map". I'm super creative.) The title of each .wap file is a designation used to keep track of that level's position on the meta-map. "0_0.wap" indicates the starting space while "-999999_0.wap" indicates the map generated if the player is masochistic. The game keeps track of the player's position on the meta-map to save and load files appropriately.

All of the above processes unite in the elegant (yeah right) system currently in place to generate Wanderer's game world. The game world size as it stands is only limited by the hard drive space of the user. Beat that, Skyrim!

Into the future

In the future, I plan on using random numbers for far more than simply map generation. The next step is to add an inventory and weapons system to the game and I can assure you that I'm not going to design any of the weapons personally. Beyond that, survivor camps, different structures, enemies and beyond all look attractive to my hunger for surprises (Maybe I should just design a random game generator?)

Inventory is definitely the next step in adding depth to the game. Right now, playing Wanderer feels very shallow. Not totally unexpected of a game developed in a week and a half but something I definitely want to fix. Whether people play this game or not, I want it to be a game someone would want to play.

Overall, procedural generation is going to be one of the fundamental features of The Wanderer. It's going to allow the player to explore new spaces and experiences in order to keep the game fresh each play through. The PG currently featured in The Wanderer isn't exactly as sophisticated as it gets but it works and can be expanded upon in the future.

On Frequency

After my initial torrent of blog posts I've slowed down my contributions quite a bit. That's probably a trend that is going to continue. I don't want to force these posts which means I only contribute when something has inspired me to write. This post was inspired by finishing the map saver and loader.

What I'm trying to say is, if I ever get tired of this I'll make sure it's known.

One Last Note

You know, the more I think about it, the more fitting the generated title seems.

1 comment:

  1. TL:DR Near infinite randomized maps.