Random Numbers of Hell

DarkRevenant

Mad Scientist
Reaction score
13
It seems that certain functions cause the random seed and the randomization algorithm to reset itself. It's very obvious in Mafia, my map, where I use a system that is powered by a footman attacking another footman in the corner of the map, generating random attack values from 1 to 12 as integer fuel. All the parts of my map that require random numbers take the most recent attack value from these footmen (15 times per second, roughly) and use it as the random number. All of my tests are done in Battle.net.

A snippet:
Trigger:
  • Set Loop = 0
    • Custom script: loop
    • Set Loop = (Loop + 1)
    • Custom script: exitwhen udg_Loop > udg_Zgodfather
    • Set TempInt = 0
    • Custom script: loop
    • Custom script: exitwhen udg_TempInt > 0
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player(Random)) is in TempForce) Equal to (==) True
        • Then - Actions
          • Set TempPlayer = (Player(Random))
          • Set TempInt = 1
        • Else - Actions
          • Wait 0.01 seconds
    • Custom script: endloop
    • Set RoleNum[(Player number of TempPlayer)] = 4
    • Player Group - Remove TempPlayer from TempForce
    • Custom script: endloop


Given the same role setup, regardless of the names of the players in the game, the "random" distribution of roles is ALWAYS the same, in every test. No matter what. Given that the random numbers are fed by something that should, by all means, give different values each time because the absolute game time is different in each test, this leads me to believe that the random seed is indeed reset as a result of these functions.

This map does not call SetRandomSeed(int) at any time, mind you. The random seeds seem to reset themselves even with Integer A loops and various other designs of loops.

I will conduct further testing with SetRandomSeed(GetRandomInt(-999999,999999)). If that doesn't work, I'll use an involuntary user-input-driven hash to use for SetRandomSeed(int). If neither method works, then may God save us all.

Edit: It appears that the GUI cinematic function resets the random seed, which may be the cause of this.
 

Rushhour

New Member
Reaction score
46
Hm, I know that this cinematic function "CinematicModeExBJ" fixes the randomSeed:
JASS:
       
     // Use a fixed random seed, so that cinematics play consistently.
        call SetRandomSeed(0)

but that's the only bj I know of that changes it, maybe there is another one?
Check if you used it and if it didn't reset for some reasons.

Edit: Ah you found it too^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top