View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0025550Runner[All Projects] HTML5Public2017-02-03 14:402017-03-17 11:30
Assigned ToFritz 
PriorityNoneSeverityC - GeneralReproducibility<25%
Platform OS OS Version
Summary0025550: HTML5: ds_list_shuffle does not work as intended
DescriptionThis is the code you're using to shuffle a ds_list in JS exports:

this._Ve.sort(function () {
return 0.5 - Math.random();

This is not a valid way to shuffle an array, since it will not distribute the numbers in a random fashion. Please see the comments on this stackoverflow issue for an explanation: [^]

The attached .gmz will, when the user presses space, create a ds_list of the numbers 1-9 and shuffle them. This is done 10,000 times and the first number is recorded.
Debug messages of the frequency of each first number and then the average value are shown in the console and a popup of the average is shown
Steps To ReproduceRun the attached .gmz
Set the target to Windows
Run the project and press space
Notice that the number that is shown in the popup is around 5
Look at the compile window and see that the frequency is equally spread
Set the target to HTML
Run the project and press space
Notice that the number that is shown in the popup is around 2.6
Look at the Developer console window and notice that the frequency is heavily weighted towards the lower values.
Additional InformationOriginal helpdesk ticket: [^]
1.4 Version1-4-1763
2.x Runtime Version
2.x Runtime Version Verified In
Attached Files? file icon SortFail.gmz [^] (221,888 bytes) 2017-02-03 14:41

- Relationships

-  Notes
Fritz (Developer)
2017-02-27 17:11

Ross Manthorp (Administrator)
2017-03-17 11:30

Verified. Closing.

Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker