Adaptive Staircase Help Needed

I need some help going about building an adaptive staircase.

Each participant has to complete 32 trials. I have a bank of easy, medium and hard images.

All participants start in the easy bank. Once they have 2 correct answers in a set of 3 trials, they can move up to the medium bank. Again, once they have 2 correct answers in a set of 3 trials, they can move up to the hard bank. If they get only 1 correct answer in 3 trials in the medium or hard bank they move down a level. Once they have completed 32 trials in total, the experiment is over.

Do you guys have any idea how I can go about this?

Thanks!!

You will need to handle your image names in code, because switching conditions files probably won’t work here. So create a routine that will show your image and insert a loop around it with an nReps of 32. On that routine, insert a code component from the “custom” components panel, and in its “begin experiment” tab, put something like this:

easy_images = [f'images/easy_{i}.jpg' for i in range(32)] 
medium_images = [f'images/medium_{i}.jpg' for i in range(29)] 
hard_images = [f'images/hard_{i}.jpg' for i in range(26)] 

# randomise if needed:
shuffle(easy_images)
shuffle(medium_images)
shuffle(hard_images)

to create three lists of images. Modify to fit the naming convention and location of your files (e.g. images/easy_0.jpg and so on). I’ve assumed you’ll need a minimum of 32 easy images, and 29 medium and 26 hard images, to cover the extreme cases where someone does either the worst or best possible performance.

Then in the “Begin” routine tab, something like this:

# set things up on the first trial only:
if name_of_your_loop.thisN == 0:
    bank = 'easy'
    current_correct = 0
    current_three = 0

    image_lists = {'easy': easy_images,
                   'medium': medium_images,
                   'hard': hard_images}

# select the image for this trial:
current_image = image_lists[bank].pop()
# record values in the data:
thisExp.addData('bank', bank)
thisExp.addData('image', current_image)
thisExp.addData('bank_trial', current_three)
thisExp.addData('current_correct', current_correct)

Then in the “end routine” tab, something like this to keep track of performance and change banks if needed. I don’t know how you will be deciding if a trial is correct or not, so am just using a variable called trial_correct to represent the result:

if trial_correct:
    current_correct = current_correct + 1
current_three = current_three + 1

# what to do after three trials
if current_three == 2: # remember, 0-based 
    if current_correct >= 2: # go up a level
        if bank == 'easy':
            bank = 'medium'
        elif bank == 'medium':
            bank = 'hard'
    else: # drop a level
        if bank == 'medium':
            bank = 'easy'
        elif bank == 'hard':
            bank = 'medium'