clock menu more-arrow no yes

Dwarf Fortress will crush your CPU because creating history is hard

New, 52 comments

Building worlds in ASCII

Like much of the collection at New York's Museum of Modern Art, Dwarf Fortress is a baffling, inscrutable mess. But with proper interpretation, even the most intimidating forms can provide for moments of admiration.

Polygon sat down with one of the creators of Dwarf Fortress, Tarn Adams, to talk about his work. We wanted to take just a piece of the whole — world creation — and unpack it. To make it digestible.

And in the process we found a whole new respect for the game.

Df_magma

The opening cinematic of Dwarf Fortress.

I met a traveller

Dwarf Fortress has been made over the last decade by Tarn and his brother Zach. Version .40 was just released a few weeks ago and the focus of the game is, as it has always been, enabling players to lead a small colony of dwarves in building a fortress. But while other game designers would spend hundreds of man-years slaving away on graphical assets, the Adams brothers have devoted themselves to developing systems.

And it's in these systems that the beauty of their game lies, systems that are capable of generating in minutes worlds that contain more richness than some entire game franchises.

So how does it work?

In the beginning, when you first install the game, there is nothing.

In the beginning there is nothing.

Then, at the push of a button a complex fractal generator divides the oceans from the land and calls into existence an area about twice the size of New Jersey.

The software then throws it out, and keeps generating 16,000 square mile chunks of real estate, each one 250 miles thick, until it gets the right distribution of elevations. Adams is looking for just the right amount of high points and low points to make the place interesting.

But this is just the shape of things. Adams has, over the years, developed an intricate process to simulate eons of complex geologic time, a way of stacking fractal layers and blending them with algorithms to give life to each world.

In an instant Dwarf Fortress calls into existence a region twice the size of New Jersey. And then throws it away.

The first layer plots the annual rainfall of each map location. Then a separate fractal simulates the deposition of mineral elements throughout the underground strata, giving the land itself a kind of texture. A temperature fractal is generated and rough biomes emerge as contiguous tiles on the map that contain a subset of closely related flora and fauna.

The order here is important, because in the next step — drainage — Dwarf Fortress begins to simulate the complex forces of erosion. Only after the biomes have been created can the rivers run, slashing deep valleys as they flow toward unnamed oceans. When they finally meet the sea a salinity algorithm kicks in to define the areas for swampy river deltas, alluvial islands and mangrove swamps.

At one time, Dwarf Fortress' natural world stopped forming here, but Adams has added something in recent years to give each one a little something extra.

The lone and level sands

In his research for the game Adams learned that in the real world when warm, wet air travels up the side of a mountain it loses moisture. Rain precipitates out creating areas like rain forests and snow capped peaks. On the other side of the mountain deserts form in areas that are called "rain shadows."

So Adams built a custom algorithm that simulates rain shadows in Dwarf Fortress, and if you watch carefully you can see it.

The whole map will shudder and shift, just for a moment. All the biomes suddenly snap, a dramatic shift from east to west. Some shrink, others expand. Deserts appear out of nowhere. That's the rain shadows kicking in.

The story of Sazir Stockadebolt, the "Confining Spell"

The land was called Teyo Quico in elvish. It means "The World of Cyclones."

Born into this world, in the year 89, was a dwarf named Sazir Stockadebolt. When she was just one year old she was abducted from her people, who were called The Ancient Spears, by a crazed dwarf woman.

She was brought to live in the dark fortress called Dangleplague. There she was raised in the company of goblins.

When she was 12 years old she was married to Onol Minedclapped, another dwarf who had been abducted and forced to live in Dangleplague. But just two years later, Minedclapped was murdered by the dwarf Ber Toursink.

The horrible crime pushed Stockadebolt over the edge of madness. She joined the goblin hordes, trained as a sword fighter, and joined them when they marched into battle.

The War of Ignition was fought over eight long years, ending in 149 in a cataclysmic battle against her own race.

Together she and her goblin brothers killed every single member a dwarf people known as The Earth of Infamy. After that campaign Stockadebolt was promoted to be the general of the goblin army. Her faction became known as The Maroon Nightmares.

After The War of Ignition, Stockadebolt journeyed to the depths of the world where she tamed a cave dragon, a beast which she rode into every subsequent battle she fought. Her victories include The War of Ignition, The Conflict of Growling and finally The Siege of Cuts.

