TheHighwayman Posted June 12, 2020 Posted June 12, 2020 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
Lineaxe Posted June 12, 2020 Posted June 12, 2020 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
TheHighwayman Posted June 12, 2020 Author Posted June 12, 2020 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.
RV8ator Posted June 13, 2020 Posted June 13, 2020 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 reviewPG Night A2A.miz
Habu_69 Posted June 14, 2020 Posted June 14, 2020 Yeah, I have also experienced that "random" triggered events seem extremely biased.
Dunx Posted June 14, 2020 Posted June 14, 2020 (edited) 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 June 14, 2020 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
Habu_69 Posted June 15, 2020 Posted June 15, 2020 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.
Dunx Posted June 15, 2020 Posted June 15, 2020 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
Lineaxe Posted June 16, 2020 Posted June 16, 2020 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 :)
Dunx Posted June 16, 2020 Posted June 16, 2020 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
Lineaxe Posted June 25, 2020 Posted June 25, 2020 you are right. Now for the mission I am writing for myself and my Brother I have no problem re-enabling os . I agree with you, someone may want to write bad scripts through os. But we are just going to write 'fun' ones :)
Knock-Knock Posted June 25, 2020 Posted June 25, 2020 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 |
Recommended Posts