Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Choosing world_gen civilisations  (Read 570 times)

dragdeler

  • Bay Watcher
    • View Profile
Choosing world_gen civilisations
« on: August 21, 2017, 05:50:34 pm »

Is there any way I can hope to set, or reliably improve my odds of generating worlds with a desired number of civilisations for each race?

I'm not exactly a math genius but I wouldn't mind fiddling with history seeds if I had the slightest idea on how to read or write them. So certainly a third party tool seems like the best option, sadly PefectWorld doesn't allow me to do so.

I did a bit of testing, using a perfectworld gen but with a defined history seed; and after 10-20 attempts, I'm under the impression that the count of goblin civs varies less than without it... but that might aswell be luck.



So, any suggestions  ;D?
Logged
let

mikekchar

  • Bay Watcher
    • View Profile
Re: Choosing world_gen civilisations
« Reply #1 on: August 21, 2017, 09:20:32 pm »

I don't know the answer to your question, but I can explain a little bit about how "seeds" work.

Usually in games we want to have at least some random content.  If the game was always the same, it would be boring.  But, computers can't really do random.  When you have a function, if you give it the same input, it will always give you the same output.  The best we can do is to have a function that gives you an unpredictable and uniform output, given an input.

To give an example, our "random number generator" outputs a number from 1 to 10.  It takes a single input (called a "seed").  For the sake of this example, let's say the seed is a number from 1-100.  For every seed you input, it gives out an unpredictable output.  So if I enter a seed of 1, the output might be 9.  If I enter a seed of 2, the output might be 5.  For every seed input (from 1 to 100), I get a different output (from 1 to 10) and it is "hard" to guess ahead of time what the output will be (that's what we mean by "unpredictable" in this case).

Every time I call my "random number generator", I can just increment the seed.  So the first time I call it, I will use a seed of 1.  The second time, 2, etc.  And my output will seem to be "random" -- it is "hard" to guess ahead of time what the output will be from the input and the output is evenly distributed (all outputs from 1-10 have an equal chance of being output at any given time).  But it's not really random.  If I enter a seed of 1, the "random" number I get out the end is *always* 9.  If I enter a seed of 2, the output will *always* be 5.

Now, our "random number generator" also has a "period".  There are only 100 different seed values.  So if I start at 1 and increment the seed each time, then I can generate only 100 "random" numbers.  After that I have to start at 1 again and the pattern will repeat.  We say that the "random number generator" has a "period" of 100 (because the sequence repeats every 100 times).

Dwarf fortress has a much better "random number generator" than the one I've been describing.  It doesn't just generate 10 values -- it generates huge numbers of values between 0.0 and 1.0 (i.e. it might generate 0.544223323 one time and 0.32456732  another).  I'm not sure exactly how many distinct values it can generate, but it is "a lot".  Also, we start with an "initial seed" between 0 and about 2 billion.  Each one of these "initial seeds" generates a distinct set of "random" values and each of them has a massive "period" (I'm not sure what algorithms DF uses, but likely the period is several million if not more -- good random number generators have periods of more than a billion).

Remember that with the "random number generator" when you enter a seed value, it *always* returns the same output.  And if you have a defined way of finding the next seed number (we incremented it in our example, but the algorithms that DF uses will do something more complicated), then the sequence of random numbers that you generate will *always* be the same.

So this means that if I start with a seed of 42, then the sequence of random numbers will always be the same.  For world gen, DF uses 2 random number generators.  Each has an initial seed.  So if you always use the same values, you will always create the same world (barring bugs, or implementation differences on different platforms).

