Skip to main content

The "array_shuffle" Function

Syntax#

array_shuffle(id);
ArgumentTypeDescription
idarrayThe index of a previously-created array to modify

Description#

Shuffles the contents of an array, resulting in values being stored in random order.

To shuffle a multidimensional array, input any parent arrays before the child array to be shuffled, e.g. my_array[0][0].

Note that for development builds, GameMaker will use the same random seed, meaning results will always randomize the same way every time the game is restarted. To avoid this behavior, use the built-in randomize function to create a new seed.

Example#

array_shuffle(my_array);
array_shuffle(my_array[0][0]);