View Issue Details

IDProjectCategoryView StatusLast Update
0025550Runner[All Projects] HTML5Public2017-03-17 11:30
ReporterzenAssigned ToFritz 
PriorityNoneSeverityC - GeneralReproducibility<25%
Status ClosedResolutionFixed 
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: http://stackoverflow.com/a/18650169/2382729

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: http://help.yoyogames.com/tickets/117831
1.4 Found In1-4-1763
2.x Runtime Found In
2.x Runtime Verified In

Activities

Kevin Brown

2017-02-03 14:41

Manager  

SortFail.gmz (221,888 bytes)

Fritz

2017-02-27 17:11

Developer   ~0051763

7a47d03c3985491c254cf2e3945ba034655ecfc2

Ross Manthorp

2017-03-17 11:30

Adminstrator   ~0052288

Verified. Closing.