I want to shuffle the numbers in my array
variable once, so I called my Shuffle
method from Start()
.
I then attempt access the sh
There is still a problem with this algorithm. Imagine an array with values 0, 1, 2 The possible shuffles should be:
0 1 2 0 2 1 1 0 2 1 2 0 2 0 1 2 1 0
and the probability of each case should be the same. To achieve this modify
int r = _random.Next(0, n+1);
Because the max value of Random.Next
is exclusive (see doc)