Fixed world.rand.shuffle for arrays of length 0 or 1.

This commit is contained in:
Nick Winter 2015-03-06 17:35:11 -08:00
parent 09e969405a
commit 6954175fa8

View file

@ -41,6 +41,7 @@ class Rand
# shuffle array in place, and also return it
shuffle: (arr) =>
return arr unless arr.length > 2
for i in [arr.length-1 .. 1]
j = Math.floor @randf() * (i - 1)
t = arr[j]