-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprisonersDilemmaEyetracking.boxs
159 lines (143 loc) · 4.76 KB
/
prisonersDilemmaEyetracking.boxs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
rounds = 10
// play the game
for (i=1; i<=rounds; i=i+1)
{
matchStranger(A,B)
// set all stuff only in the first round - use the following 'trick'
// if a variable is never used before, it is by default 0 ...
if (isFirstRound == 0)
{
// ... so set it to '1' inside the if-block
isFirstRound = 1
// new style for tables
style("body{ padding: 0px; font-size: 12px; } h1{font-size: 130%; margin-top: 0px; margin-bottom: 3px; font-weight: normal;} h2{font-size: 115%; margin-top: 0px; margin-bottom: 3px; font-weight: normal; } table{border-collapse:collapse;} th{text-align:center; background:#fff4c6; color:#333; padding:8px 16px 8px 8px; border-right:1px solid #fff; border-bottom:1px solid #fff;} td{text-align:center; color:#333; padding:8px; border-right:1px solid #f3f0e4; border-bottom:1px solid #f3f0e4;}")
// Initialize variables
// C D
// _______ _______
// | | |
// C |200/200| 50/300|
// |_______|_______|
// | | |
// D |300/50 |100/100|
// |_______|_______|
// WinMatrix[Zeile][Spalte][Spieler]
WinMatrix[0][0][0] = 200
WinMatrix[0][0][1] = 200
WinMatrix[0][1][0] = 50
WinMatrix[0][1][1] = 300
WinMatrix[1][0][0] = 300
WinMatrix[1][0][1] = 50
WinMatrix[1][1][0] = 100
WinMatrix[1][1][1] = 100
// overall win
totalwin = 0
// number of rounds per player combination
rounds = 10
// Welcome screen
display("<h1>Willkommen beim Experiment</h1>")
display("Warten Sie auf die Instruktionen der Versuchsleiter ")
//inputNumber(checkExperimenter)
//assert(checkExperimenter == 222)
//VPN Code
display("Bitte geben Sie nun Ihre VP-Nummer ein:")
//inputString(vpnumber)
// EYETRACKER ONLY FOR S1
if (username == "S1")
{
// INIT EYETRACKER
eyetrackerInitialise("localhost",4444,5555)
display("Mit weiter gelangen Sie zur Kalibrierung")
wait()
display("<h1>Bitte bewegen Sie sich nun nicht mehr und verfolgen Sie bitte die erscheinenden Punkte</h1>")
wait()
// CALIBRATE EYETRACKER AND START TRACKING
eyetrackerCalibrate()
display("Danke - Die Kalibrierung war erfolgreich")
filename = "PrisonersDilemma_" + vpnumber + ".dat"
eyetrackerStart(60,filename)
// SEND TRIGGER
eyetrackerTrigger("Calibration Done")
}
// Wait for everybody being ready
waitForPlayers("Weiter")
}
table = "<table>"
table = table + " <thead>"
table = table + " <tr>"
table = table + " <th> </th>"
table = table + " <th>Cooperate</th>"
table = table + " <th>Defect</th>"
table = table + " </tr>"
table = table + " </thead>"
table = table + " <tbody>"
table = table + " <tr>"
table = table + " <th>Cooperate</th>"
table = table + " <td>" + WinMatrix[0][0][0] + " / " + WinMatrix[0][0][1] + "</td>"
table = table + " <td>" + WinMatrix[0][1][0] + " / " + WinMatrix[0][1][1] + "</td>"
table = table + " </tr>"
table = table + " <tr>"
table = table + " <th>Defect</th>"
table = table + " <td>" + WinMatrix[1][0][0] + " / " + WinMatrix[1][0][1] + "</td>"
table = table + " <td>" + WinMatrix[1][1][0] + " / " + WinMatrix[1][1][1] + "</td>"
table = table + " </tr>"
table = table + " <tr>"
table = table + " </tbody>"
table = table + "</table>"
display(table)
choice(action,"Cooperate", "Defect")
waitForPlayers("Weiter")
// Calculate Payoff
if (A.action == "Cooperate")
{
if(B.action == "Cooperate")
{
A.win = WinMatrix[0][0][0]
B.win = WinMatrix[0][0][1]
}
if(B.action == "Defect")
{
A.win = WinMatrix[0][1][0]
B.win = WinMatrix[0][1][1]
}
}
if (A.action == "Defect")
{
if(B.action == "Cooperate")
{
A.win = WinMatrix[1][0][0]
B.win = WinMatrix[1][0][1]
}
if(B.action == "Defect")
{
A.win = WinMatrix[1][1][0]
B.win = WinMatrix[1][1][1]
}
}
// present actions and payoff
display("Sie haben '" + action + "' gewählt" )
if (role == "B")
{
display("Ihr Gegener hat '" + A.action + "' gewählt" )
}
if (role == "A")
{
display("Ihr Gegener hat '" + B.action + "' gewählt" )
}
display("Ihr Rundengewinn beträgt somit " + win)
totalwin = totalwin + win
win[i] = win
action[i] = action
wait()
matchDone()
}
if (username=="S1")
{
eyetrackerStop()
}
// End of game reached
display("<h1>Das Experiment ist nun beendet. Bitte klicken Sie weiter um die Auszahlung anzuzeigen</h1>")
wait()
display("Sie haben insgesamt folgende Anzahl an Talern verdient: " + totalwin)
display("Dies entspricht einem Betrag von: " + totalwin / 200)
display("<br><br> Bitte verständigen Sie nun die Versuchsleitung per Handzeichen")
waitForPlayers("Beenden")