Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: What in the world gen is procedural and what is random?  (Read 1821 times)

Nagidal

  • Bay Watcher
    • View Profile
    • My gaming channel
What in the world gen is procedural and what is random?
« on: January 03, 2017, 12:38:36 pm »

I'll be making a 5-minute short presentation about Dwarf Fortress for the general public. I decided to include a few sentences about the world generation. That's where I noticed that I don't exactly know what parts of it are procedural and what are random.

I usually don't fool around with the world gen parameters, but I think I saw people talking about world gen seeds on this forum, so I conclude that there is something procedural about world gen.

Are any parts of Dwarf Fortress world history random? Like names, historical figures, forgotten beasts, battles, maybe the whole course of history? Can it happen when you procedurally generate a world from the same seed, it will look geologically the same but the toponyms will be different, the civilizations and their diplomatic relationships will be different, maybe even the locations of cities or ruins are will be different?

A thing I noticed is that sieges, ambushes and were-beast attacks are somewhat random. I once suffered a game crash not long after such attack and when I recovered the last save from the season before I noticed another such attack happening at about the same time, but with slightly different creatures.
Logged
I stream most of my DF sessions: gaming.youtube/nagidal146, they are archived on my youtube channel. (Dwarf Fortress Tutorials)

PatrikLundell

  • Bay Watcher
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #1 on: January 03, 2017, 01:45:15 pm »

