Skip to content

Instantly share code, notes, and snippets.

@mstevenson
Created January 7, 2013 00:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstevenson/4471373 to your computer and use it in GitHub Desktop.
Save mstevenson/4471373 to your computer and use it in GitHub Desktop.
Fisher-Yates shuffle
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