Allow ZScript to set random seed

Moderator: GZDoom Developers

Post Reply
User avatar
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm
Contact:

Allow ZScript to set random seed

Post by JPL »

Any time Random() is used, things will be a bit different across play sessions, which can be a pain for testing or for establishing a consistent basis for certain kinds of competitive play - I'm talking less about the core Doom random things like combat damage, and more things like mods that randomize items.

In Python I'm used to being able to feed something into random.seed() if I want the same result on multiple runs. It would be nice if we could do this from ZScript with something like SetRandomSeed(int seedValue).

Again I'm aware that Doom's use of randomness is a bit different, and that random generators can produce seemingly different results depending on how many times they've been extracted from - it would be on zscript users to understand how to use this properly.

If this is better served by adding a different generator implementation, eg SeededRandom(), that would be fine. It's even possible a generator could be implemented in ZScript, though I don't see bit math in the documentation and that's useful for most generator algorithms.
User avatar
JPL
 
 
Posts: 523
Joined: Mon Apr 09, 2012 12:27 pm
Contact:

Re: Allow ZScript to set random seed

Post by JPL »

Looking at the code a bit, there's already a CCMD that does this, "rngseed get|set|clear", a "-rngseed" command line switch, and the general design of the system clearly fully supports a user-defined seed. So the work here mainly seems to come down to exposing it to ZScript in the proper way.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Allow ZScript to set random seed

Post by Graf Zahl »

Added.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”