2023-09-11 16:08:58 +02:00
|
|
|
function angle_random_eval(range, seed = undefined) {
|
|
|
|
if(is_real(range))
|
|
|
|
return range;
|
|
|
|
|
|
|
|
if(seed != undefined) random_set_seed(seed);
|
|
|
|
|
2023-09-19 12:53:24 +02:00
|
|
|
if(array_empty(range)) return 0;
|
|
|
|
|
2023-09-11 16:08:58 +02:00
|
|
|
if(array_length(range) < 2)
|
2023-09-19 12:53:24 +02:00
|
|
|
return range[0]
|
2023-09-11 16:08:58 +02:00
|
|
|
else if(array_length(range) == 2)
|
|
|
|
return irandom_range(range[0], range[1]);
|
|
|
|
else if(array_length(range) > 2) {
|
|
|
|
switch(range[0]) {
|
|
|
|
case 0 : return irandom_range(range[1], range[2]);
|
|
|
|
case 1 : return irandom_range(range[1] - range[2], range[1] + range[2]);
|
|
|
|
case 2 : return choose(irandom_range(range[1], range[2]), irandom_range(range[3], range[4]));
|
|
|
|
case 3 : return choose(irandom_range(range[1] - range[3], range[1] + range[3]), irandom_range(range[2] - range[3], range[2] + range[3]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-19 12:53:24 +02:00
|
|
|
return array_safe_get(range, 0);
|
2023-09-11 16:08:58 +02:00
|
|
|
}
|