In 195 she was murdered, like her husband before her, by her own kind; a dwarf by the name of Urdim Passoars. She was 106.

But her story lives on. Along with 57,283 other historical figures, all of whom have similar stories to share.

In the future, Adams hopes to add plate tectonics. When he does entire regions of the map will be able to cleave against each other to create fissures, or smash into and over each other to become mountains.

"If we had land going up and down," Adams says with a sigh, "maybe none of this would be necessary."

By this point in world generation the game is using something like half of a modern quad-core computer's total CPU power. It will hold there while it begins to spool up the maximum allowable amount of RAM that the game engine's 32-bit software will allow. And it's just getting started.

After the map has been locked into place, the game assigns a kind of energy to each region, ranging from good to evil on a scale of one to 20. It then uses the positive and negative energy of each area to generate place names — The Ocean of Muting sit along the edge of The Jungles of Mire near the Ivory Hills — and on and on creating hundreds of uniquely named regions.

But these are just the names as translated for the player. Adams says that each area of the map has been named by one of four cultures. Human, dwarven, elvish and goblin languages are actually programmed into the game.

Eventually, he hopes that the game will be able to procedurally generate languages as part of world creation, but for now it's working off very large lists of words.

"There are evil words and good words in each language," Adams says. "It chooses names based on those. The dwarf language will be used to name things that have more artifice, and the elf language will be used to name things that are more natural, and wild things and so on."

And it's not done yet.

"Then it places all the little features," Adams says, "like the caves and monsters and the starting points of civilizations. And after that it gets significantly more complicated."

The world's history begins to play out, a week at a time, for 250 years.

Towns grow and flourish, only to expand into the wild and and conflict with their neighbors. Leaders rise to create dynasties, which then fall into ruin. And you can watch it all happen before your eyes; hundreds of thousands of creatures live and die in seconds as little more than flickering ASCII shapes.

"They have their farms that all go on this yearly cycle and give them actual food numbers," Adams says. "When you see a city shrink down in size, the people have either moved away or they ran out of food. Every object that is made is tracked."

It's this kind of detail that gives Dwarf Fortress an impossible richness.

For instance, when you travel to certain cities in the game and speak to a merchant they might tell you that their leather caps are made in an elvish city half a world away. And it will be true. They really were made there, during world creation, and traveled to this market for you to buy before you even started playing.

Kobold_swordsman_zombie_seige

High drama: A kobold swordsman breaks through a line of zombies at a river crossing. Via Reddit.

Look upon my works, ye mighty

"But that's just the trade system," Adams continues. "There's the whole diplomacy and war thing going on as well. Civilizations make very simple decisions about what they want to do. They just look at some population numbers and where they are and so on.

"The personalities of the different rulers are all determined in advance," Adams says, referring to the matrix of 50 different character traits that, when balanced by each individual's personal and cultural values, aims to simulate their thought process.

"They use their different personality facets to decide whether or not to go to war."

But this isn't just history for history's sake. After the world generation is complete you can start the game in Legends mode. Here players can spend time digging into the life story of individual people.

"Damn. I just popped up a world there. ... Maybe that's how people feel when they see Dwarf Fortress and the things our players do with it."

Players can even export the game data to a fan-made program called Legends Viewer, which generates a hyperlinked database of people, places and events. It allows players to track the progress of wars, the rise and fall of individual frontier fortresses, and even dig down to read the battle history of infamous creatures large and small.

It's important to Adams, and to his players, to have all this backstory in place before the gameplay even begins. After all, he says, you have to, "keep track of which historical figure was dragged into a night creature's lair so that you can find their body parts simmering in the cauldron."

From start to finish, world creation takes a little under two minutes. Faster for a smaller world, and much much longer for a larger one. Dial the history of the world up to over 1,000 years and the whole process can take 20 minutes or more. Just to make a map for you to play on.

The complexity of it all is something that Adams has gotten numb to over time.

"I guess you get inured to it," he says, sounding tired. "It is cool to sit back and watch. Especially when I haven't done it for a while. I go and test it and I'm like, damn. I just popped up a world there. ... Maybe that's how people feel when they see Dwarf Fortress and the things our players do with it.

"For me, it's the culmination of stuff my brother and I have been dreaming of doing for 20 years."

Edit: You can snag a copy of the Dwarf Fortress soundtrack here.