Habu23 Posted December 16, 2011 Posted December 16, 2011 (edited) Hello all, I am building a mission that utilizes randomization, but I am having some severe problems with designing the trigger framework to suit these needs. Let me explain what I would like to happen: 1) Flight of A-10C's proceed to an IP. Using a zone area and "group in zone" trigger, I can do this without difficulty. 2) At this time, I want to randomly activate one of four, specific groups. One of the four must spawn. Point number 2 has been giving me the largest problems. I designed a framework where there is a 25% chance that one group of four would activate, evaluating each group in order. The biggest problem is that the law of probability makes it difficult for the fourth group to ever be activated and this system does not work. Everytime, the first group is activated even though I specified a 25% Random Trigger. Even when this was at 10%, it always fired. What is the best way to achieve what I want to do? I feel that with a simple script could achieve this problem, but I am forced to work with triggers. I am simply looking to randomly activate one of four groups, each with a 25% chance of being picked. Thank you all for your help toward my questions. Habu Edited December 16, 2011 by Habu23 [sIGPIC][/sIGPIC]
SmokeyTheLung Posted December 16, 2011 Posted December 16, 2011 The "random" triggers are evaluated by the engine every second or so untill they become true. What you need to do is add a couple of extra conditions to your group activate triggers. Set it up so that each trigger has an action that sets a flag as true. Then you need to add an extra condition to each trigger that will not allow the group to spawn if the flag is true. That should do the trick, although I've been away from the ME for a couple of months System specifications: Computer, joystick, DCS world, Beer
Grimes Posted December 16, 2011 Posted December 16, 2011 In psuedo code Once> Part of group is in zone> Flag 1 On Once> Flag 1 is true && Random 10%> Flag 1 Off, Activate group A Once> Flag 1 is true && Random 10%> Flag 1 Off, Activate group B Once> Flag 1 is true && Random 10%> Flag 1 Off, Activate group C Once> Flag 1 is true && Random 10%> Flag 1 Off, Activate group D The groups will become activated only when flag 1 is true (on). When an option is selected it turns flag 1 off preventing other options from being chosen. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Habu23 Posted December 16, 2011 Author Posted December 16, 2011 Thank you very much again for your feedback. I will give it a try and let you know if I have any more questions. Habu [sIGPIC][/sIGPIC]
STP Dragon Posted December 16, 2011 Posted December 16, 2011 Grimes trigger logic will work but ATTENTION! The random condition (stand alone) is not working with ONCE triggers! A ONCE trigger will get executed cyclic till it is true. If a random condition is used by a ONCE trigger it will get true once. (matter of time) So if you use a random condition (stand alone) please use MISSIONSTART triggers. Homepage: Spare-Time-Pilots DCS:BlackShark v1.0.2: BLINDSPOTs EditorMod DRAGONs ArmA2-Sounds DRAGONs BS1 TRAININGPACK DRAGONs MISSIONPACK [bS & FC2] DCS:World: TM WARTHOG PROFIL FOR BS2 DRAGONs BS2_TRAININGPACK DRAGONs TRAININGPACK DRAGONs MISSIONPACK
Druid_ Posted December 16, 2011 Posted December 16, 2011 (edited) I need to test this in patch 1.1.1.1 to make sure it works but in the meantime here's the link to an earlier question to the same problem http://forums.eagle.ru/showthread.php?t=72336&highlight=random there's also plenty of other good suggestions in that thread too. Edited December 16, 2011 by Druid_ i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
STP Dragon Posted December 16, 2011 Posted December 16, 2011 Druid, it is a logical system behaviour. Homepage: Spare-Time-Pilots DCS:BlackShark v1.0.2: BLINDSPOTs EditorMod DRAGONs ArmA2-Sounds DRAGONs BS1 TRAININGPACK DRAGONs MISSIONPACK [bS & FC2] DCS:World: TM WARTHOG PROFIL FOR BS2 DRAGONs BS2_TRAININGPACK DRAGONs TRAININGPACK DRAGONs MISSIONPACK
Druid_ Posted December 16, 2011 Posted December 16, 2011 Druid, it is a logical system behaviour. sorry Dragon I don't follow. Can you explain? i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
daribouca Posted December 16, 2011 Posted December 16, 2011 (edited) I am simply looking to randomly activate one of four groups, each with a 25% chance of being picked. Hi! Perhaps I got something wrong, but what I would do is simply assign a random value to a flag, which has to be between 1 and 4. In ME logic: MissionStart: FlagSetRandomValue(x,1,4) FlagEquals(x,1) -> ActivateGroup(Group1) FlagEquals(x,2) -> ActivateGroup(Group2) FlagEquals(x,3) -> ActivateGroup(Group3) FlagEquals(x,4) -> ActivateGroup(Group4) Edited December 18, 2011 by daribouca
maxmax Posted December 16, 2011 Posted December 16, 2011 I've never actually managed to get random group spawn like the one Grimes suggested. Only at mission start have I got groups to spawn properly at random. The last one seems logical though, and I'll give it a shot. Randomstuff has always been a pain for me. On the other hand I did almost fail statistical theory in math class. Odds n' shit. The thing is, a mission gets lots more replay value if you never know where units will spawn. So it's kinda important.
STP Dragon Posted December 16, 2011 Posted December 16, 2011 (edited) sorry Dragon I don't follow. Can you explain? Sorry, it's hard for me to explain this in english but I'll try :D For a ONCE trigger the condition is getting checked "is it true?", every second frequently. It's a cyclic behaviour. Once the condition is true the action get executed and the trigger woun't get touched anymore. If the condition is a RANDOM condition it get checked and checked and checked every second till it is randolmy true. So the action will get executed some seconds (depends on the %) after missionstart (the first check). This is a logical system behaviour and I don't think that ED was/is/will change that. To get a RANDOM condition to work you need a trigger which is checked only once (not frequently). The only trigger for this is MISSIONSTART. Edited December 16, 2011 by =STP= Dragon Homepage: Spare-Time-Pilots DCS:BlackShark v1.0.2: BLINDSPOTs EditorMod DRAGONs ArmA2-Sounds DRAGONs BS1 TRAININGPACK DRAGONs MISSIONPACK [bS & FC2] DCS:World: TM WARTHOG PROFIL FOR BS2 DRAGONs BS2_TRAININGPACK DRAGONs TRAININGPACK DRAGONs MISSIONPACK
Habu23 Posted December 16, 2011 Author Posted December 16, 2011 Great feedback guys. Thanks Dragon for the clarification on the random triggers. I'm going to resort to the .lua script that Druid provided: -- Change the values in the 2 variables lowest_flag and highest_flag -- to the flag values you wish to use in your mission local lowest_flag = 100 local highest_flag = 105 ---------------------- DO NOT EDIT BELOW THIS LINE ------------ local total_flags = 1 + (highest_flag - lowest_flag) local flag_table = {} for x = 1, total_flags do flag_table[x] = lowest_flag + (x-1) end function randomiseTable(tableName) local temp_table = {} local index = -1 math.randomseed( os.time() ) while #tableName > 0 do index = math.random(1,#tableName) table.insert(temp_table,tableName[index]) table.remove(tableName,index) end return temp_table end function randomiseGpActivate(rgroup) local spawnrandom = 0 math.randomseed( os.time() ) math.random() spawnrandom = math.random(1,5) return(spawnrandom) end flag_table = randomiseTable(flag_table) local rgroupindex = randomiseGpActivate(rgroup) local rgroup = flag_table[rgroupindex] trigger.setUserFlag(rgroup,true) In his script there are the following lines: local lowest_flag = 100 local highest_flag = 105 Does that mean that one of the following flags will be randomly picked: 100, 101, 102, 103, 104, 105 Habu [sIGPIC][/sIGPIC]
Druid_ Posted December 16, 2011 Posted December 16, 2011 (edited) Great feedback guys. Thanks Dragon for the clarification on the random triggers. I'm going to resort to the .lua script that Druid provided: In his script there are the following lines: local lowest_flag = 100 local highest_flag = 105 Does that mean that one of the following flags will be randomly picked: 100, 101, 102, 103, 104, 105 Habu Yes. In patch 1.1.0.8 access to the operating functions was removed e.g. os.time(). I have not checked yet to see if has been re-enabled in patch 1.1.1.0 or 1.1.1.1 Let me know how you get on. Edited December 16, 2011 by Druid_ i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
Jona33 Posted December 16, 2011 Posted December 16, 2011 Easiest way I find which will always spawn a group (only one). Once:Unit in Zone: (A-10):Set flag 1 Mission Start:Random (50%): Set flag 2 Mission start:Random(50%): Set flag 3 Once: Flag 1 is true&flag 2 is true&flag 3 is true:ACtivate group one. Once:Flag 1 is true&Flag 2 is true&flag 3 is false: Activate group 2. Once:Flag 1 is true&Flag 2 is false&flag 3 is true;Activate group three. Once:Flag 1 is true&Flag 2 is false&flag 3 is false:Activate group three. Always remember. I don't have a clue what I'm doing
Druid_ Posted December 17, 2011 Posted December 17, 2011 ..... To get a RANDOM condition to work you need a trigger which is checked only once (not frequently). The only trigger for this is MISSIONSTART. Ahh I think you misunderstood my prev post, my testing comment was in relation to the link I posted and not the MISSION START / ONCE random problem. Nice explanation though. Cheers i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
STP Dragon Posted December 17, 2011 Posted December 17, 2011 Ahh I think you misunderstood my prev post, my testing comment was in relation to the link I posted and not the MISSION START / ONCE random problem. Nice explanation though. Cheers Ahhhh OK, sorry dude. :thumbup: Homepage: Spare-Time-Pilots DCS:BlackShark v1.0.2: BLINDSPOTs EditorMod DRAGONs ArmA2-Sounds DRAGONs BS1 TRAININGPACK DRAGONs MISSIONPACK [bS & FC2] DCS:World: TM WARTHOG PROFIL FOR BS2 DRAGONs BS2_TRAININGPACK DRAGONs TRAININGPACK DRAGONs MISSIONPACK
MadTommy Posted December 18, 2011 Posted December 18, 2011 I am simply looking to randomly activate one of four groups, each with a 25% chance of being picked. There is a pretty simple and robust way to do this. I use it on almost all my missions. Mission Start > Random 50% > Set Flag 1 Mission Start > Random 50% > Set Flag 2 Once > Flag 1 True & Flag 2 True > Set Flag 3 Once > Flag 1 False & Flag 2 True > Set Flag 4 Once > Flag 1 True & Flag 2 False > Set Flag 5 Once > Flag 1 False & Flag 2 False > Set Flag 6 Once > Flag 3 True > Activate Groups 1 Once > Flag 4 True > Activate Groups 2 Once > Flag 5 True > Activate Groups 3 Once > Flag 6 True > Activate Groups 4 Flag 3 - 6 all have a 25% chance of being active, only one can become active. :pilotfly: i5-3570K @ 4.5 Ghz, Asus P8Z77-V, 8 GB DDR3, 1.5GB GTX 480 (EVGA, superclocked), SSD, 2 x 1680x1050, x-fi extreme music. TM Warthog, Saitek combat pro pedals, TrackIR 4
STP Dragon Posted December 19, 2011 Posted December 19, 2011 Brilliant! MadTommy :thumbup: Homepage: Spare-Time-Pilots DCS:BlackShark v1.0.2: BLINDSPOTs EditorMod DRAGONs ArmA2-Sounds DRAGONs BS1 TRAININGPACK DRAGONs MISSIONPACK [bS & FC2] DCS:World: TM WARTHOG PROFIL FOR BS2 DRAGONs BS2_TRAININGPACK DRAGONs TRAININGPACK DRAGONs MISSIONPACK
Weta43 Posted December 19, 2011 Posted December 19, 2011 (edited) Here's something half finished that I think has what you're after but using the set flag between triggers... Fly into an 'on station' zone, get assigned one of 5 tasks (gives a bulls reference, & a JTAC contact name & Hz). At the moment when you've finished one it assigns another ( I think - I can't remember where I got to with it.) maybe you have to go back into the 'on station' zone - if not it should be easy enough to finish that off & make it that you have to go back to the zone. Uploaded because there's no scripts in it just triggers to get the same effect.5 scenario Trigger template F.miz Edited December 19, 2011 by Weta43 Cheers.
Habu23 Posted December 19, 2011 Author Posted December 19, 2011 Hello all, Thank you all for your feedback and guidance. I am almost finished with my randomized mission and i'm confident that it will not disappoint! I decided to go with a framework that incorporated triggers rather than scripts to insure that the mission will survive upcoming patches. Habu [sIGPIC][/sIGPIC]
Grimes Posted December 29, 2011 Posted December 29, 2011 Figured I oughta post in here rather than making a different thread, but has anyone tested the "flag set random value" trigger action to see if it has any statistical tendency? Specifically in picking certain numbers or a range of numbers within the defined value? The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
HiJack Posted December 29, 2011 Posted December 29, 2011 (edited) I did a test with 16 random flags in FC2 making units activate randomly and flares go off in front of the car for different situations when mission loaded. I then ended up with a mission with 8 initial starts and 8 different location triggers (and of course 256 different combinations). It works of course but I did not do a statisticly evaluation of the trigger if that is what you want. And I must admit DCS is now much more advanced in using the random features. Edited December 29, 2011 by HiJack
Grimes Posted January 2, 2012 Posted January 2, 2012 Decided to test the idea out a little and put the results into some statistics. Test Premise: Record the time it takes for a random flag value to equal a specific number 10 separate times. Test Setup: Continuously evaluated a trigger "Time is more than 0> set flag random value, flag 1 between 1 and 10. I had 10 triggers, numbered 1 to 10 that check flag 1 = x > Flag 1x increase by 1 At the end I had 10 triggers number 1 to 10 that checked "once flag 1x = 10 to blow up a unique unit". The explosion was so I can record the time in the mission debrief log since they removed flag reporting from the debrief. (Still sad about that) I ran the test 5 times, all in real time. Units are in seconds. [TABLE]Test 1 Test 2 Test 3 Test 4 Test 5 Average Random (1-20) 121 129 124 94 76 108.8 Unit 1 301 138 107 93 54 102 98.8 Unit 2 240 74 105 84 89 93 89.0 Unit 3 211 96 70 60 92 145 92.6 Unit 4 190 99 99 57 134 92 96.2 Unit 5 244 100 95 67 129 100 98.2 Unit 6 171 89 78 107 121 125 104.0 Unit 7 174 99 74 116 76 107 94.4 Unit 8 260 88 59 167 189 61 112.8 Unit 9 212 101 88 81 67 88 85.0 Unit 10 207 100.5 90.4 95.6 104.5 98.9 98.0 Overall Average 221 138 129 167 189 145 153.6 Average High 301 74 59 57 54 61 61.0 Average Low 171 [/TABLE] The good news is the averages stayed... average, while having the occasional flag be abit unlucky. I'm sure with additional tests the averages would be a little more equal. Unfortunately what it doesn't tell us is the final value of each flag at the end of the test. This table simply shows how long it took to get to 10. The column on the far right was me being curious, but not caring enough to do 4 more tests or to equally distribute 10 choices. I simply adjusted the max random value to 20. I was curious if it would result in approx 2x the time to achieve a complete data set. However it did continue the trend that the minimum flag value is not well liked. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
HiJack Posted January 2, 2012 Posted January 2, 2012 Nice Grimes! Running the check in multiplayer and using ServMan on the server will give you a better and detailed log. You can set the log level to "Insane" as Pansertard described it to me. I think there are like 4 log levels. Check it out :D (HJ)
Recommended Posts