Howdy, Stranger!

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

Supported by

pseudo-randomization in OSWeb and setting the underscores of the associated character in SPR

Hi, I am currently designing an opensesame experiment that will later be carried out on Jatos. Now I have encountered two problems. So I am asking for your help here. 

1. I have a total of 3 categories of items: category 1 (abbreviated as C1) and category 2 (C2) both contain critical items, but they are different from each other. Category 3 (F) contains the fillers. Now I want to pseudorandomize the items so that the critical items from the same category (C1 or C2) do not appear consecutively. The fillers, on the other hand, can appear one after the other. The possible arrangements are, for example, as follows:

C1-C2-F-C1...

C1-F-C1...

C1-F-F-C1...

How can I implement this pseudo-randomization in OSWeb?

2. The underscores that represent the words that have already been shown or will be shown are not as wide as the characters. That is why the display always jumps back and forth. 

The following pictures show the problem:

As you can see, the underscore is shorter than the phrase associated with it. 

On another program, the length of the underscore can correspond to that of the character, as in the following screenshot:

Do you have a solution as to how can I adjust the length of the underscore so that it matches the length of the associated character? 

I look forward to any advice and thanks a lot in advance! 

Lili

Comments

  • Hi @deandgei ,

    Loop constraints are not supported in OSWeb, as you probably noticed. So you need to write a script that applies these constraints for you. The general logic is always the same:

    • Create a list (or array in JavaScript) of conditions
    • Shuffle the conditions until the constraints (which depend on the experiment) are met
    • Then use one element from the conditions on each trial

    In your case, the constraint boils down to checking whether there are two consecutive conditions that are identical and that are not 'F'. The script below shows how you can do that. This would go in the prepare phase of an inline_javascript at the start of the experiment.

    /**
     * Shuffles the order of elements in an array.
     **/
    
    function shuffle(array) {
        let counter = array.length
        while (counter > 0) {
            let index = Math.floor(Math.random() * counter)
            counter--
            let temp = array[counter]
            array[counter] = array[index]
            array[index] = temp
        }
        return array
    }
    
    
    /**
     * Checks whether the conditions array conditions two identical and consecutive
     * elements that are not 'F'.
     **/
    
    function needsShuffle(conditions) {
        for (let i = 0; i++; i < conditions.length - 1) {
            if ((conditions[i] !== 'F') && (conditions[i] === conditions[i + 1])) {
                return true
            }
        }
        return false
    }
    
    
    // Shuffle the array of conditions until it doesn't need shuffling anymore
    let conditions = shuffle(['C1', 'C2', 'F', 'C1', 'C2', 'F'])
    while (needsShuffle(conditions)) {
        conditions = shuffle(conditions)
    }
    
    // Assign as experimental variable so we can use it in other scripts
    vars.conditions = conditions
    

    Then, at the start of each trial, again in the prepare phase of an inline_javascript , you simply get the last element from the array and assign it to the condition variable, which you can then use in the normal way.

    // Pop the last element from the conditions array
    vars.condition = vars.conditions.pop()
    

    Does that make sense?

    Regarding the length of the characters: Chinese characters are essentially a monospace font where each character sits in a box of a fixed size. Latin characters are not, and even a monospace Latin font will not be matched in size to Chinese characters. The most pragmatic way to work around this is to use one of the Chinese punctuation characters instead of an underscore, because these are matched in length to the Character boxes. For example, below you can see that the Chinese full stop actually matches the widths of the characters:

    Hope this helps!

    — Sebastiaan

  • Hi @sebastiaan,

    thank you very much for your detailed reply.

    I have copied your code in the prepare phase of an inline_javascript at the start of the experiment and also added vars.condition = vars.conditions.pop() at the start of each trial in the prepare phase of an inline_javascript

    1. I have changed the for loop in the needsShuffle(conditions) a little, now it looks like this: for (let i = 0; i <= conditions.length - 1;i++)
    2. This is my let conditions


    After I saved everything, two critical items belong to the same type would still show continuously. I tried to solve this problem these three days, but I can still not figure it out. I am sorry if it is too basic. Could you please help me solve this problem? 

    This is where I fill my stimulus. In the column "condition", the condition in row 1-10 is "F", row 11 -17 is condition "C1", row 18-25 is condition "C2".

    Besides, using one of the Chinese punctuation characters instead of an underscore solves the problem with the display.

    Thank you very much for your help! I am looking forward to your advice.

    Lili

  • Hi @deandgei ,

    These scripts replace the condition column in the block loop (so this column should be removed from new_loop), and the second script should be at the start of each trial, so at the start of trial_sequence_1.

    Looking at your loop table, your situation is a bit more complex than I initially thought though, because you have a lot of other variables that, I assume, should be kept together with the condition variable. Is that right?

    What you could do is define a slightly more complex array of conditions, where each condition is itself an object with multiple variables (instead of only the name of the condition). For two trials and two variables (condition and ID ) this would look like this:

    let conditions = [
        {'condition': 'C1', 'ID': 1},
        {'condition': 'F', 'ID': 2}
    ]
    

    This would also require a few tweaks to the other scripts. Specifically, you'd have to change needsShuffle() so that it compares the condition variable only. And you'd need to change the script at the start of the trial so that each variable is assigned to an experimental variable (i.e. as a property of the vars object). I'll leave that to you to play around with though!

    — Sebastiaan

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