Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Controlling the randomisation of loop variables

edited July 2015 in OpenSesame

Let's say I want a loop which goes through 6 items (A, B, C, D, E and F) randomly. However, there is a constraint that the first item in the loop should be A, B or C and the last item in the loop should be D, E or F; then the middle four elements are random (modulo the items that have already been chosen at the terminals).

How could this be done in OpenSesame?

My understanding is that I would have to split it up into three loops: one for the first element; another for the middle four; and a final one for the last element. I would then have to code some logic into the loop sequence items to ensure items aren't picked more than once (e.g., I could use subject number modulo 3 to determine the first and last, thus knowing what's remaining in the middle; or a permutation matrix generated from a static random seed).

Thanks;
C

Comments

  • edited 1:22AM

    Hi,

    As far as I see, there is no easy and direct way of doing this with the loop item. However, doing it with an inline_script is not much harder. I would do following. First, I'd put a small inline_script in the beginning of your sequence. Furthermore, in the loop item itself, you don't have to put your variable names (A,B,C,..), but just some sort of counter.
    In the inline_script, you can put the actual part that selects the condition or item you need. Something like this, should do:

    import random
    
    # I assume earlier in the experiment you created a list with your items
    # e.g. items = ['A','B','C','D','E','F']
    # this has to be defined outside the loop, in order to make sure that no
    # item does appear more than once
    # counter can be the counter variable that is running in the `loop` item
    
    if counter == 0:
        cur_item = random.choice(['A','B','C'])
        items.remove(cur_item)
    elif counter == 5: # (or whatever the index of the last element is)
        cur_item = random.choice(['D','E','F'])
        items.remove(cur_item)
    else:
        cur_item = items.pop(0)
    
    # anything else that you want to do
    

    Does this do what you had in mind?

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 1:22AM

    Thanks, Eduard

    Yes, this looks like it should work :) Now I've learned that what is declared in inline scripts persists until the end of the experiment it should, like you say, be very easy to get things to run the way I have in mind.

  • edited 1:22AM

    Great to hear. Then I'll mark this discussion as solved. If you happen to have more question don't hesitate to post them again in here.

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games