1

for an experiment I want to program that a certain choice results in a probability distribution of an outcome. Currently I have:

Action = models.IntegerField(
    choices=[
        [1, 'altruistic (2:0.5,0:0.3,-2:0.2)'],
        [2, 'selfish (2:0.3,0:0.4,-2:0.3)']
        ]

I tried:

Action = models.IntegerField(
    choices=[
        [random.choices([2,0,-2],[0.5,0.3,0.3]), 'altruistic (2:0.5,0:0.3,-2:0.2)'],
        [random.choices([2,0,-2],[0.3,0.4,0.3]), 'selfish (2:0.3,0:0.4,-2:0.3)']
        ]
    )

which gives me an Internal Server Error. For the experiment I need the random number from the experiment, and the given choice. The given choice I should access with

player.get_field_display('Action')

However in the current state with :

{% extends "global/Page.html" %}{% load otree %}


{% block title %} 
Treffen Sie ihre Entscheidung 
{% endblock %}


{% block content %} 
Bitte treffen Sie ihre Entscheidung. Spieler 1 hat entschieden {{player.get_field_display('Action')}}  an Sie zu verteilen. Dies resultierte in {{ group.Action }}
    {%formfields%}
    {% next_button %} 
{% endblock %} 

this results in TemplateSyntaxError: Unparsable argument '‘’Action’’'. Arguments must be valid Python literals. (line 29, in "player.get_field_display(<span") Has anyone an idea for these flaws?

xnood
  • 11
  • 2

0 Answers0