Created
January 7, 2013 00:40
-
-
Save mstevenson/4471373 to your computer and use it in GitHub Desktop.
Fisher-Yates shuffle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = branches.Length - 1; i > 0; --i) { | |
int next = Random.Range (0, i + 1); | |
Transform temp = shuffled [i]; | |
shuffled [i] = shuffled [next]; | |
shuffled [next] = temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment