krzychuzokecia 717 Posted October 8 Let me preface the following with: I'm not a coder. I know nothing about that stuff, but I do use scripts created by many of talented Arma mission-makers throughout the years. The new 2.18 patch introduces a "fix" to random command - ever since Arma 2 "random X" would generate a random number from 0 to X included. Now, it works in a way that "X" is excluded from the outcome. In a number of third-party scripts I use, random command is used alongside ceil to generate whole numbers from range of 1 to X (0 is technically possible, but very unlikely - see the comment by @hcpookie). x = ceil (random 5) // will return 0, 1, 2, 3, 4 or 5. (0 is very unlikely, but possible, as ceil 0 is 0) The usual use for that is for example randomly selecting some kind of event to happen in a mission, from possible amount of X events. Does this new "fix" to random means we now have to use "ceil random X+1" in such cases? Share this post Link to post Share on other sites
soldierXXXX 107 Posted October 8 Hi, as far as I know this change shouldn't affect any script in particular. While scripters use random x with combination floor, round or ceil then the number always returns integer value. In case the script uses pure random, then the autor probably didn't really needed that specific x value to be included. So that means, if you're using ceil for instance with number 5, it might generate any number between 0 and <5 so like 4.73 can be generated and ceil automatically makes it 5. If you seriously need that value to be included you can probably use linearConversion command with clip value true. something like _wantedNum = 5; _randomIncluded = linearConversion [-0.01,_wantedNum,(random (_wantedNum + 1))-0.01,0,_wantedNum,TRUE]; //should theoretically return numbers between 0 and 5 not tested IMO this change might actually help, because when I used for loop with combination of array select _i in older scripts, I always had to account for that particular case that it didn't choose that last number where no value was defined so I had to do like for "_i" from 0 to (floor (random (count _array -0.1))) do {...(Today I'm usually using forEach loop instead) And since 2.18 it could be same thing without -0.1. It's not really good example to show it on but now it will work like in other programming languages. I think that's why they changed it. 2 1 Share this post Link to post Share on other sites
mrcurry 496 Posted October 9 18 hours ago, krzychuzokecia said: random command is used alongside ceil to generate whole numbers from range of 1 to X... Quote Does this new "fix" to random means we now have to use "ceil random X+1" in such cases? This depends entirely on the use case. If a uniform distribution is required, meaning all outcomes have equal chance to occur, you need a different approach. For a proper uniform random range use: _rand = _min + floor random (_max - _min); Above _max is exclusive and won't be included, if you need inclusive _max use: _rand = _min + floor random (_max - _min + 1); These are both guaranteed to never generate value below _min. It's ofc ok to precompute the brackets into a variable and use that as input to the random call. 1 Share this post Link to post Share on other sites
krzychuzokecia 717 Posted October 9 16 hours ago, soldierXXXX said: While scripters use random x with combination floor, round or ceil then the number always returns integer value. 16 hours ago, soldierXXXX said: So that means, if you're using ceil for instance with number 5, it might generate any number between 0 and <5 so like 4.73 can be generated and ceil automatically makes it 5. Ah yes, now it seems so obvious to me! As I said, I'm not a coder, just some hack messing with stuff I don't understand! Thank you! Share this post Link to post Share on other sites