Given that there are no such things as truly random numbers with computers (unless you hook up a device that generate those, such as one based on radioactive decay), everything is fully predictable if you have all the information.
"Random" numbers are based on "seeds" that serve as the starting point for random number generator algorithms. Once the seed is known the exact sequence of "random" number is known. DF makes use of 4 such seeds, if I remember correctly, where one controls the geography, one creatures, one history, and one names. If all of them are provided the world generation SHOULD give the same result every time (provided all the other parameters, raws, etc. are the same). The geography seed (or just seed, as it's called) will affect everything else, so it's the "top" one. Change that one and everything else changes (a mountain changed into a plain changes the creatures that can appear, which scrambles the creature seed, civs may take account of this differing terrain and the history changes, changes to creatures through terrain or history scrambles the names).
If you don't specify any seeds when you generate a world the seeds are generated somewhat randomly. I don't know what method DF uses, but a common one is to base it off the current time reported by the OS.

After world generation there are some RNG (Random Number Generator) seeds that vary between each session, so presumably they're re-seeded each time you load a fortress.

The generation of embark and fortress levels are based on seeds stored in the DF data structures (I've failed to locate the embark level seeds, but even if you use DFHack to mess with the embark level pre embark, leaving the area to look at another one and then returning will regenerate it the same as it was originally), which is a very clever way to reduce the size of the saves to levels that would fit on a hard disk at the time the DF development started.

Thus, there are procedural rules within DF, but those are subject to random parameters values as well. Dorfs are described physically in raws, that state the number of arms, etc, but it gives a range for size. Attributes such as strength, dexterity, etc. are likewise described as ranges with the actual starting value being determined randomly.
Logged

Thisfox

  • Bay Watcher
  • Vixen.
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #2 on: January 03, 2017, 03:59:24 pm »

We used to have a random number generator at Uni. It was good for "number between 1 and 10", and also "number between 1 and 100". I believe the number in question was 9. It was randomly generated every single time....
Logged
Mules gotta spleen. Dwarfs gotta eat.
Thisfox likes aquifers, olivine, Forgotten Beasts for their imagination, & dorfs for their stupidity. She prefers to consume gin & tonic. She absolutely detests Facebook.
"Urist McMason died out of pure spite to make you wonder why he was suddenly dead"
Oh god... Plump Helmet Man Mimes!

94dima94

  • Bay Watcher
  • For !!SCIENCE!!
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #3 on: January 03, 2017, 05:32:29 pm »

We used to have a random number generator at Uni. It was good for "number between 1 and 10", and also "number between 1 and 100". I believe the number in question was 9. It was randomly generated every single time....

Did it work like this?
Logged
The worst enemy you'll ever meet is the little voice that says Hey, this would be a cool/awesome/funny thing to do!/I wonder what happens if...
"Rock needs a nerf! Paper is just fine, IMO." - The Scissors.

Thisfox

  • Bay Watcher
  • Vixen.
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #4 on: January 03, 2017, 08:08:37 pm »

We used to have a random number generator at Uni. It was good for "number between 1 and 10", and also "number between 1 and 100". I believe the number in question was 9. It was randomly generated every single time....
Did it work like this?

No, it was somewhat more random, and somewhat more complex, and used both hardware and software in its programming, but yes, I'd forgotten the xkcd one. <grin>
Logged
Mules gotta spleen. Dwarfs gotta eat.
Thisfox likes aquifers, olivine, Forgotten Beasts for their imagination, & dorfs for their stupidity. She prefers to consume gin & tonic. She absolutely detests Facebook.
"Urist McMason died out of pure spite to make you wonder why he was suddenly dead"
Oh god... Plump Helmet Man Mimes!

Nagidal

  • Bay Watcher
    • View Profile
    • My gaming channel
Re: What in the world gen is procedural and what is random?
« Reply #5 on: January 04, 2017, 03:45:36 pm »

Thank you, Patrick, for your detailed answer. It gave me enough insight to see that world generation is based on multiple seeds, of which each is used to generate pseudo-random numbers and sometimes also modifies the random numbers (or the interpretation of them) coming from some other seed. This should make sure, that if you use all the same seeds, the "randomly" generated worlds should end up the same. This is like using the same seed for world generation in Minecraft will result in two identical worlds being generated. Practically, this is just like a procedural generation.

However, after the world generation, things start to differ, because for every session of gameplay some randomness is introduced for the generation of further events. That's why two players (or two instances of) playing an identical world will get different migration waves, caravans, enemy encounters, etc. Similarly, in Minecraft, the enemies, spawned on acertain location are randomized, even if played in identical worlds.
Logged
I stream most of my DF sessions: gaming.youtube/nagidal146, they are archived on my youtube channel. (Dwarf Fortress Tutorials)

Melting Sky

  • Bay Watcher
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #6 on: January 11, 2017, 11:57:52 am »

Thank you, Patrick, for your detailed answer. It gave me enough insight to see that world generation is based on multiple seeds, of which each is used to generate pseudo-random numbers and sometimes also modifies the random numbers (or the interpretation of them) coming from some other seed. This should make sure, that if you use all the same seeds, the "randomly" generated worlds should end up the same. This is like using the same seed for world generation in Minecraft will result in two identical worlds being generated. Practically, this is just like a procedural generation.

However, after the world generation, things start to differ, because for every session of gameplay some randomness is introduced for the generation of further events. That's why two players (or two instances of) playing an identical world will get different migration waves, caravans, enemy encounters, etc. Similarly, in Minecraft, the enemies, spawned on acertain location are randomized, even if played in identical worlds.

Yeah, you got it. Random seeds are generated and then used as a basis to procedurally generate the world.
Logged

Sanctume

  • Bay Watcher
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #7 on: January 11, 2017, 12:42:52 pm »

Adding to @PatrikLundell

There was a point where different OS results differently based on the same seed.  I'm not sure if this is still an issue cross-OS regarding using the same seed to world-gens.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: What in the world gen is procedural and what is random?
« Reply #8 on: January 11, 2017, 05:33:45 pm »

I believe there's a case where the 32 and 64 bit Windoze versions generate different somewhat worlds currently. I don't think the issue with retries has been dealt with either, so only seeds that results in no rejections are thought to generate the same worlds across different OS'. Toady has fixed some cases of the same seeds generating different results on the same OS in a reasonably recent version as well, but whether those were the only cases remains to be seen.
Logged