Howdy, Stranger!

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

Supported by

[solved] How to generate loop variable values based on others within a loop cycle?

edited October 2013 in OpenSesame

I am using a loop item to set up values for 5 variables for a single cycle (called "0" in the OS script screen). One of the variables (a_one) is to be a randomly generated value in {0,1}, which gives setcycle 0 a_one "=randint(0,1)" in the script-view of the loop. Each successive variable value is set conditioned on a_one, a_two, etc, so that a_two =1-self.get('a_one'), and so on.

But after I try doing this daisy-chain for more than 2 variables, the order gets messed up in the script-view of the loop, which results in a variable being used before it is defined.

So, for just a_one and a_two, the script-view gives the following, which works:

set repeat "1"
set description "Repeatedly runs another item"
set item "sequence"
set column_order "a_one;a_two"
set cycles "1"
set order "random"
setcycle 0 a_one "=randint(0,1)"
setcycle 0 a_two "=1-self.get('a_one')"
run sequence

But if I try adding a third variable that depends on a_two, then I get an error. The following script-view shows up after I add the third variable:

set repeat "1"
set description "Repeatedly runs another item"
set item "sequence"
set column_order "a_one;a_two;a_three"
set cycles "1"
set order "random"
setcycle 0 a_three "=1-self.get('a_two')"
setcycle 0 a_one "=randint(0,1)"
setcycle 0 a_two "=1-self.get('a_one')"
run sequence

Notice above that a_three has a setcycle that occurs before a_one, even though the set column_order has a_one, followed by a_two, followed by a_three. Even if I put in some fixed number for a_three (e.g. '0'), it gets its setcycle performed first. Furthermore, if I rearrange the setcycle commands in the script-view of the loop, and press 'apply and close', and then look again at the script-view, the malformed order is back again.

Can anyone suggest how I would go about setting one variable after another in a loop, where each is based on one or more variables being set before it?

Thanks!

Comments

  • edited 4:56PM

    Can anyone suggest how I would go about setting one variable after another in a loop, where each is based on one or more variables being set before it?

    The order in which the columns are set is essentially random, so you cannot assume a specific order. The visible order of the columns is kept constant in the GUI, but that's just because it's annoying if the columns keep jumping around (which they used to).

    To have variables depend on other variables, the best strategy is simply to insert a short inline_script at the start of the trial_sequence. In your case, this would be something like this:

    exp.set('a_two', 1-self.get('a_one'))
    exp.set('a_three', 1-self.get('a_two'))
    

    Cheers!
    Sebastiaan

    (Btw, in your example a_three is always equal to a_one.)

  • edited 4:56PM

    Okay, I'll set it up in a script at the beginning of the sequence.

    Thank you for a very prompt follow-up!

    (Yes, I realize that a_three will be equal to a_one, but this was a simplified example of the behavior.)

    Cheers!

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