Skip to content
Snippets Groups Projects
Commit d4176e1d authored by Maxime MORGE's avatar Maxime MORGE
Browse files

Dictator Continuous Setup

parent 9d0b631b
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,14 @@
</Attribute>
</value>
</entry>
<entry key="$PROJECT_DIR$/data/dictator/dictator.csv">
<entry key="$PROJECT_DIR$/data/dictator/dictator_continuous_setup.csv">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
<entry key="$PROJECT_DIR$/data/dictator/dictator_setup.csv">
<value>
<Attribute>
<option name="separator" value="," />
......
This diff is collapsed.
Model,ALTRUISTIC,EGALITARIAN,SELFISH
deepseek-r1,0.03333333333333333,0.6,0.1
llama3,0.13333333333333333,0.0,0.06666666666666667
mistral-small,0.36666666666666664,0.1,0.06666666666666667
......@@ -6,7 +6,7 @@
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<cc:Work>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:date>2025-03-06T15:23:02.586659</dc:date>
<dc:date>2025-03-17T12:23:10.390098</dc:date>
<dc:format>image/svg+xml</dc:format>
<dc:creator>
<cc:Agent>
......@@ -39,7 +39,7 @@ z
</g>
<g id="FillBetweenPolyCollection_1">
<defs>
<path id="mfe429e2412" d="M 90 -239.966955
<path id="m3cd6a21c3a" d="M 90 -239.966955
L 90 -184.017045
L 152 -182.897803
L 214 -178.751067
......@@ -64,8 +64,8 @@ L 90 -239.966955
z
" style="stroke: #5862ed; stroke-opacity: 0.2"/>
</defs>
<g clip-path="url(#p3b5f617323)">
<use xlink:href="#mfe429e2412" x="0" y="432" style="fill: #5862ed; fill-opacity: 0.2; stroke: #5862ed; stroke-opacity: 0.2"/>
<g clip-path="url(#pa1c39dbf13)">
<use xlink:href="#m3cd6a21c3a" x="0" y="432" style="fill: #5862ed; fill-opacity: 0.2; stroke: #5862ed; stroke-opacity: 0.2"/>
</g>
</g>
<g id="FillBetweenPolyCollection_2">
......@@ -92,11 +92,11 @@ L 214 -54.6048
L 152 218.16
L 90 -54.6048
z
" clip-path="url(#p3b5f617323)" style="fill: #000037; fill-opacity: 0.2; stroke: #000037; stroke-opacity: 0.2"/>
" clip-path="url(#pa1c39dbf13)" style="fill: #000037; fill-opacity: 0.2; stroke: #000037; stroke-opacity: 0.2"/>
</g>
<g id="FillBetweenPolyCollection_3">
<defs>
<path id="m3545795bc6" d="M 90 -242.978975
<path id="m8b8ccd7e42" d="M 90 -242.978975
L 90 -184.701025
L 152 -238.711267
L 214 -178.659196
......@@ -121,13 +121,13 @@ L 90 -242.978975
z
" style="stroke: #32a68c; stroke-opacity: 0.2"/>
</defs>
<g clip-path="url(#p3b5f617323)">
<use xlink:href="#m3545795bc6" x="0" y="432" style="fill: #32a68c; fill-opacity: 0.2; stroke: #32a68c; stroke-opacity: 0.2"/>
<g clip-path="url(#pa1c39dbf13)">
<use xlink:href="#m8b8ccd7e42" x="0" y="432" style="fill: #32a68c; fill-opacity: 0.2; stroke: #32a68c; stroke-opacity: 0.2"/>
</g>
</g>
<g id="FillBetweenPolyCollection_4">
<defs>
<path id="mc05c159bf0" d="M 90 -250.991651
<path id="m1a6d89619c" d="M 90 -250.991651
L 90 -195.168349
L 152 -256.435371
L 214 -143.051893
......@@ -152,8 +152,8 @@ L 90 -250.991651
z
" style="stroke: #ff6941; stroke-opacity: 0.2"/>
</defs>
<g clip-path="url(#p3b5f617323)">
<use xlink:href="#mc05c159bf0" x="0" y="432" style="fill: #ff6941; fill-opacity: 0.2; stroke: #ff6941; stroke-opacity: 0.2"/>
<g clip-path="url(#pa1c39dbf13)">
<use xlink:href="#m1a6d89619c" x="0" y="432" style="fill: #ff6941; fill-opacity: 0.2; stroke: #ff6941; stroke-opacity: 0.2"/>
</g>
</g>
<g id="FillBetweenPolyCollection_5">
......@@ -180,11 +180,11 @@ L 214 -54.6048
L 152 218.16
L 90 29.951202
z
" clip-path="url(#p3b5f617323)" style="fill: #ffd24b; fill-opacity: 0.2; stroke: #ffd24b; stroke-opacity: 0.2"/>
" clip-path="url(#pa1c39dbf13)" style="fill: #ffd24b; fill-opacity: 0.2; stroke: #ffd24b; stroke-opacity: 0.2"/>
</g>
<g id="FillBetweenPolyCollection_6">
<defs>
<path id="mba4e5b03f6" d="M 90 -252.013023
<path id="md18585fd14" d="M 90 -252.013023
L 90 -153.490977
L 152 -101.361384
L 214 -184.80972
......@@ -209,8 +209,8 @@ L 90 -252.013023
z
" style="stroke: #333333; stroke-opacity: 0.2"/>
</defs>
<g clip-path="url(#p3b5f617323)">
<use xlink:href="#mba4e5b03f6" x="0" y="432" style="fill: #333333; fill-opacity: 0.2; stroke: #333333; stroke-opacity: 0.2"/>
<g clip-path="url(#pa1c39dbf13)">
<use xlink:href="#md18585fd14" x="0" y="432" style="fill: #333333; fill-opacity: 0.2; stroke: #333333; stroke-opacity: 0.2"/>
</g>
</g>
<g id="matplotlib.axis_1">
......@@ -218,16 +218,16 @@ z
<g id="line2d_1">
<path d="M 90 384.48
L 90 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_2">
<defs>
<path id="m53209c4533" d="M 0 0
<path id="mb81c913329" d="M 0 0
L 0 3.5
" style="stroke: #000000; stroke-width: 0.8"/>
</defs>
<g>
<use xlink:href="#m53209c4533" x="90" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="90" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_1">
......@@ -257,11 +257,11 @@ z
<g id="line2d_3">
<path d="M 152 384.48
L 152 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_4">
<g>
<use xlink:href="#m53209c4533" x="152" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="152" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_2">
......@@ -301,11 +301,11 @@ z
<g id="line2d_5">
<path d="M 214 384.48
L 214 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_6">
<g>
<use xlink:href="#m53209c4533" x="214" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="214" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_3">
......@@ -353,11 +353,11 @@ z
<g id="line2d_7">
<path d="M 276 384.48
L 276 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_8">
<g>
<use xlink:href="#m53209c4533" x="276" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="276" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_4">
......@@ -392,11 +392,11 @@ z
<g id="line2d_9">
<path d="M 338 384.48
L 338 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_10">
<g>
<use xlink:href="#m53209c4533" x="338" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="338" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_5">
......@@ -437,11 +437,11 @@ z
<g id="line2d_11">
<path d="M 400 384.48
L 400 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_12">
<g>
<use xlink:href="#m53209c4533" x="400" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="400" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_6">
......@@ -487,11 +487,11 @@ z
<g id="line2d_13">
<path d="M 462 384.48
L 462 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_14">
<g>
<use xlink:href="#m53209c4533" x="462" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="462" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_7">
......@@ -517,11 +517,11 @@ z
<g id="line2d_15">
<path d="M 524 384.48
L 524 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_16">
<g>
<use xlink:href="#m53209c4533" x="524" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="524" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_8">
......@@ -576,11 +576,11 @@ z
<g id="line2d_17">
<path d="M 586 384.48
L 586 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_18">
<g>
<use xlink:href="#m53209c4533" x="586" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="586" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_9">
......@@ -626,11 +626,11 @@ z
<g id="line2d_19">
<path d="M 648 384.48
L 648 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_20">
<g>
<use xlink:href="#m53209c4533" x="648" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#mb81c913329" x="648" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_10">
......@@ -917,16 +917,16 @@ z
<g id="line2d_21">
<path d="M 90 384.48
L 648 384.48
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_22">
<defs>
<path id="m66daa8bac6" d="M 0 0
<path id="me4cc7d8216" d="M 0 0
L -3.5 0
" style="stroke: #000000; stroke-width: 0.8"/>
</defs>
<g>
<use xlink:href="#m66daa8bac6" x="90" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="384.48" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_12">
......@@ -952,11 +952,11 @@ z
<g id="line2d_23">
<path d="M 90 342.9
L 648 342.9
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_24">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="342.9" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="342.9" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_13">
......@@ -973,11 +973,11 @@ L 648 342.9
<g id="line2d_25">
<path d="M 90 301.32
L 648 301.32
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_26">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="301.32" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="301.32" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_14">
......@@ -994,11 +994,11 @@ L 648 301.32
<g id="line2d_27">
<path d="M 90 259.74
L 648 259.74
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_28">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="259.74" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="259.74" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_15">
......@@ -1015,11 +1015,11 @@ L 648 259.74
<g id="line2d_29">
<path d="M 90 218.16
L 648 218.16
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_30">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="218.16" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="218.16" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_16">
......@@ -1036,11 +1036,11 @@ L 648 218.16
<g id="line2d_31">
<path d="M 90 176.58
L 648 176.58
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_32">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="176.58" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="176.58" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_17">
......@@ -1057,11 +1057,11 @@ L 648 176.58
<g id="line2d_33">
<path d="M 90 135
L 648 135
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_34">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="135" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="135" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_18">
......@@ -1078,11 +1078,11 @@ L 648 135
<g id="line2d_35">
<path d="M 90 93.42
L 648 93.42
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_36">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="93.42" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="93.42" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_19">
......@@ -1099,11 +1099,11 @@ L 648 93.42
<g id="line2d_37">
<path d="M 90 51.84
L 648 51.84
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/>
</g>
<g id="line2d_38">
<g>
<use xlink:href="#m66daa8bac6" x="90" y="51.84" style="stroke: #000000; stroke-width: 0.8"/>
<use xlink:href="#me4cc7d8216" x="90" y="51.84" style="stroke: #000000; stroke-width: 0.8"/>
</g>
</g>
<g id="text_20">
......@@ -1350,7 +1350,7 @@ L 462 220.008
L 524 216.312
L 586 221.856
L 648 214.464
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #5862ed; stroke-width: 1.5; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #5862ed; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="line2d_40">
<path d="M 90 162.72
......@@ -1363,7 +1363,7 @@ L 462 162.72
L 524 218.16
L 586 162.72
L 648 218.16
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #000037; stroke-width: 1.5; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #000037; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="line2d_41">
<path d="M 90 218.16
......@@ -1376,7 +1376,7 @@ L 462 247.728
L 524 210.768
L 586 240.336
L 648 203.376
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #32a68c; stroke-width: 1.5; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #32a68c; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="line2d_42">
<path d="M 90 208.92
......@@ -1389,7 +1389,7 @@ L 462 232.944
L 524 212.616
L 586 216.312
L 648 188.592
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #ff6941; stroke-width: 1.5; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #ff6941; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="line2d_43">
<path d="M 90 218.16
......@@ -1402,7 +1402,7 @@ L 462 162.72
L 524 218.16
L 586 162.72
L 648 218.16
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #ffd24b; stroke-width: 1.5; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #ffd24b; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="line2d_44">
<path d="M 90 229.248
......@@ -1415,7 +1415,7 @@ L 462 201.528
L 524 201.528
L 586 240.336
L 648 251.424
" clip-path="url(#p3b5f617323)" style="fill: none; stroke: #63656a; stroke-width: 1.5; stroke-linecap: square"/>
" clip-path="url(#pa1c39dbf13)" style="fill: none; stroke: #63656a; stroke-width: 1.5; stroke-linecap: square"/>
</g>
<g id="patch_3">
<path d="M 90 384.48
......@@ -1949,7 +1949,7 @@ L 445.2375 138.329062
</g>
</g>
<defs>
<clipPath id="p3b5f617323">
<clipPath id="pa1c39dbf13">
<rect x="90" y="51.84" width="558" height="332.64"/>
</clipPath>
</defs>
......
# Maxime MORGE <maxime.morge@univ-lyon1.fr>
import os
import asyncio
import json
from typing import Literal, Dict
from pydantic import BaseModel
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.messages import TextMessage
from autogen_core import CancellationToken
from autogen_ext.models.openai import OpenAIChatCompletionClient
from enum import Enum
from src.rps.rps_draw_2loop import model
# Load API key from environment variable
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
# Validate API key
if not OPENAI_API_KEY:
raise ValueError("Missing OPENAI_API_KEY. Set it as an environment variable.")
class RestrictedWelfare(Enum):
EGALITARIAN = "Egalitarian", "You have a stronger preference for fairness between players and maximize the minimum income."
SELFISH = "Selfish", "You have a stronger preference for your own interest and maximize your own income."
ALTRUISTIC = "Altruist", "You have a stronger preference for another player’s interest and maximize another player’s income."
def __init__(self, label, description):
self._label = label
self._description = description
@property
def label(self):
return self._label
@property
def description(self):
return self._description
# Define the expected response format as a Pydantic model
class AgentResponse(BaseModel):
my_share: int
other_share: int
reasoning: str
class DictatorContinuousSetup:
debug = False
def __init__(self, model: str, temperature: float, preference: RestrictedWelfare, strategy=False):
self.model = model
self.temperature = temperature
self.preference = preference
self.strategy = strategy
if not self.strategy:
is_openai_model = model.startswith("gpt")
base_url = "https://api.openai.com/v1" if is_openai_model else "http://localhost:11434/v1"
self.model_info = {
"temperature": self.temperature,
"function_calling": True,
"parallel_tool_calls": True,
"family": "unknown",
"json_output": True,
"vision": False
}
self.model_client = OpenAIChatCompletionClient(
model=self.model,
base_url=base_url,
api_key=OPENAI_API_KEY,
model_info=self.model_info,
response_format=AgentResponse
)
async def run(self) -> Dict:
"""Runs the dictator game and returns a detailed response dictionary."""
if self.strategy:
return self.apply_strategy(self.model)
instruction = f"""
Hi, let’s play a game. You are paired with another player.
Your role is to decide how to divide $1000, and the other player simply receives your choice.
Money can be lost in the process.
{self.preference.description}
How would you like to divide the money?
Please provide one specific choice, stating how much you keep, how much you give, and how much is lost.
"""
agent = AssistantAgent(
name="Dictator",
model_client=self.model_client,
system_message="You are a helpful assistant."
)
response = await agent.on_messages(
[TextMessage(content=instruction, source="user")],
cancellation_token=CancellationToken(),
)
response_data = response.chat_message.content
if self.debug:
print(f"Raw Response: {response_data}")
response_dict = json.loads(response_data)
agent_response = AgentResponse.model_validate(response_dict)
is_consistent = self.check_consistency(agent_response)
return {
"is_consistent": is_consistent,
"my_share": agent_response.my_share,
"other_share": agent_response.other_share,
"reasoning": agent_response.reasoning
}
def apply_strategy(self, model: str) -> Dict:
"""Applies a predefined strategy based on the preference."""
if model == "gpt-4.5-preview-2025-02-27" or model == "llama3" or model == "mistral-small":
strategy_choices = {
RestrictedWelfare.SELFISH: {"my_share": 1000, "other_share": 0, "reasoning": "Maximizing personal gain."},
RestrictedWelfare.ALTRUISTIC: {"my_share": 0, "other_share": 1000, "reasoning": "Maximizing the other player’s gain."},
RestrictedWelfare.EGALITARIAN: {"my_share": 500, "other_share": 500, "reasoning": "Ensuring a fair split."},
}
strategy_response = strategy_choices.get(self.preference, {"my_share": 500, "other_share": 500, "reasoning": "Default fair split."})
return {
"is_consistent": True,
"my_share": strategy_response["my_share"],
"other_share": strategy_response["other_share"],
"reasoning": strategy_response["reasoning"]
}
if model == "deepseek-R1":
return {"error": "Preference strategy not defined"}
def check_consistency(self, agent_response: AgentResponse) -> bool:
"""Check if the response aligns with the given preference."""
valid_choices = {
RestrictedWelfare.SELFISH: (1000, 0),
RestrictedWelfare.ALTRUISTIC: (0, 1000),
RestrictedWelfare.EGALITARIAN: (500, 500),
}
expected_values = valid_choices.get(self.preference, None)
if expected_values:
return (
agent_response.my_share == expected_values[0] and
agent_response.other_share == expected_values[1]
)
return False
# Run the async function and return the response
if __name__ == "__main__":
preference = RestrictedWelfare.EGALITARIAN
game_agent = DictatorContinuousSetup(model="llama3", temperature=0.7, preference=preference, strategy=False)
response = asyncio.run(game_agent.run())
print(response)
import pandas as pd
# Charger les résultats de l'expérience
df = pd.read_csv("../../data/dictator/dictator_continuous_setup.csv")
# Calculer l'accuracy par modèle et par préférence
accuracy_table = df.groupby(["Model", "Preference"])["is_consistent"].mean().unstack()
# Afficher le tableau
print(accuracy_table)
# Sauvegarder le tableau en format CSV pour une utilisation future
accuracy_table.to_csv("../../figures/dictator/dictator_continuous_setup_accuracy.csv")
\ No newline at end of file
import asyncio
import os
import pandas as pd
from src.dictator.dictator__continuous_setup import DictatorContinuousSetup, RestrictedWelfare
class DictatorContinuousSetupExperiment:
debug = True
def __init__(self, models: list[str], temperature: float, iterations: int, output_file: str):
self.models = models
self.temperature = temperature
self.iterations = iterations
self.output_file = output_file # Path to the CSV output file
# Helper function to escape double quotes in the reasoning string
def protect_reasoning(self, reasoning):
if reasoning:
return f'"{reasoning.replace("\"", "\"\"")}"'
return reasoning
async def run_experiment(self):
preferences = [RestrictedWelfare.SELFISH, RestrictedWelfare.ALTRUISTIC, RestrictedWelfare.EGALITARIAN]
file_exists = os.path.isfile(self.output_file) # Check if file already exists
# Run the dictator game for each model and preference
for model in self.models:
if self.debug:
print(f"Running experiment for model: {model}")
for preference in preferences:
print(f"Running with preference: {preference.name}")
for iteration in range(1, self.iterations + 1):
print(f"Iteration: {iteration}")
# Initialize the DictatorSetup for the current model and preference
game_agent = DictatorContinuousSetup(model=model, temperature=self.temperature, preference=preference)
try:
agent_response = await game_agent.run()
is_consistent = agent_response['is_consistent']
my_share = agent_response['my_share']
other_share = agent_response['other_share']
reasoning = agent_response['reasoning']
reasoning = self.protect_reasoning(reasoning)
except Exception as e:
print(f"Error in iteration {iteration} for model {model} ({preference.name}): {e}")
is_consistent = False
my_share, other_share, reasoning = None, None, None
# Create a single-row DataFrame for the current result
df = pd.DataFrame([{
'Iteration': iteration,
'Model': model,
'Temperature': self.temperature,
'Preference': preference.name,
'is_consistent': is_consistent,
'my_share': my_share,
'other_share': other_share,
'reasoning': reasoning
}])
# Append results to the CSV file
df.to_csv(self.output_file, mode='a', header=not file_exists, index=False)
file_exists = True # Ensure header is only written once
if self.debug:
print(f"Result for Iteration {iteration} saved to {self.output_file}")
# Running the experiment
if __name__ == "__main__":
models = ["llama3", "mistral-small", "deepseek-r1"] #"gpt-4.5-preview-2025-02-27"
temperature = 0.7
iterations = 30
output_file = '../../data/dictator/dictator_continuous_setup.csv'
experiment = DictatorContinuousSetupExperiment(models=models, temperature=temperature, iterations=iterations, output_file=output_file)
asyncio.run(experiment.run_experiment())
print(f"Experiment results saved to {output_file}")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment