Howdy, Stranger!

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

Supported by

[solved] updating variable

edited March 2015 in OpenSesame

Hi all!

I'm having some troubles in programming an experiment. In particular I'm trying to update a variable after the subject's response.
I've declared my variables at the beginning of the experiment in an inline code:

exp.set('acc_id1', 0)
exp.set('acc_id2', 0)

After the subject's response I've inserted an inline code to update the variables:

err_corr = self.get('correct')
if self.get('id') == '1': # the id refers to different images, to keep track of the accuracy for each images independently
if err_corr == '1'
exp.set('acc_id1', self.get('acc_id1')+1)
else:
exp.set('acc_id1', self.get('acc_id1')+0)
else:
if err_corr == '1'
exp.set('acc_id2', self.get('acc_id2')+1)
else:
exp.set('acc_id2', self.get('acc_id2')+0)

The experiments works but when I look at the results the values of my variables are always 0, as I declared them at the beginning of the experiment.

I've also tried with:

err_corr = self.get('correct')
if self.get('id') == '1': # the id refers to different images, to keep track of the accuracy for each images indipendentely
if err_corr == '1'
acc_id1 = self.get('acc_id1')+1
else:
acc_id1 = self.get('acc_id1')+0
else:
if err_corr == '1'
acc_id2 = self.get('acc_id2')+1
else:
acc_id2 = self.get('acc_id2')+0

but the result doesn't change.
Any suggestions?

Thank you in advance!

Cheers,
Andrea

Comments

  • edited 2:42PM

    I'm sorry for the code format! I try again!

    Here it is the code I used to declared the variables:

    exp.set('acc_id1', 0)
    exp.set('acc_id2', 0)
    

    And this is the code I used to update the variables:

    err_corr = self.get('correct')
    if self.get('id') == '1':
        if err_corr == '1':
            exp.set('acc_id1', self.get('acc_id1')+1)
        else:
            exp.set('acc_id1', self.get('acc_id1')+0)
    else:
        if err_corr == '1':
            exp.set('acc_id2', self.get('acc_id2')+1)
        else: 
            exp.set('acc_id2', self.get('acc_id2')+0)
    

    I've also tried with:

    err_corr = self.get('correct')
    if self.get('id') == '1':
        if err_corr == '1':
            acc_id1 = self.get('acc_id1')+1
        else: 
            acc_id1 = self.get('acc_id1')+0
    else:
        if err_corr == '1':
            acc_id2 = self.get('acc_id2')+1
        else: 
            acc_id2 = self.get('acc_id2')+0
    

    but the result doesn't change....

  • edited 2:42PM

    Hi Andrea,

    The problem is simply that you're comparing an int with a str. For example, Python will evaluate this as False: 1 == '1'. So the solution would simply be to compare err_corr to an int, like so:

    if self.get('id') == 1:
    

    Does that make sense? For more information about how OpenSesame deals with variable types, see:

    Cheers!
    Sebastiaan

  • edited 2:42PM

    It absolutely makes sense!!
    Thank you so much!

    Andrea

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