Jump to content
ArmaMan360

Best way to get true random values?

Recommended Posts

I got these arrays:

_city = ["city1","city2","city3","city4","city5","city6","city7","city8","city9","city10","city11","city12","city13","city14","city15","city16","city17","city18","city19","city20","city21","city22","city23","city24","city25","city26","city27","city28","city29","city30","city31","city32","city33"];

_base = ["base1","base2","base3","base4","base5","base6","base7","base8","base9","base10","base11","base12","base13","base14","base15","base16","base17","base18","base19","base20","base21","base22"];

_allloc = ["city1","city2","city3","city4","city5","city6","city7","city8","city9","city10","city11","city12","city13","city14","city15","city16","city17","city18","city19","city20","city21","city22","city23","city24","city25","city26","city27","city28","city29","city30","city31","city32","city33","base1","base2","base3","base4","base5","base6","base7","base8","base9","base10","base11","base12","base13","base14","base15","base16","base17","base18","base19","base20","base21","base22"];

These are 3 arrays, _city = 33 values, _base = 22 values, and _allloc = 55 values. Each is a marker name for random mission location. So I will be utilizing a value from only one of these 3 main arrays at a time.

 

I read about an issue with bis_fnc_selectrandom "leaving out" the first and last value and more probability towards whats in between.

 

Which is the best way now to return a truely random value which is like throwing a 6-sided die, where the possibility throughout is 1/6.

 

Any of the following 3 or whatever the geniuses in the community would like to suggest. :)

_pos = _city Bis_fnc_selectRandom; // or
_pos = floor (random _city); // or
_pos = round random _city; //

By the way I am running 1.52 Arma client not Dev Build as there changes to the selectrandom i guess :)

Thanks :)

Share this post


Link to post
Share on other sites

Give this a try

_pos = _city select (floor (random (count _city)));
  • Like 1

Share this post


Link to post
Share on other sites

 

Give this a try

_pos = _city select (floor (random (count _city)));

What about "-1" at the end? This way it'll ignore the last value imho.

Share this post


Link to post
Share on other sites
I read about an issue with bis_fnc_selectrandom "leaving out" the first and last value and more probability towards whats in between.

 

_one = 0;
_two = 0;
_three = 0;
_four = 0;
_five = 0;

for "_i" from 1 to 100000 do
{
    _num = [1,2,3,4,5] call BIS_fnc_selectRandom;
    
    switch (_num) do {
        case 1: { _one = _one + 1 };
        case 2: { _two = _two + 1 };
        case 3: { _three = _three + 1 };
        case 4: { _four = _four + 1 };
        case 5: { _five = _five + 1 };
    };
    hintSilent format ["One: %1\nTwo: %2\n Three: %3\n Four: %4\n Five: %5\n",_one,_two,_three,_four,_five];
};

Whatever you heard, it's not true ;)

 

Share this post


Link to post
Share on other sites
_one = 0;
_two = 0;
_three = 0;
_four = 0;
_five = 0;

for "_i" from 1 to 100000 do
{
    _num = [1,2,3,4,5] call BIS_fnc_selectRandom;
    
    switch (_num) do {
        case 1: { _one = _one + 1 };
        case 2: { _two = _two + 1 };
        case 3: { _three = _three + 1 };
        case 4: { _four = _four + 1 };
        case 5: { _five = _five + 1 };
    };
    hintSilent format ["One: %1\nTwo: %2\n Three: %3\n Four: %4\n Five: %5\n",_one,_two,_three,_four,_five];
};

Whatever you heard, it's not true ;)

 

 

I was referring to this :https://forums.bistudio.com/topic/131090-round-random-unexpected-behaviour-round-floor-expected-behaviour/ :)

Share this post


Link to post
Share on other sites

The variation with BIS_fnc_selectRandom is ~ 1%, so pretty much negligible. It will probably even become zero if  n - > infinite

Share this post


Link to post
Share on other sites

The variation with BIS_fnc_selectRandom is ~ 1%, so pretty much negligible. It will probably even become zero if  n - > infinite

Hmmmm. But when I restarted the mission over and over again, it frequently chose the nearer positions as the markers with higher numbers in their names were placed farther away.

I donno man. Maybe a better way? You personally use selectrandom?

Share this post


Link to post
Share on other sites
Hmmmm. But when I restarted the mission over and over again, it frequently chose the nearer positions as the markers with higher numbers in their names were placed farther away.

 

 

Probably just a coincidence.

Share this post


Link to post
Share on other sites

BIS_fnc_selectRandom use to be different and what you read in that other thread was correct.

BIS_fnc_selectRandom is now the same as - ARRAY select (floor(random (count ARRAY)))

either of which is the best option for a good spread of results.

  • Like 1

Share this post


Link to post
Share on other sites

BIS_fnc_selectRandom use to be different and what you read in that other thread was correct.

BIS_fnc_selectRandom is now the same as - ARRAY select (floor(random (count ARRAY)))

either of which is the best option for a good spread of results.

Thank you Larrow and R3Vo !!! :D

  • Like 1

Share this post


Link to post
Share on other sites

BIS_fnc_selectRandom use to be different and what you read in that other thread was correct.

 

 

Thanks for the info Larrow, that was probably before my time.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the info Larrow, that was probably before my time.

 

R3vo, you have helped me out on quite a lot of occasions. :)

I Appreciate it bro. :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×