Howdy, Stranger!

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

Supported by

[solved] Go from one loop to another

edited September 2014 in OpenSesame

Hi,
I'm new to OpenSesame, so sorry if this is a silly question.
I'm trying to navigate between certain loops. The idea is that a user can score points by answering questions right: if the user has enough points, he or she goes to the next level (which is in a different loop). However, when a person answers questions in the next level wrong, the user goes back to the previous level. I've tried the following things:

This is the inline script in the first loop:

current = exp.get("glob_var")

if self.get('correct_question_response') == 0:
    if current > 0: 
        current=current-1
else:
    current = current +1
exp.set("glob_var", current)
if current < 4: 
    exp.items['experimentloop'].prepare()
    exp.items['experimentloop'].run()

which works fine. It goes to the next loop when needed. In the next loop, I have the following inline script:

current = exp.get("glob_var")
if self.get('correct_question_response') == 0:

    if current > 0: 
        current=current-1
else:
    current = current +1
exp.set("glob_var", current)
if current < 4: 
    exp.items['experimentloop'].prepare()
    exp.items['experimentloop'].run()

When the total of points is lower than four, it does go back to the first loop, however, when the points total is high enough again, you never get back to the second loop again... It just stops.

I've tried adding this to only the first inline script:

if current > 3: 
    exp.items['experimentloop2'].prepare()
    exp.items['experimentloop2'].run()

and then it does go back, but then it keeps repeating the second loop infinitely, even though it's only supposed to run once... I thought inline scripts in a loop applied only to that particular loop, am I wrong?

I hope I made myself clear!

Comments

  • edited 3:56AM

    Hi Floor,

    That's an interesting problem. Your code is already quite good.

    However, what's missing at the moment is a stop criterion. When do you want the experiment to terminate? Once we have established that, we can see how this can be implemented in your experiment. So what are the exact rules of your experiment?

    Also, it would be helpful if you post the full script of your experiment, for example to http://pastebin.com/.

    Cheers!
    Sebastiaan

  • edited 3:56AM

    Hi Sebastiaan,
    Thank you for your answer! Let's say, the experiment has to stop once current == 8. Is there some way to put that in an inline script in the loop?

    Thanks,
    Floor

  • edited 3:56AM

    Hi Floor,

    I think you could make your experiment a bit simpler. Let's assume that you have two sequences, called level1 and level2, which implement your two categories of questions. The logic is, if I understand correctly, that you want to run level1 when glob_var is less than 4, and level2 when glob_var is greater than or equal to 4. When glob_var is 8 you want to break the loop. I think you could implement this purely with conditional statements:

    loop (break-if: [glob_var] = 8, repeat: 10000)
    - sequence
      - level1 (run-if: [glob_var] < 4)
      - level2 (run-if: [glob_var] >= 4)
    

    The repeat value of the loop is set really high so that it's practically infinite.

    That should do the trick, right?

    Cheers,
    Sebastiaan

  • edited 3:56AM

    Hi Sebastiaan,
    yes, thank you for your help! Problem solved :)

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