I am trying to replace the “random.shuffle” function so that I can upload my experiment to Pavlovia as I cannot import anything when I want to use it in Pavlovia.
So far I have found the Knuth Shuffle to do this in JS language:
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
When I change the code setting to ‘both’ and try and insert this, it disappears after running the experiment. I want to shuffle 3 lists so that my stimuli appear randomly. It worked perfectly with random.shuffle().
Apologies for the many posts lately. Hopefully someone will be able to help with this!
Does anybody have any suggestions for this?
Best regards,
Snoek