However, remember when I said that the output is uniform and unpredictable.  There is no way "easy" way to relate the seed that you started with to the output that you generate (or speaking a bit more clearly, you can't predict what it will be other than to run the random number generator itself).  So this means that you can't do what you want to do.  There is no way for you to look at a bunch of desired outcomes in world gen and calculate the seed that you would need to generate it.  It's just like saying, "I need the 12th number in the random number sequence to be 0.5444332.  What seed do I need to start with?"  Apart from sitting there and running the algorithm over and over and over again until you find a seed that satisfies your demand, there is no way to do it.

As an aside, we call such a function a "one way hash" and it's the basis of all modern cryptography.  It's relatively easy to find the random number from a seed (we just run the random number function once), but it is very difficult to go the other direction.  Because the output is unpredictable (even though it is defined), we have to run the random number generator potentially millions of times before it outputs the value we want.    So you can imagine that we could have a series of "seeds" -- one for each letter in our message, and we can generate an "encrypted message" simply by running the random number generator on the seeds.  Nobody can decrypt the message to find the original "seeds" because it would take millions or billions of tries to do it.  With encryption algorithms (as opposed to random number generators), we can provide a "hint" in the form of a "key".  If you know the key, there is an algorithm that will relatively quickly find the original "seeds".  As long as the "key space" (number of possible keys) is large, then it is still infeasible to try to decrypt the output without the key.

Hope you found that interesting, though it is a shame you can't do what you want.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Choosing world_gen civilisations
« Reply #2 on: August 21, 2017, 11:44:09 pm »

As for what Perfect World is: it's a custom GUI for vanilla user interface we call the world painter (advanced world generation - edit parameters - paint pre-set values).

I like to compare this to setting a mesh size with number of mesh nodes equal the number of regional tiles.

Great though the control it provides may be, it's still has great randomness in it. If you place a volcano in predetermined regional tile, it may be anywhere in that 16x16 square, for 256 random values, and it may be flat, a pipe, or have random elevation raise as well. River and especially biome shapes are far more complex, obviously, being more than a single tile.

Nonetheless, the control is still great enough with basic worldgen that you can have only 1 mountain, location chosen by you, where dwarves can be placed, and similarly for humans and elves. Goblins can be stopped with lack of demons, but that's pretty crude.

For a further level of control, perhaps the simplest way to accomplish what you want would be by modding. Entity_default.txt has a nice token called [MAX_STARTING_CIV_NUMBER:100]. Obviously, if you set it to 1 to all and try to generate a world with 10 civs you'll get infinite rejections, so revert your changes after you've done generating the world lest you forget about it.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Choosing world_gen civilisations
« Reply #3 on: August 22, 2017, 02:50:48 am »

It should be noted that mikekchar's description of a random number generator is still a simplification (but it's a good description of the gist of it).
DF uses several RNG seeds for different purposes, and their outcome interact. Given that the world gen parameters (including raws) are the same, the same set of seeds should result in exactly the same world, history, etc ("should" = if it doesn't it's a bug, and there are such bugs at times). Each RNG seed will case that RNG to spit out exactly the same numbers in exactly the same sequence every time, so as long as a the numbers are used exactly for the same thing everything repeats. However, if you disturb anything the sequences get out of sync, so if say RNGs caused a site to appear in a location in one generation, but you changed the volcanism in the world so a volcano appeared there in the world gen, that site won't appear there (but possibly elsewhere). This means hist fig X won't be born there to meet and fight hist fig Y, so the history changes. Everything related to the history changes as well, and the results are that you could just as well have used a different ("random") RNG.

The only way I see to generate exactly X dwarven civs, exactly Y elven civs, etc. is to change the entity_defaults entries for each race to set the max number of civs the corresponding number, remove all megabeasts and titans (to remove the death of civs to their wrath), set the world gen civ number to match the sum, use a PSV based world where each civ is placed exactly (which is very tricky) to avoid them killing off each other with wars, and then keep generating world until you happen to get one where none of the civs are killed of by FBs.
Having said that, I suggest you've set up an unsuitable goal (in terms of being reachable), and ought to reevaluate it. There's some kind of reason for your desire for the exact number of civs, so you might want to look at that reason and see if what you actually want to achieve can be gotten through an easier path. It can be noted that DF is not intended, and is highly unsuitable, for regenerating some fantasy world recreation of a map with specific countries and and settlements.
Logged

dragdeler

  • Bay Watcher
    • View Profile
Re: Choosing world_gen civilisations
« Reply #4 on: August 22, 2017, 12:59:05 pm »

Let me thank you all for your amazing responses.

Mikekchar, yes it was very interesting and helped a lot me to confirm my toughts. Thus my only approach could be to run the worldgen and keep the most promising seeds.

Fleetingframes, yes I found that matching max_peaks etc to the drawn map helps, especially for dwarf distribution.

PatrickLundell, so you're saying, that if I keep the whole set of seeds the outcome should be more reliable? If that's the case I sure hope the nameseed to be a little more interchangeable, I allready have a beauty on that front.

