Task URL https://pavlovia.org/run/Topor/probabilistic-learning-task/html/
Description of the problem: The task is still quite rough around the edges. I am focusing at the moment on translating the code from Python to PsychoPy.
The task has three phases. The first one is a practice phase and it works fine. The second one is a learning phase and this is where a lot of code has been added. I made a threshold that each participant has to reach before they can progress to the last phase of the experiment. I have already translated parts of the code so the task is working to a certain point. As soon as I started translating the code for the performance criterion, the task stopped working. When I run it, a message shows up âloading the experimentâ. I saw on other threads that this means the code is not translated correctly.
This is what I did to establish the criterion
first set of stimuli
sum of correct responses in the last 60 trials in conditions 1 > 12, in conditions 2 > 11 and in condition 3 > 9, there must be at least 60 trials in the training phase
if myCount == 1 and (sum(resplist1[-60:]) > 12 and sum(resplist2[-60:]) > 11 and sum(resplist3[-60:]) > 9 and myCount1 > 59):
practice.finished = True
I understand that Java Script does not have options to easily operate on arrays.
I have created array slices to identify the last 60 trials, and I made a function to sum the array contents. It looks like this:
practiceA = resplist1.slice(-60,)
practiceB = resplist2.slice(-60,)
practiceC = resplist3.slice(-60,)
arrSum = function(arr){
return arr.reduce(function(a,b){
return a + b
}, 0);
}
Corr1 = arrSum(practiceA)
Corr2 = arrSum(practiceB)
Corr3 = arrSum(practiceC)
if (myCount == 1 and Corr1 > 12 and Corr2 > 11 and Corr3 > 9 and myCount1 > 59)){``
practice.finished = true;
}
The empty arrays are stated in the Begin routine
tab.
However, only in the End Routine
tab I included a code that commands how the resplist arrays (used in the Begin routine
tab) should be appended. This was not an issue in PsychoPy, but potentially an issue for JS?:
if(resp.keys == letterA) {
resp1 = 1;
} else {
resp1 = 0;
}
if(resp.keys == letterC) {
resp2 = 1;
} else {
resp2 = 0;
}
if(resp.keys == letterE) {
resp3 = 1;
} else {
resp3 = 0;
}
resplist1.appendChild(resp1)
resplist2.appendChild(resp2)
resplist3.appendChild(resp3)
I will appreciate it if someone can look through the code to see if there is anything obvious that could be wrong. The task overall has more code so it is possible that the pieces are in the wrong place as well.
I will appreciate all help!