Skipping to the next game in a condition and counterbalanced loop

Hi! I think I have posted this a couple of times in the forum. I really am not well versed with Python and definitely, any help would be appreciated greatly.

I am having problems skipping a condition in my routine to move onto the next task in the loop. I have a total of 3 games/test, and2 games are counterbalanced and the other should run once the test trial has been completed. For easy reference, I will just name them games A, B, and C.

The structure of the experiment is as follow:
Start

  1. Instruction of practice & Start of Practice round for game A
  2. Instruction of test round & start of Test round of Game A
  3. Instruction of practice & Start of Practice round for game B
  4. Instruction of test round & start of Test round of Game B
  5. Instruction of practice & Start of Practice round for game C
  6. Instruction of test round & start of Test round of Game C
    End
    This is the current set up:

There are 24 stimuli in the practiceLoop that will be separated into 2 rounds of 12 stimuli, where the 2nd round of stimuli will not be presented if the participant scores at least 8 correct in the first 12 rounds and will move onto to the test round, else they will do the 2nd round of practice and if they don’t score at least 8 correct, the test round will be skipped and it will move onto the next game. I have a code as such in the End Routine Tab:

score = score + 1

if practiceLoop.thisN == 11 and score >= 8:
practiceLoop.finished = True

elif practiceLoop.thisN == 23 and score <=5:
practiceLoop.finished = False

It doesn’t seem to be working and the experiment stops if the participant fails the 2nd round of practice as well. I don’t want it to be a sequential score recording and want the scores to be of 2 different rounds (i.e., the score of 1st round should not be added into the 2nd round). Am I doing something wrong, or is the coding wrong?

Hi There,

I think your logic is very close there! Just you might need to reset your score and use a trialN instead of N?
something like

if practiceLoop.thisTrialN == 11 and score >= 8:
    # if this is the 12th trial and the score is above or equal to 8
    continueRoutine = False
    practiceLoop.finished = True
    # reset the score
    score = 0
elif practiceLoop.thisTrialN== 23 and score >5:
    # if this is the 24th trial and the score is above or equal to 5
    continueRoutine = False
    practiceLoop.finished = True
    score = 0
elif practiceLoop.thisTrialN == 23 and score <=5:
    repeat = 1
    score = 0

Here is a demo doing something similar that I hope might help,
Beccapractice-loop-break.psyexp (17.7 KB) answer-list.xlsx (8.6 KB)

Hi! Thank you so much for helping me! But I’m still facing some issues. I’m not sure if it’s because of the confounding language in both the elif parts. Also, why is it trialN instead of N?

elif practiceLoop.thisTrialN== 23 and score >5:
# if this is the 24th trial and the score is above or equal to 5
continueRoutine = False
practiceLoop.finished = True
score = 0
For this logic, for some reason, it stops on the 19th trial instead when the score is equal to 5. I want it to count all the way to the 24th trial before it even proceeds onto the test routine (“startGame” and “trial”)

elif practiceLoop.thisTrialN == 23 and score <=5:
repeat = 1
score = 0
And for this, even if the score is less than 5, it still proceeds onto the test routine which I just want the test routine to be skipped, and continue onto the next game in that condition and counterbalanced loop for participants who don’t score at least 8 from the 13th to 24th trial. Here is the flow of the experiment shown below: