On the usability of rng in games like dwarf fortress, do thousands of rolls are generated then stored or is only the seed stored?
The second would seem more sensible but it cant explain why two same seeded world gen end up being different. The world would change every time you load a game would nt it?
I cannot speak for DF,
but what would normally happen in any program that uses a PRNG is that it is initialised with a seed-value[1] and then as each new number is required from the PRNG they are requested. The internal state of the PRNG is morphed from its previous condition to the new one and the single new number putput. (Or the request is fulfilled and then the state morphed, it's functionally the same.)
As to whether "thousands of rolls are generated and stored", well, that's up to the code that collects the PRNG output. If you said "for n=1..1000 do Num[n]=NextRandomNumber()", then you'd
indeed be storing thousands of numbers.
At the end of the loop, the PRNG function will still be only storing
one example of whatever internal state form it normally holds. (But, normally, you'd be reaching a decision point, asking for a number in order to
make that decision, then continuing on on whatever path that decision led and then requesting another decision point.[2])
The seed itself, by this time, will be long forgotten. (Unless you poke around into the private data of the PRNG and can somehow perfectly retrace the morphs back to the original state, and translate that back to the seed itself[3], but that's well outside the context of any program that would use it, even if possible.) The fact that the seeds used are provided when you export your worldgen details from DF is a separate functionality provided so that you can recreate a world (even one where you let the computer start with random seeds... What seeded the system that gave the original random seeds is totally irrelevant to this example.
[fakeedit: I don't disagree with Thief^, BTW. I might look at odds with the statement "With DF, the original seed is stored, but also all of the results.", but I would class "all the results" as not storing the generated rolls but only the results of the rolls. i.e. passed through so many other processes as to effectively make them "game data" instead of "the specific list of original random numbers used to create the game data". Which, although there's obviously a causation, is not what I'd call the same thing.]If I understand your original question, because I'm not absolutely sure I do.
As to the workings of the twister itself, I don't think I can add to the explanations already given. And if the pseudo-code snippets you provided are accurate (funny formatting, aside) that tends to be fairly understandable and
should be sufficient.
[1] As described before, either
itself 'randomly' obtained (e.g. from the clock time), or a fixed value, or (as an optional alternative to the former, as seen in DF and Minecraft especially) a user-provided seed.
[2] Though this might well be "set height at coordinates [0,0] to something based upon one random number; set height at coordinates [0,1] to something based upon another random number; set height at coordinates [0,2] to something based upon yet another random number; etc..." which could of course be in a loop, but you can argue whether that's the
same as storing the source random numbers. Especially if in that loop you are restraining each adjacent height according to those already known, either by scaling and translating the values produced or by rejecting invalid results (in which case you might be requesting several random numbers for a single value and rejecting those that you don't like, but that's a very wasteful way of doing it[4] and you'd be better off with the scale-and-translate method).
[3] Given a possible many->one relationship in the forward direction, unlikely.
[4] The fact that DF has "rejects" during worldgen is down to the complexity involved giving very little chance to have "forward looking" logic (that would mean that it can see that this line of worldgen is 'doomed') or to avoid at the time falling foul of the worldgen rejection criteria. For example, you want creatures and population to die during the history creation, or whatever, but if you have a lower-limit on those that remain you can't just say "right, enough have died now, we can't have them be killed any more". So you start again. (Although, IME, it's mostly geographical/geological causes for worldgen rejection, like "There aren't enough volcanoes!", but you can't suddenly start putting loads more volcanoes in the yet-to-be-formed part of the world, without it looking odd.)