[solved] updating variable
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
I'm sorry for the code format! I try again!
Here it is the code I used to declared the variables:
And this is the code I used to update the variables:
I've also tried with:
but the result doesn't change....
Hi Andrea,
The problem is simply that you're comparing an
int
with astr
. For example, Python will evaluate this asFalse
:1 == '1'
. So the solution would simply be to compareerr_corr
to anint
, like so:Does that make sense? For more information about how OpenSesame deals with variable types, see:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
It absolutely makes sense!!
Thank you so much!
Andrea