jkgarner
Posts: 174
Joined: 4/30/2020 Status: offline
|
Hear! Hear! It is not necessary to seed the random number generator EVERY time you call a random number. Generally it is sufficient to seed it a single time a the beginning of a run (or scenario) Most random number generators are sufficiently random for game purposes to provide an even distribution of numbers between 0 and 1, unless you are dealing with security issues (think finances) in which case you want one that is certified. But even these function the same way. You seed once, and then call repeatedly as needed. For simulations purposes, there is over seeding the generator. This results in compete loss on control of the randomness and a lack of repeatability. Repeatability? (You ask) Why do I want that? OK, for a pleasure game, it is not critical. But for a simulation, repeatability can bes very handy as a validation tool and as a debugging tool. If in my run of the simulation, I encounter an error (or what I believe to be an error halfway through the run. As a simulation developer, I must be able to recreate that series of events and instrument the run to see what happened to correct it. Debugging becomes much easier if I could simply feed it the same inputs and run, knowing that the error WILL occur. If the ONLY time the random number generator is seeded is the very beginning of the run, and that seed value is saved, then when I run it again, I could give it the same seed and get the same results. As a debugger, then all I need to do is instrument the appropriate code (assuming the instrumenation code it does not call random) and then examine the output after the run. I could stop it seconds before the error occurs to examine the state of the system to gain further insight. This most often leads to the discovery that where the error appears or is reported was the result of something else that was not correct, and may have been incorrect for some time), so I then run again, stopping earlier, working backwards looking for root causes, until I find the true error, and a way to fix it. This is ONLY possible with repeatability. As a simulation grows in complexity, this type of behavior becomes more necessary. My reccomendation is for the scenario developers to seed the random number generator ONLY at the very beginning of the scenario, when first loaded and store the value of the seed into the Key Values Store (using ScenEdit_SetKeyValue) That is my two cents worth.
|