Example #1
0
    def play_round(self):
        print("Round #: {}".format(self.round_number))
        if self.round_number == 1:
            yield (SubmissionMustFail(QuizPartOne, {'q1': ['2'], 'q2': ['1']}))
            yield (SubmissionMustFail(QuizPartOne, {'q1': ['1'], 'q2': ['1']}))

            yield (QuizPartOne, {'q1': ['2'], 'q2': ['2']})
            expect(self.player.q1, "['2']")
            expect(self.player.q2, "['2']")

            yield (SubmissionMustFail(QuizPartTwo, {'q3': ['2'], 'q4': ['1']}))
            yield (QuizPartTwo, {'q3': ['2', '3', '4'], 'q4': ['1', '3']})

            yield (InstructionPage)

        if self.round_number != 1 and (
            (self.round_number - 1) % (Constants.rounds_per_lottery + 1)) == 0:
            yield (NewLotteryReminder)

        if ((self.round_number - 1) % (Constants.rounds_per_lottery + 1)) == 0:
            yield (ValuationPage, {'bid': 0})

        if ((self.round_number - 1) % (Constants.rounds_per_lottery + 1)) == 1:
            yield (NewSignalReminder)

        if ((self.round_number - 1) % (Constants.rounds_per_lottery + 1)) != 0:
            yield (BidPage, {'bid': 0})
            yield (OutcomePage)
Example #2
0
 def play_round(self):
     yield SubmissionMustFail(IDPage, dict(DecisionLabId='111111a'))
     yield SubmissionMustFail(IDPage, dict(DecisionLabId=0000000))
     yield SubmissionMustFail(IDPage, dict(DecisionLabId=7654321))
     yield SubmissionMustFail(IDPage, dict(DecisionLabId=12345678))
     yield IDPage, dict(DecisionLabId=1234555)
     expect(self.player.DecisionLabId, '1234555')
Example #3
0
    def play_round(self):
        yield pages.Introduction

        if self.player.id_in_group == 1:
            yield pages.Offer, dict(kept=c(99))
            expect(self.player.payoff, c(99))
        else:
            expect(self.player.payoff, c(1))
        yield pages.Results
Example #4
0
    def play_round(self):
        yield Introduction

        if self.player.id_in_group == 1:
            yield Offer, dict(kept=cu(99))
            expect(self.player.payoff, cu(99))
        else:
            expect(self.player.payoff, cu(1))
        yield Results
Example #5
0
    def play_round(self):

        yield pages.Demographics, dict(age=24, gender='Male')

        yield (
            pages.CognitiveReflectionTest,
            dict(crt_bat=10, crt_widget=5, crt_lake=48),
        )

        for value in [self.player.crt_bat, self.player.payoff]:
            expect(value, '!=', None)
Example #6
0
    def play_round(self):
        yield Introduction

        if self.case == 'min':
            yield Decide, dict(units=0)
            # if player produces 0, nothing is sold and they make 0
            expect(self.player.payoff, cu(0))

        if self.case == 'max':
            yield Decide, dict(units=Constants.max_units_per_player)
            # if everyone produces max, price is driven to 0
            expect(self.player.payoff, cu(0))

        yield Results
Example #7
0
    def play_round(self):

        # start
        yield Introduction

        if self.case == 'success':
            request = cu(10)
            yield Request, dict(request=request)
            yield Results
            expect(self.player.payoff, request)

        if self.case == 'greedy':
            yield Request, dict(request=Constants.amount_shared)
            yield Results
            expect(self.player.payoff, 0)
