BooleanField not recognized as True

39 views
Skip to first unread message

Linda Aldehoff

unread,
May 18, 2022, 11:02:28 AMMay 18
to oTree help & discussion
Hello,

I've been working on a payoff function for a few days now, since it doesn't recognize that a bool is true.
The boolean field:

expectations1C1_check = models.BooleanField(initial=False)
def set_expectations1C1_check(self):
p1 = self.get_player_by_id(1)
p2 = self.get_player_by_id(2)
self.expectations1C1_check = p1.value['expectations1C'] == p2.participant.vars['take'].value['take']

the payoff:

def set_payoffs(self):
p1 = self.get_player_by_id(1)
p2 = self.get_player_by_id(2)
p3 = self.get_player_by_id(3)
for p in self.get_players():
p.treatment = p.session.vars['treatment']
if p.treatment == 1:
print('treatment')
if p == p3:
print('p3')
if self.expectations1T_check == True:
print('expectations1T_check')
if self.expectations2T_check == True:
for p in self.get_players():
print('payoff4)')
p.payoff = 4
else:
for p in self.get_players():
p.payoff = 2
...
with the print function I found out that tree thinks that self.expectations1T_check == False, even when it is supposed to be true. 

Did I define the Boolean Field wrong? How do I fix this?

Thank you for your help!

Best,

Linda

Katy Tabero

unread,
May 24, 2022, 7:10:10 AMMay 24
to oTree help & discussion
Hi Linda, 

I may not be the best person to help as I am still an amateur and may just be misreading your code, but just with a quick look, I have noticed two things:

1) In the first function you mention self.expectations1C1_check whereas elsewhere you refer to self.expectations1T_check - so it is unclear where self.expectations1T_check should be set to True.
2) I cannot see where you are calling your set_expectations1C1_check function. Assuming this is where you intend to set self.expectations1T_check, if it is not being called at any point then self.expectations1T_check will remain at false as that is what you have set it as initially. A quick test might be to put a print statement in the  set_expectations1C1_check function to make sure that it is being enacted before the payoff function.
Reply all
Reply to author
Forward
0 new messages