from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from .models import Constants import random, time from otree.api import expect, SubmissionMustFail, Submission def call_live_method(method, **kwargs): inputs = [(4000, 4000), (3500, 4000), (3000, 4500), (0, 0), (0, 3000), (10, 4000)] i = (0, 1) while i[0] != i[1]: i = random.choice(inputs) return1 = method(1, i[0]) time.sleep(0.2) return2 = method(2, i[1]) print("Input from Player 1: ", i[0], ", Return: ", return1) print("Input from Player 2: ", i[1], ", Return: ", return2) class PlayerBot(Bot): def play_round(self): treatment = self.player.session.config['gender'] # passwords = [Constants.password for _ in range(20)] + [0] yield pages.Welcome1 yield pages.Welcome2 if treatment == 'mw': genders = ['w', 'm'] yield pages.Gender, dict(gender=random.choice(genders)) # check that bewerber/vorgesetzte are in correct zoom-meeting if self.player.gender == 'w': expect('060475', 'in', self.html) elif self.player.gender == 'm': expect('123416', 'in', self.html) else: if self.player.id_in_group == 1: expect('060475', 'in', self.html) elif self.player.id_in_group == 2: expect('123416', 'in', self.html) yield pages.Zoom, dict(zoom_code=Constants.password) if self.player.zoom_code != Constants.password: yield pages.PaymentOptions, dict(use_paypal=random.choice(['True', 'False'])) expect(self.player.payoff, 4) return # check that females get id_in_group = 1 if treatment == 'mw' and len(self.group.get_players()) == 2: if self.player.gender == 'w': expect(self.player.id_in_group, 1) else: expect(self.player.id_in_group, 2) elif len(self.group.get_players()) != 2: # check that leftover successfully kicked yield pages.PaymentOptions, dict(use_paypal=random.choice(['True', 'False'])) expect(self.player.payoff, 4) return if self.player.id_in_group == 2: expect('Vorgesetzten', 'in', self.html) elif self.player.id_in_group == 1: expect('Bewerbers', 'in', self.html) yield pages.Instructions if self.player.id_in_group == 2: expect('Mitarbeiters', 'in', self.html) elif self.player.id_in_group == 1: expect('Vorgesetzten', 'in', self.html) yield pages.Payoff if self.player.id_in_group == 2: expect('Mitarbeiters', 'in', self.html) yield pages.Comprehension1, dict(comprehension1='< 3500 €') elif self.player.id_in_group == 1: expect('Eigener', 'in', self.html) yield pages.Comprehension1, dict(comprehension1='> 4000 €') yield pages.Comprehension2, dict(comprehension2='4 €') if self.player.id_in_group == 2: yield pages.Comprehension3, dict( comprehension3='Ich muss das Gehalt meines Mitarbeiters so verhandeln, dass es möglichst gering ist.') elif self.player.id_in_group == 1: yield pages.Comprehension3, dict( comprehension3='Ich muss mein Gehalt so verhandeln, dass es möglichst hoch ist.') if self.player.id_in_group == 2: expect('Ihre Firma', 'in', self.html) yield pages.Comprehension4, dict(comprehension4='4500€') elif self.player.id_in_group == 1: expect('Sie akzeptieren würden', 'in', self.html) yield pages.Comprehension4, dict(comprehension4='3000€') expect('Bitte fragen Sie Ihren Experimentleiter via Chat.', 'not in', self.html) yield Submission(pages.Negotiation, dict(), check_html=False) yield Submission(pages.Timer, dict(), check_html=False) yield Submission(pages.Results, dict(), check_html=False) print("Player ", self.player.id_in_subsession, " Negotiation Result: ", self.player.negotiation_result) # if not self.group.agreed: # expect(self.player.payoff, 4) yield pages.Questionnaire1, dict(est_time=random.randint(0, 60), easy=random.randint(1, 7), happiness=random.randint(1, 7), exp_negotiation=random.randint(1, 7)) yield pages.Questionnaire2, dict(comfortableness=random.randint(1, 7), own_bg_choice=random.choice( ["Ja, ich hätte das Hintergrundbild selbst auch gewählt", "Nein, ich hätte ein anderes Hintergrundbild gewählt", "ich bin mir nicht sicher"]), own_bg_positive=random.randint(1, 7), other_bg_positive=random.randint(1, 7)) yield pages.Questionnaire3, dict(own_bg_sympathetic=random.randint(1, 7), other_bg_sympathetic=random.randint(1, 7), own_bg_effect=random.choice([ "Ja, das Hintergrundbild hatte meiner Meinung nach einen Einfluss auf das Ergebnis, und zwar dass es den Lohn gesteigert hat.", "Ja, das Hintergrundbild hatte meiner Meinung nach einen Einfluss auf das Ergebnis, und zwar dass es den Lohn gesenkt hat.", "Nein, das Hintergrundbild hatte meiner Meinung nach keinen Einfluss auf das Ergebnis."]), other_bg_effect=random.choice([ "Ja, das Hintergrundbild hatte meiner Meinung nach einen Einfluss auf das Ergebnis, und zwar dass es den Lohn gesteigert hat.", "Ja, das Hintergrundbild hatte meiner Meinung nach einen Einfluss auf das Ergebnis, und zwar dass es den Lohn gesenkt hat.", "Nein, das Hintergrundbild hatte meiner Meinung nach keinen Einfluss auf das Ergebnis."])) yield pages.Questionnaire4, dict(own_strategy=random.choice(["ich habe versucht, Druck aufzubauen", "meine Verhandlungsstrategie war von partnerschaftlichem Verhandeln geprägt", "ich habe nachgegeben, um ein Ergebnis zu erzielen"]), other_strategy=random.choice( ["mein Verhandlungspartner hat versucht, Druck aufzubauen", "die Verhandlungsstrategie meines Verhandlungspartners war von partnerschaftlichem Verhandeln geprägt", "mein Verhandlungspartner hat nachgegeben, um ein Ergebnis zu erzielen"])) yield pages.Questionnaire5, dict(own_performance=random.randint(1, 7), other_performance=random.randint(1, 7), winner=random.choice(["ich habe die Verhandlung gewonnen", "mein Verhandlungspartner hat die Verhandlung gewonnen"])) yield pages.Questionnaire6, dict(first_suggestion=random.choice( ["ich habe die erste Zahl genannt", "mein Verhandlungspartner hat die erste Zahl genannt"]), first_number=random.randint(0, 6000), speech_share=random.choice( ["ich hatte mehr Redeanteil", "mein Verhandlungspartner hatte mehr Redeanteil", "beide Verhandlungspartner hatten etwa gleich viel Redeanteil."])) yield pages.Questionnaire7, dict(other_sympathetic=random.randint(1, 7), self_sympathetic=random.randint(1, 7), confidence=random.randint(1, 7)) yield pages.Questionnaire8, dict(other_voice_sympathetic=random.randint(1, 7), other_attractive=random.randint(1, 7)) yield pages.Questionnaire9, dict(other_trustworthy=random.randint(1, 7), other_voice_pitch=random.randint(1, 7), other_voice_general=random.randint(1, 7)) yield pages.Questionnaire10, dict( wifi_connection=random.choice(["Die Internetverbindung war stabil und es gab keine technischen Probleme.", "Die Internetverbindung war teilweise instabil. Es gab einige technische Probleme.", "Die Internetverbindung war größtenteils instabil und es gab große technische Probleme."]), camera=random.choice(["Die Kamera war stabil und es gab keine technischen Probleme.", "Die Kamera war teilweise instabil. Es gab einige technische Probleme.", "Die Kamera war größtenteils instabil und es gab große technische Probleme."]), microphone=random.choice(["Das Mikrofon war stabil und es gab keine technischen Probleme.", "Das Mikrofon war teilweise instabil. Es gab einige technische Probleme.", "Das Mikrofon war größtenteils instabil und es gab große technische Probleme."])) if self.player.show_interrupts: temp = dict() if 'instabil' in self.player.wifi_connection: temp['wifi_interrupt'] = random.randint(0, 1000) if 'instabil' in self.player.camera: temp['camera_interrupt'] = random.randint(0, 1000) if 'instabil' in self.player.microphone: temp['microphone_interrupt'] = random.randint(0, 1000) yield pages.Questionnaire11, temp yield pages.Questionnaire12, dict( know_partner=random.choice(["Nein, ich kannte meinen Verhandlungspartner noch nicht vor dem Experiment", "Ja, ich kannte meinen Verhandlungspartner schon vor dem Experiment"])) yield pages.Questionnaire13, dict(birthyear=random.randint(1920, 2021), gender2=random.choice(["weiblich", "männlich"]), language=random.choice( ["Grundkenntnisse", "Gute Kenntnisse", "Sehr gute Kenntnisse", "Fließend", "Verhandlungssicher", "Muttersprache"]), experience_exp=random.choice(["0", "1–5", "6–10", "> 10"])) yield pages.Questionnaire14, dict(grade_maths=random.choice( ["1.0–1.3", "1.4–1.7", "1.8–2.1", "2.2-2.5", "2.6-2.9", "3.0-3.3", "3.4-3.7", "3.8-4.0", "> 4.0"]), faculty=random.choice(["Architektur", "Bau-/Vermessungswesen", "Chemie", "Education", "E-Technik", "Informatik", "Maschinenwesen", "Mathematik", "Medizin", "Physik", "Sport", "Wirtschaft", "Weihenstephan", "anderer"]), degree=random.choice(["Bachelor", "Master", "Anderer Abschluss"]), semester=random.randint(1, 10)) yield pages.Questionnaire15, dict(risk_aversion=random.randint(1, 10)) yield pages.Questionnaire16, dict( inequity_aversion=random.choice(["Verteilung A", "Verteilung B", "Verteilung C"])) yield pages.Questionnaire17, dict(reciprocity_q1=random.randint(1, 7), reciprocity_q2=random.randint(1, 7), reciprocity_q3=random.randint(1, 7)) yield pages.Questionnaire18, dict(reciprocity_q4=random.randint(1, 7), reciprocity_q5=random.randint(1, 7), reciprocity_q6=random.randint(1, 7)) yield pages.Questionnaire19, dict(big_five_q1=random.randint(1, 7)) yield pages.Questionnaire20, dict(big_five_q2=random.randint(1, 7), big_five_q3=random.randint(1, 7), big_five_q4=random.randint(1, 7)) yield pages.Questionnaire21, dict(big_five_q5=random.randint(1, 7), big_five_q6=random.randint(1, 7), big_five_q7=random.randint(1, 7)) yield pages.Questionnaire22, dict(big_five_q8=random.randint(1, 7), big_five_q9=random.randint(1, 7), big_five_q10=random.randint(1, 7)) yield pages.Questionnaire23, dict(big_five_q11=random.randint(1, 7), big_five_q12=random.randint(1, 7), big_five_q13=random.randint(1, 7)) yield pages.Questionnaire24, dict(big_five_q14=random.randint(1, 7), big_five_q15=random.randint(1, 7)) yield pages.Questionnaire25, dict(tech_acc_q1=random.randint(1, 7), tech_acc_q2=random.randint(1, 7)) yield pages.Questionnaire26, dict(tech_acc_q3=random.randint(1, 7), tech_acc_q4=random.randint(1, 7), tech_acc_q5=random.randint(1, 7), tech_acc_q6=random.randint(1, 7)) yield pages.Questionnaire27, dict(tech_acc_q7=random.randint(1, 7), tech_acc_q8=random.randint(1, 7)) yield pages.Questionnaire28, dict(tech_acc_q9=random.randint(1, 7), tech_acc_q10=random.randint(1, 7)) yield pages.Questionnaire29, dict(tech_acc_q11=random.randint(1, 7), tech_acc_q12=random.randint(1, 7), tech_acc_q13=random.randint(1, 7), tech_acc_q14=random.randint(1, 7)) yield pages.Questionnaire30, dict(locuscontr_q1=random.randint(1, 7), locuscontr_q2=random.randint(1, 7), ) yield pages.Questionnaire31, dict(locuscontr_q3=random.randint(1, 7), locuscontr_q4=random.randint(1, 7)) yield pages.Questionnaire32, dict(locuscontr_q5=random.randint(1, 7), locuscontr_q6=random.randint(1, 7)) yield pages.Questionnaire33, dict(locuscontr_q7=random.randint(1, 7), locuscontr_q8=random.randint(1, 7)) yield pages.Questionnaire34, dict(locuscontr_q9=random.randint(1, 7), locuscontr_q10=random.randint(1, 7)) # all players use PayPal yield pages.PaymentOptions, dict(use_paypal=True) # yield pages.PaymentOptions, dict(use_paypal=random.choice(['True', 'False'])) if not self.player.use_paypal: expect('Dies ist ihr Code', 'in', self.html)