List Shuffle Fix & Test

Reporter: RobertBColton  |  Status: open  |  Last Modified: May 12, 2019, 01:20:47 PM

Updated the CI test I just added for data structures to prevent #1107 from coming back. I wasn't sure if I could get this to work deterministically, that's why It was not included in #1650 with my other list tests. Apparently I can test it out reliably, hence I am submitting this pull request.

The documentation does explicitly state that list shuffle should be connected with the game's random seed.

NOTE: This function will shuffle the list items to the same positions every time the game is run afresh due to the fact that GameMaker: Studio generates the same initial random seed every time to make debugging code a far easier task. To avoid this behaviour use randomize at the start of your game. This is only true when testing and debugging the game, as the final executable package will not show this behaviour and will be random every play.
https://docs.yoyogames.com/source/dadiospice/002_reference/data%20structures/ds%20lists/ds_list_shuffle.html

RobertBColton  
No, you didn't and the CI is actually full of non-fatal errors about that. But yeah, thanks for putting the kibosh on this, you are right that #1324 is a blocker to merging this.
RobertBColton  

Ok, now that #1706 is in, this should pass deterministically.
RobertBColton  

Alright, I ran onto a bug in the shuffle function, it's never moving the last element of the list. Once I fix it, I also know how to regression test that.

var list_str;
list_str = ds_list_create();

ds_list_add(list_str, "bank");
ds_list_add(list_str, "alarm");
ds_list_add(list_str, "cash");

for (var i = 0; i < 6; ++i) {
	random_set_seed(69378);
	ds_list_shuffle(list_str);
	show_message(string(ds_list_find_value(list_str, 0)) + " " +
				 string(ds_list_find_value(list_str, 1)) + " " +
				 string(ds_list_find_value(list_str, 2)));
}

codecov[bot]  

Codecov Report

Merging #1654 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1654      +/-   ##
==========================================
+ Coverage    22.1%   22.12%   +0.02%     
==========================================
  Files         166      166              
  Lines       16654    16654              
==========================================
+ Hits         3681     3685       +4     
+ Misses      12973    12969       -4
Impacted Files Coverage Δ
...stem/Extensions/DataStructures/data_structures.cpp 46.19% <0%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a176df1...8c4c2e0. Read the comment docs.

Please sign in to post comments, or you can view this issue on GitHub.