Description of the problem: I use builder view and have a custom code in it that shuffle the list of numbers that need to be presented to participants. I’ve recently changed my code in order to counterbalance trials in my experiment. Here is the code:
def shuffle_list(List):
counta=0
countb=0
countc=0
for ii in List:
shuffle(ii)
d = difFinder(ii)
if(d == 1):
counta += 1
elif(d == 2):
countb += 1
elif(d == 3):
countc += 1
if(counta == countb and counta == countc):
shuffle(List)
return List
else:
return shuffle_list(List)
def difFinder(i):
if i[0] != i[1] and i[0] != i[2]:
return 1;
if i[1] != i[0] and i[1] != i[2]:
return 2;
if i[2] != i[0] and i[2] != i[1]:
return 3;
While running locally it’s ok but online, it gives this error:
InternalError: too much recursion
How can I fix the code to prevent this error?
Thank you for your help.
Hi @wakecarter . Thanks for your suggestion. I did what you just said but I get this error:
TypeError: shuffle is not a function
I didn’t have this problem when my codes were in begin experiment tab. I just moved whatever was in “begin experiment” to “before experiment”.
And moving my codes to before experiment didn’t have any effect on this error of too much recursion. @sotiri Do you happen to know what should I do with this error? How can I fix it?
And I should mention that the error while running the experiment in Chrome is like this:
RangeError: Maximum call stack size exceeded
Which I searched and found out that these are kind of the same errors.
In my experiment, I really need to counterbalance the number of times the first list differs from the other two, the second list differs from the other two, and the third list differs from the other two.
If you think I can achieve the same goal with another programming for this or by including a function or something in my jscode it would help me a lot.