Example #8
0
class PlayerBot(Bot):
    cases = [
        {'offer': cu(0), 'return': cu(0), 'p1_payoff': cu(10), 'p2_payoff': cu(0)},
        {'offer': cu(5), 'return': cu(10), 'p1_payoff': cu(15), 'p2_payoff': cu(5)},
        {'offer': cu(10), 'return': cu(30), 'p1_payoff': cu(30), 'p2_payoff': cu(0)},
    ]

    def play_round(self):
        case = self.case
        if self.player.id_in_group == 1:
            yield Send, dict(sent_amount=case['offer'])

        else:
            for invalid_return in [-1, case['offer'] * Constants.multiplier + 1]:
                yield SubmissionMustFail(
                    SendBack, dict(sent_back_amount=invalid_return)
                )
            yield SendBack, dict(sent_back_amount=case['return'])

        if self.player.id_in_group == 1:
            expected_payoff = case['p1_payoff']
        else:
            expected_payoff = case['p2_payoff']

        expect(self.player.payoff, expected_payoff)
Example #9
0
class PlayerBot(Bot):

    cases = ['basic', 'min', 'max']

    def play_round(self):
        case = self.case
        yield pages.Introduction

        if case == 'basic':
            if self.player.id_in_group == 1:
                for invalid_contribution in [-1, 101]:
                    yield SubmissionMustFail(
                        pages.Contribute,
                        dict(contribution=invalid_contribution))

        contribution = dict(min=0, max=100, basic=50)[case]

        yield pages.Contribute, dict(contribution=contribution)

        yield pages.Results

        if self.player.id_in_group == 1:

            if case == 'min':
                expected_payoff = 100
            elif case == 'max':
                expected_payoff = 200
            else:
                expected_payoff = 150
            expect(self.player.payoff, expected_payoff)
Example #10
0
class PlayerBot(Bot):

    cases = ['basic', 'p1_wins', 'all_0', 'all_max']

    def play_round(self):
        case = self.case

        # Introduction
        yield pages.Introduction

        if case == 'basic':
            for invalid_bid in [-1, 11]:
                yield SubmissionMustFail(pages.Bid,
                                         dict(bid_amount=invalid_bid))
        if case == 'p1_wins':
            if self.player.id_in_group == 1:
                bid_amount = 2
            else:
                bid_amount = 1
        elif case == 'all_0':
            bid_amount = 0
        else:  # case == 'all_max':
            bid_amount = Constants.max_allowable_bid
        yield pages.Bid, dict(bid_amount=bid_amount)

        if case == 'p1_wins':
            if self.player.id_in_group == 1:
                expect('You won the auction', 'in', self.html)
            else:
                expect('You did not win', 'in', self.html)

        if self.player.id_in_group == 1:
            num_winners = sum(
                [1 for p in self.group.get_players() if p.is_winner])
            expect(num_winners, 1)

        for field in [
                self.player.bid_amount,
                self.player.payoff,
                self.player.item_value_estimate,
                self.player.is_winner,
        ]:
            expect(field, '!=', None)

        yield pages.Results
Example #11
0
    def play_round(self):

        yield pages.MyPage

        print(self.participant.id_in_session)
        if self.participant.id_in_session == 1:
            expect(self.player.treatment, "==", Treatment.T1.name)
        if self.participant.id_in_session == 2:
            expect(self.player.treatment, "==", Treatment.T2.name)
        if self.participant.id_in_session == 3:
            expect(self.player.treatment, "==", Treatment.T3.name)
        if self.participant.id_in_session == 4:
            expect(self.player.treatment, "==", Treatment.T4.name)
Example #12
0
class PlayerBot(Bot):

    cases = ['0_volunteer', '1_volunteer']

    def play_round(self):
        case = self.case

        yield Introduction

        if case == '0_volunteer':
            yield Decision, dict(volunteer=False)
            expect(self.player.payoff, cu(0))
            expect('You did not volunteer and no one did', 'in', self.html)
        elif case == '1_volunteer':
            yield Decision, dict(volunteer=self.player.id_in_group == 1)
            if self.player.id_in_group == 1:
                expect('You volunteered', 'in', self.html)
                expect(
                    self.player.payoff,
                    Constants.general_benefit - Constants.volunteer_cost,
                )
            else:
                expect('You did not volunteer but some did', 'in', self.html)
                expect(self.player.payoff, cu(100))
        yield Results
Example #13
0
class PlayerBot(Bot):
    cases = ['both_min', 'both_max', 'p1_lower']

    def play_round(self):
        case = self.case

        # start game
        yield pages.Introduction

        if case == 'both_min':
            yield pages.Claim, dict(claim=Constants.min_amount)
            expect(self.player.payoff, Constants.min_amount)
        elif case == 'both_max':
            yield pages.Claim, dict(claim=Constants.max_amount)
            expect(self.player.payoff, Constants.max_amount)
        else:
            if self.player.id_in_group == 1:
                yield pages.Claim, dict(claim=Constants.min_amount)
                expect(self.player.payoff, Constants.min_amount + 2)
            else:
                yield pages.Claim, dict(claim=Constants.min_amount + 1)
                expect(self.player.payoff, Constants.min_amount - 2)

        yield pages.Results
Example #14
0
 def play_round(self):
     yield Instructions
     yield SubmissionMustFail(Understanding, dict(q1=100, q2=100, q3=0))
     yield SubmissionMustFail(Understanding, dict(q1=0, q2=100, q3=0))
     yield SubmissionMustFail(Understanding, dict(q1=50, q2=50, q3=0))
     yield SubmissionMustFail(Understanding, dict(q1=50, q2=0, q3=0))
     yield SubmissionMustFail(Understanding, dict(q1=50, q2=100, q3=100))
     yield SubmissionMustFail(Understanding, dict(q1=50, q2=100, q3=50))
     yield Understanding, dict(q1=50, q2=100, q3=0)
     expect(self.player.q1, 50)
     expect(self.player.q2, 100)
     expect(self.player.q3, 0)
Example #15
0
    def play_round(self):
        yield pages.Choice, dict(penny_side='Heads')
        if self.player.is_matcher():
            expect(self.player.is_winner, True)
        else:
            expect(self.player.is_winner, False)

        if self.player.round_number == Constants.num_rounds:
            # only 1 person should be paid in only 1 round
            total_payoffs = 0
            for player in self.group.get_players():
                total_payoffs += sum(p.payoff for p in player.in_all_rounds())
            expect(total_payoffs, Constants.stakes)
Example #16
0
 def play_round(self):
     yield Introduction
     yield SubmissionMustFail(Consent, dict(consent=False))
     yield Consent, dict(consent=True)
     expect(self.player.consent, True)
Example #17
0
    def play_round(self):
        if self.round_number == 1:
            yield pages.Introduction

        if self.case == 'p1_wins':
            if self.player.id_in_group == 1:
                for invalid_guess in [-1, 101]:
                    yield SubmissionMustFail(pages.Guess,
                                             dict(guess=invalid_guess))
                yield pages.Guess, dict(guess=9)
                expect(self.player.payoff, Constants.jackpot)
                expect('you win', 'in', self.html)
            else:
                yield pages.Guess, dict(guess=10)
                expect(self.player.payoff, 0)
                expect('you did not win', 'in', self.html)
        else:
            if self.player.id_in_group in [1, 2]:
                yield pages.Guess, dict(guess=9)
                expect(self.player.payoff, Constants.jackpot / 2)
                expect('you are one of the 2 winners', 'in', self.html)
            else:
                yield pages.Guess, dict(guess=10)
                expect(self.player.payoff, 0)
                expect('you did not win', 'in', self.html)

        yield pages.Results
Example #18
0
 def play_round(self):
     yield Introduction
     yield Decision, dict(decision='Cooperate')
     expect('Both of you chose to Cooperate', 'in', self.html)
     expect(self.player.payoff, Constants.both_cooperate_payoff)
     yield Results
 def play_round(self):
     if self.participant.label is None:
         yield pages.OrseeID, dict(orsee_id="test-id")
     expect(str(self.participant.payoff_plus_participation_fee()), "in",
            self.html)
     yield Submission(pages.Payoff, check_html=False)