Guys I need a help .
I have array .
example
1, 2,3,4,5,6,7,8,9,
now i need a shuffle the numbers.
when i use random operator . i have shuffled numbers but there are repeted ..
i need what numbers don;t repeated like 3,6,4,9,1,7,5,8,2
This topic covers shuffling cards but it is applicable:
http://www.scirra.com/forum/randomized-an-array-for-a-deck-of-cards_topic45833.html
R0J0hound
I have read this topic .. but resolve problem whit plugin Randomized Array
scirra.com/forum/plugin-randomarray_topic45277.html
10x for answering:)
I wrote a tutorial about this topic
scirra.com/tutorials/469/implementing-fisher-yates-shuffling-algorithm
I wrote a tutorial about this topic https://www.scirra.com/tutorials/469/implementing-fisher-yates-shuffling-algorithm
https://www.scirra.com/tutorials/469/implementing-fisher-yates-shuffling-algorithm
10x a lot of .. I understand :)
Another great tutorial that may help you:
https://www.scirra.com/tutorials/315/generating-random-numbers-without-duplicates
Develop games in your browser. Powerful, performant & highly capable.
Also have a look at my solution that I used
scirra.com/forum/generate-unique-times-tables-questions-array_topic65058.html
It doesn't do the shuffle but it would be pretty easy to implement.
Just loop through the array use a temp variable to hold a value so you can swap two array elements.
kittiewan's solution theoretically can takes forever. Fisher Yates is a O(n) solution. So it guarantees a maximum n times loop.