Now for that [MAX_STARTING_CIV_NUMBER:], this seems to be exactly what I needed! Besides, I don't need "exactly" the world I imagine, I allready left volcanism and drainage to DF. Actually, considering all I've just learned, I might be running my attempts with everything BUT the history seed. One worldgen for each core, keep the one that suits me most, should be fine...



As for what I intend to do: as soon as the new updates comes, I'll gen that world and pour houndreds of hours into it with a ton of megaproject & RPG ambitions. For my fantasies to have the right canvas, I'd need a world with a ton of beasts, so evidently I will have to run history a few times to assure the important civs and figures are not dead. Ideally it would have 3-4 dwarven civs with at least one on the brink of extinction, at least 2 alive elven civs, one on the continent, one on an island, at least 6 goblin civs with an alive demon master, and then about 15 kobold and human civs of which most are not extinct. To simply put it: a world that won't give me a reason to gen another one after a fort, with plenty of goblinite. That's all I can tell you since I intended to share a glorious story, and I don't want to spoil/ have copycats/ raise expectations too high, in case it doesn't turn out as expected. But if it does turn out as expected I'll attempt to find others players to continue playing on that world so I can watch from afar how my protagonists and some deep relationships might change history. There would need to be more than one dwarven civ so other players won't get flooded with my dwarves so that they can roam free.
Logged
let

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Choosing world_gen civilisations
« Reply #5 on: August 22, 2017, 01:12:39 pm »

No, keeping seed and changing things do not make sense as more or less any change anywhere will change everything, as the RNG number sequence will be applied differently. The only level that *does* seem to make sense is for a PSV world to keep the SEED. As far as I can tell, the geography seems to be the same every time. The other seeds probably interact so any change to one seed will affect something that will offset the other sequences, with the end result being that you could just as well have used "random" seeds.

Well, one other thing makes sense: Keeping the complete set of data and increase the length of the world gen. The state you had at the previous end is the state you'll get to at that point in time in the next gen, so one approach I've used is to generate fortresses with random seeds and short histories and then select the promising ones to regenerate them with a longer one (Legends Mode allows you to export the world gen parameters, including the seeds used, so you can find which random seeds DF used).

As long as you keep your stories on a story sub forum I'm happy (stories are not my thing, but others like them, so as long as they don't clutter the technical fora I'm satisfied).
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Choosing world_gen civilisations
« Reply #6 on: August 22, 2017, 04:35:55 pm »

Keeping seed and changing things very little seems to be better way to get very small change in PSV worlds than just changing the seeds in my experience. Not just geography (though I have used 1-tile volcanism changes to tune layers of soil and stone at embark), but history too. Few examples:

One of the "in-progress" gens I made had the first town appear in 1919 and upgrade to big one in 1985. In it, I discover the builder of dozens of towers had moved out into the town when it appeared.

I kept the same seeds and slightly changed the savagery on one of the hillocks he visited then, and got him to leave his last tower earlier, in 1512. Another change, and I got him to visit dozen sites in 30s to 90s, creating new necromancer nomadic group, ready to become a tower, each time.

(In the ultimate final version I managed to keep the same Necromancer with 80 towers built while slowly nudging town to be founded earlier and earlier, till I reached max size town in 1394 - half dozen centuries earlier than the above successful example.)


On a more random note, I like keeping history seed while changing other parameters that affect history so that the initial site placement is as I desire, but worldgen progresses differently.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Choosing world_gen civilisations
« Reply #7 on: August 23, 2017, 02:20:07 am »

Hm, initial site placement control is a very good reason to keep history seeds (assuming, of course, the small changes you make doesn't scramble that, but trying and failing doesn't cost much). Another useful tool for the toolbox.
Logged

dragdeler

  • Bay Watcher
    • View Profile
Re: Choosing world_gen civilisations
« Reply #8 on: August 23, 2017, 01:44:50 pm »

Allright! So using [MAX_STARTING_CIV_NUMBER:] and PerfectWorld I'm able to achieve what I want. Then I looked a little deeper into it, and yes, using the seed and history seed (not name nor creature) proves to be perfectly reliable for starting locations. Then I tried the name seed I enjoyed so much, but found out that all civilisations have the same name in all version, also all megabeasts remain the same species and keep their names in all versions. On the other hand, Demon masters always changed their "species", and I do not care for their unpronouncable names. So the nameseed and creatureseed show me no effect that is apparant in this configuration (and for what I'm looking at).

This sure is enough to go. Thank you all very much  :)!
Logged
let