1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Random is only random in some cases

Discussion in 'World Editor Help Zone' started by Solu9, Apr 27, 2016.

  1. Solu9

    Solu9

    Joined:
    Jan 25, 2011
    Messages:
    2,166
    Resources:
    47
    Models:
    26
    Icons:
    16
    Skins:
    1
    Tools:
    1
    Maps:
    3
    Resources:
    47
    I have a lot of things in my map that rely on random numbers, but only some of these things will change from map start to map start.

    For instance.
    Random generated gold mines seem to be placed the exact same places over and over again.

    But a spawned Town Hall will be different from map start to map start.

    This also seem to be the case when the map is started from WC3 and not through the editor.
     
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,658
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    There's a world editor setting called "random seed" or something, try changing that.
     
  3. Solu9

    Solu9

    Joined:
    Jan 25, 2011
    Messages:
    2,166
    Resources:
    47
    Models:
    26
    Icons:
    16
    Skins:
    1
    Tools:
    1
    Maps:
    3
    Resources:
    47
    I have tried with it checked and unchecked. From what I can tell it's the same story.
    And should this have any effect when the map is played from within WC3?


    By the way.
    The Town Hall I mentioned in post #1. It seem to only randomize between 3 points.


    What I do is having a trigger which runs at 0.10 seconds in game time.
    This trigger will run a series of other triggers. It's in these triggers the magic is happening (you should be happening). All that random stuff.
     
  4. Meatmuffin

    Meatmuffin

    Joined:
    Jul 25, 2014
    Messages:
    451
    Resources:
    9
    Maps:
    2
    Spells:
    7
    Resources:
    9
    No, the setting "Fixed random seed" only affects the editor (it takes effect when you use Test Map). If the problem was within the editor only, would have replied sooner.
     
  5. Emm-A-

    Emm-A-

    Joined:
    Jul 1, 2008
    Messages:
    1,312
    Resources:
    0
    Resources:
    0
    Did you check with Debug messages, whether the random numbers are what you expected? This will tell you, whether the calculation method of the random factor is not good enough or whether there is a simple bug somewhere.
    You should also post the function, that is rolling the random numbers.
     
  6. Solu9

    Solu9

    Joined:
    Jan 25, 2011
    Messages:
    2,166
    Resources:
    47
    Models:
    26
    Icons:
    16
    Skins:
    1
    Tools:
    1
    Maps:
    3
    Resources:
    47
    There are SO many randoms being generated in my map that I didn't bother.
    Often I use the inherit "Random number between" in the function instead of using an integer set with "Random number between".

    Edit:
    Here is an example of the types pf triggers I use.

    • ...


    The terrain will chance at the exact same spot using the exact same randoms every time I launch the map. Be it from the editor or from WC3.

    Edit:
    Alright so I think I have found what caused the problem.
    In my map initialization I turned on Cinematic. It turns out that turning on Cinematic the random seed will be set to 0. I'm referring to this thread: http://www.hiveworkshop.com/forums/graveyard-418/snippet-random-seed-210426/ post #9 by Bribe.
     
    Last edited: Apr 28, 2016
  7. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Yep, this is the problem. They fix the seed because usually you want cinematics to be deterministic.

    To change that, simply run this after turning cinematic mode on:
    • Cinematic - Turn Cinematic Mode On...
    • Custom script: call SetRandomSeed(bj_cineModeSavedSeed)
     
  8. Solu9

    Solu9

    Joined:
    Jan 25, 2011
    Messages:
    2,166
    Resources:
    47
    Models:
    26
    Icons:
    16
    Skins:
    1
    Tools:
    1
    Maps:
    3
    Resources:
    47
    Legend!

    A couple of questions.
    I'm curious. Is says "SavedSeed". How is that to be understood? Does it save the seed from before the cinematic is turned on or how does it work?

    And

    Turning cinematic mode off again won't affect the seed?
     
  9. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,727
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    As far as I can recall there is no native to get the actual RNG seed. Instead a random number in maximum range is fetched from the RNG and used as the seed since that number in some way reflects the seed but could be different from the seed. This distinction is important because it means after restoring seed the random results may be different than if they occurred without saving/loading the seed, basically a RNG sequence discontinuity.
     
  10. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    It saves a random variable from 0 to 1,000,000 into the variable
    bj_cineModeSavedSeed
    when you turn cinematic mode on. Then it sets the seed to 0 for the cinematic.

    When you turn cinematic mode off, it sets the seed to the stored value, as I showed in post #7.

    So it doesn't actually store the seed itself, but rather just a random number. But it doesn't matter much, because that random number was already based on the seed you had at the time. As long as it isn't just some fixed seed (e.g. 0), you'll get the randomness you want. ;)

    EDIT: DSG beat me to the post.