Mantis

View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0025550Runner[All Projects] HTML5Public2017-02-03 14:402017-03-17 11:30
Reporterzen 
Assigned ToFritz 
PriorityNoneSeverityC - GeneralReproducibility<25%
StatusClosedResolutionFixed 
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 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
(0051763)
Fritz (Developer)
2017-02-27 17:11

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

Verified. Closing.


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker