Modding, Mission Design, and Coding > The FRED Workshop

What's a "seed" in "rand"?

<< < (2/2)

karajorma:
I seem to remember that the reason the seed option was added was for exactly that reason. So that BHX could be deterministic and that if you were bug testing you knew which combination of factors were causing a bug to appear rather than having to re-hardcode everything in order have the bug happen every time.

Goober5000:
In the Feynmann tradition of simple English, here's my explanation:

The numbers aren't actually random.  As JSRNerdo said, they are specific sequences of numbers.  So imagine that the computer knows about several sequences, like this:

Sequence 1: 44, 56, 18, 2, 87
Sequence 2: 78, 5, 1, 99, 53
Sequence 3: 6, 34, 79, 44, 90
etc...

The "seed" is just the sequence identifier.  So in the above example, if you have a seed of 1, you will always get the sequence 44, 56, 18, 2, 87.  Any number you pick for a seed will correspond to some sequence, but the sequence will always be the same for that seed.

The sequence isn't stored in memory; it's generated from the seed using a mathematical formula.  Regular users don't need to know the details of the formula.  The formula was created to have many of the same mathematical properties as a truly random formula, even though it isn't truly random itself.

Usually, the seed is chosen based on the system time.  Suppose that the game uses the number of seconds in the day so far.  Since there are 86400 seconds in a day, there are 86400 possible sequences.  Since it is unlikely two players will start the game at exactly the same second, they will almost certainly experience two different sequences.

TopAce: