Repetition of the same app

188 views
Skip to first unread message

Fabian Gerstmeier

unread,
Mar 30, 2021, 12:00:17 PM3/30/21
to oTree help & discussion
Hello, 

sorry if this question has been answered before but I am new to oTree and cannot figure out a good answer on my own. 

I have an original game that is 4 rounds long. Now I want to repeat this game several times and randomly assign the participants into new groups. 
Is there a smart way to do that?

Of course I can copy and paste the original app and make a sequence of these copy-paste apps. But I am reluctant to do so since I would have a lot of code repetition. 
(If this is the suggested answer. Is there an easy way randomly select one of the apps to be payment relevant)

I really appreciate any help 

Best
Fabi

Chris @ oTree

unread,
Mar 30, 2021, 12:16:07 PM3/30/21
to Fabian Gerstmeier, oTree help & discussion
How about making a 16 round game?

Sent from my phone

On Mar 31, 2021, at 12:00 AM, Fabian Gerstmeier <fabgers...@gmail.com> wrote:

Hello, 
--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/9c818868-3b7c-4531-8b32-ab06262273ean%40googlegroups.com.

Fabian Gerstmeier

unread,
Mar 30, 2021, 2:21:36 PM3/30/21
to oTree help & discussion

Sadly not really working I guess. I was not precise enough in the initial question. 
One Period can go from 1-4 rounds depending on the decisions. Hence, if say I want 5 Periods (5 repetition of the initial game) there could be 5 rounds or 20 rounds depending on the decisions of the participants. 
Also I guess it will be weird working with in_all_rounds() etc. since it will count over all rounds and not only over one Period(1-4 rounds) which I want. 

But thank you for the fast reply and  I will think about it more!

Best,
Fabian


Chris @ oTree

unread,
Mar 30, 2021, 2:36:31 PM3/30/21
to oTree help & discussion
It can still be done. You just need to track the current period & round number yourself, and use those instead of the built-in .round_number. Make field on the group like:

current_period = models.IntegerField()
round_in_period = models.IntegerField()

Then in each round, you decide if the period is finished. If yes, then increment the field by 1. (You can also store current_period as a participant field.)

Instead of .in_all_rounds(), you could use a function like this:

def in_all_period_rounds(group):
    current_round = group.round_number
    first_round_in_period = group.round_number - group.round_in_period + 1)
    return group.in_rounds(first_round_in_period, current_round)

Fabian Gerstmeier

unread,
Mar 30, 2021, 3:06:32 PM3/30/21
to Chris @ oTree, oTree help & discussion
Thank you I will try that! 

Best
Fabian

You received this message because you are subscribed to a topic in the Google Groups "oTree help & discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/otree/Vt_9d3NsD_U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/eba268a2-687c-47a3-80ab-69a0397eac7cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages