Jump to content

Random trigger returns same result


TheHighwayman

Recommended Posts

I have a mission that fires 1 of 6 permutations for replay value. (F-14 vs. A-4 on Nevada Map; player flies F-14)

 

Blue enters a zone, which activates a timer, which activates a random trigger with 1-6 as possible results, and each result is linked to a permutation which spawns different opponents for blue.

 

However, each time I play the mission, I get permutation number 5, which is entirely inexplicable to me. I reviewed my triggers, and everything seems right.

 

Chances are I am missing something obvious. But I can't see it myself.

 

Can someone play this mission a few times and let me know what permutations you are getting?

 

Each play is probably about 10-15 minutes. It's also fun. Thanks.

Mighty_Wings (1).miz

Link to comment
Share on other sites

You can try using my random generator code found in another one of my posts .. it gives you the Option of using one of several random generator methods

 

Thanks! I'll look for it.

 

The method I am using SHOULD work. It's simple and straightforward, but it isn't working. I feel I am either missing something obvious, or there is a bug. I can't figure which.

Link to comment
Share on other sites

I had the same issue when I made up my Random A2A training mission, I had to use separate flags for each additional spawn, I also needed an additional condition to random generate the next sequence. I'm sure there are better ways but I'm not a coder and it does work well.

 

I attached my mission for you to review

PG Night A2A.miz

Link to comment
Share on other sites

Algorithm based RNGs need a unique seed to force them to change.

 

Using the same seed will generate the same pattern of random numbers under the same computational circumstances.

 

Edit: Calling math.randomseed(os.time()) before calling math.random() should force a different pattern (if implemented in DCS version)


Edited by Dunx

ROG Z690 Hero ● i9-12900K 5.5GHz ● Giggy RTX 3090 OC ● 32GB 4800MHz ● Firecuda M.2s ● Reverb G2 ● Win11Pro //// A10CII ● AH64D ● AJS37 ● AV8BNA ● C101 ● CEII ● F16C ● F5EII ● F86F ● FA18C ● FC3 ● I16 ● KA50 ● M2000C ● MI8 ● P47D ● SA342 ● SPIT ● UH1H ● Y52

Link to comment
Share on other sites

Algorithm based RNGs need a unique seed to force them to change.

 

Using the same seed will generate the same pattern of random numbers under the same computational circumstances.

 

Edit: Calling math.randomseed(os.time()) before calling math.random() should force a different pattern (if implemented in DCS version)

 

 

Anyone tried this recently? I checked this out a few DCS versions ago and found that DCS did not permit access to os.time(), IIRC.

Link to comment
Share on other sites

Anyone tried this recently? I checked this out a few DCS versions ago and found that DCS did not permit access to os.time(), IIRC.

 

By default DCS disables os and io during startup. You can bypass this.

 

I just checked the other classes and singletons exposed by DCS but could not find anything that would generate a "different" value that could be used to seed the RNG.

ROG Z690 Hero ● i9-12900K 5.5GHz ● Giggy RTX 3090 OC ● 32GB 4800MHz ● Firecuda M.2s ● Reverb G2 ● Win11Pro //// A10CII ● AH64D ● AJS37 ● AV8BNA ● C101 ● CEII ● F16C ● F5EII ● F86F ● FA18C ● FC3 ● I16 ● KA50 ● M2000C ● MI8 ● P47D ● SA342 ● SPIT ● UH1H ● Y52

Link to comment
Share on other sites

the routine I posted reverses the last digits and uses them AS THE SEED for the random number generator. As I mentioned, and it can be found on one of the LUA forums :)

 

Awww, a glimmer of hope dashed.

 

Sadly, your routine calls the "os.time()" function. The "os" class is disabled by default, and for a very good security reasons.

 

Malicious scripts could be used to delete local files and execute local/remote programs.

ROG Z690 Hero ● i9-12900K 5.5GHz ● Giggy RTX 3090 OC ● 32GB 4800MHz ● Firecuda M.2s ● Reverb G2 ● Win11Pro //// A10CII ● AH64D ● AJS37 ● AV8BNA ● C101 ● CEII ● F16C ● F5EII ● F86F ● FA18C ● FC3 ● I16 ● KA50 ● M2000C ● MI8 ● P47D ● SA342 ● SPIT ● UH1H ● Y52

Link to comment
Share on other sites

  • 2 weeks later...

Myea its certainly not random, DCS's random generator. I had that feeling for a long time, and then a while ago I did a continuous -> random (1) -> flag random 1,99 - and then 1 to 10 of the values would trigger a beep, a 120 sec long message, and place a map mark on a runway.

 

I ran that and accelerated time to x300. Didnt take long before I had 5 or 6 map marks, and no new map mark would appear, and the way the messages appeared on screen, it had a beat I could almost dance to :)

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...