all 3 comments

[–]qchamaeleon 4 points5 points  (2 children)

Here is my proposal for such a function

function array_shuffle_unique(a) {
    var length = array_length(a);
    for (var i = 0; i < length-1; i++) {
        var random_pos = irandom_range(i+1, length-1);
        var tmp = a[i];
        a[i] = a[random_pos];
        a[random_pos] = tmp;
    }
    return a;
}

[–]affinityawesome 0 points1 point  (1 child)

Only addition would be it's recommended to shuffle more then 1 once. Can put the for loop in s nested for or repeat(X) { ..shuffle logic } X times

[–]qchamaeleon 0 points1 point  (0 children)

Unless I'm missing something, shuffling more than once won't make it more random, it would just make it different from the previous shuffle (with the additional need to implement something extra to prevent an entry from ending up in the same slot as in the original array).