File size: 32,598 Bytes
6dd335a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
"""

Silicon Subjects — protocol suite builder.



Writes data/protocols.jsonl: classic experimental protocols from behavioural

economics and psychology, each paired with *human anchor* statistics taken from

the published literature, split along the three axes a simulated population has

to reproduce:



    1. location    — the level of the response (mean)

    2. dispersion  — the spread of the response (sd)

    3. effect      — the direction and magnitude of the treatment contrast



Anchors are literature aggregates, not raw subject-level data. They are meant as

reference points for auditing a simulated population, NOT as exact replications;

always re-check against the cited source before drawing conclusions.



Usage:

    python scripts/build_protocols.py [--out-dir data]

"""

from __future__ import annotations

import argparse
import json
from pathlib import Path
from typing import Any, Dict, List, Optional


def P(  # noqa: N802 - short builder alias

    protocol_id: str,

    name: str,

    domain: str,

    paradigm: str,

    source: str,

    response: Dict[str, Any],

    conditions: List[Dict[str, str]],

    anchors: Dict[str, Dict[str, Any]],

    effect: Optional[Dict[str, Any]] = None,

    shape: Optional[str] = None,

    notes: str = "",

) -> Dict[str, Any]:
    return {
        "protocol_id": protocol_id,
        "name": name,
        "domain": domain,
        "paradigm": paradigm,
        "source": source,
        "response": response,
        "conditions": conditions,
        "anchors": anchors,
        "effect": effect,
        "shape": shape,
        "notes": notes,
    }


NUM = lambda lo, hi, unit: {"type": "numeric", "min": lo, "max": hi, "unit": unit}  # noqa: E731
BIN = lambda lo_label, hi_label: {  # noqa: E731
    "type": "binary",
    "min": 0,
    "max": 1,
    "unit": f"1 = {hi_label}, 0 = {lo_label}",
}


# ---------------------------------------------------------------------------
# 1-8. Social preferences
# ---------------------------------------------------------------------------

DICTATOR = P(
    "dictator_game",
    "Dictator game",
    "social_preferences",
    "one-shot unilateral allocation",
    "Engel (2011) 'Dictator games: a meta study', Experimental Economics 14:583-610",
    NUM(0, 10, "dollars transferred out of a $10 endowment"),
    [
        {
            "condition_id": "single",
            "label": "single decision",
            "prompt": (
                "You are taking part in an economics experiment. You have been given $10. "
                "You may transfer any amount from $0 to $10 to another participant, who "
                "cannot respond and cannot affect your payoff. You keep whatever you do "
                "not transfer. How many dollars do you transfer? Answer with a single number."
            ),
        }
    ],
    {
        "single": {
            "mean": 2.83,
            "sd": 2.60,
            "confidence": "medium",
            "note": "Meta-analytic mean share is ~28% of the stake; individual-level dispersion "
            "varies widely across subject pools, so treat sd as approximate.",
        }
    },
    shape="bimodal — mass at $0 and at half the stake",
    notes="The canonical other-regarding-preference measure. A simulated population that gives "
    "the 'fair' 50% is reproducing a norm, not the human distribution.",
)

ULTIMATUM_OFFER = P(
    "ultimatum_offer",
    "Ultimatum game — proposer offer",
    "social_preferences",
    "one-shot bargaining, proposer role",
    "Oosterbeek, Sloof & van de Kuilen (2004) 'Cultural differences in ultimatum game "
    "experiments', Experimental Economics 7:171-188; Camerer (2003)",
    NUM(0, 10, "dollars offered out of a $10 pie"),
    [
        {
            "condition_id": "proposer",
            "label": "proposer",
            "prompt": (
                "You are the proposer. You and one other participant will split $10. You "
                "propose how much of the $10 the other person receives. If they accept, you "
                "both get the proposed split; if they reject, neither of you gets anything. "
                "How many dollars do you offer? Answer with a single number."
            ),
        }
    ],
    {
        "proposer": {
            "mean": 4.00,
            "sd": 1.30,
            "confidence": "medium-high",
            "note": "Meta-analytic mean offer is ~40% of the pie, with a strong mode at 50%.",
        }
    },
    shape="unimodal with a spike at 50%",
    notes="Offers cluster at the equal split; very low offers are rare because proposers "
    "anticipate rejection.",
)

ULTIMATUM_REJECT = P(
    "ultimatum_reject_low",
    "Ultimatum game — rejection of a low offer",
    "social_preferences",
    "one-shot bargaining, responder role",
    "Camerer (2003) Behavioral Game Theory; Oosterbeek et al. (2004)",
    BIN("accept", "reject"),
    [
        {
            "condition_id": "low_offer",
            "label": "offer of $2 out of $10",
            "prompt": (
                "You are the responder. The proposer offers you $2 out of $10 and keeps $8. "
                "If you accept, you get $2 and they get $8. If you reject, neither of you "
                "gets anything. Answer 1 if you reject the offer, 0 if you accept it."
            ),
        }
    ],
    {
        "low_offer": {
            "mean": 0.50,
            "sd": None,
            "confidence": "medium",
            "note": "Rejection probability for offers at or below 20% of the pie is roughly "
            "40-60%; it rises steeply as the offer falls.",
        }
    },
    notes="Human responders punish unfairness at a material cost to themselves. Populations "
    "that never reject are behaving like pure payoff maximisers.",
)

PUBLIC_GOODS = P(
    "public_goods_oneshot",
    "Public goods game — one shot",
    "social_preferences",
    "linear voluntary contribution mechanism, one-shot",
    "Ledyard (1995) in Kagel & Roth (eds.), Handbook of Experimental Economics; "
    "Chaudhuri (2011) 'Sustaining cooperation in laboratory public goods experiments', "
    "Experimental Economics 14:47-83",
    NUM(0, 10, "tokens contributed out of 10"),
    [
        {
            "condition_id": "oneshot",
            "label": "one-shot, 4 players, MPCR 0.4",
            "prompt": (
                "You are in a group of 4 people. Each person receives 10 tokens. Any token "
                "you put into a common pool is multiplied by 1.6 and then split equally "
                "among the 4 members. Tokens you keep are worth 1 point each to you. This "
                "is a single, one-shot decision with the same 4 people. How many of your 10 "
                "tokens do you contribute to the pool? Answer with a single number."
            ),
        }
    ],
    {
        "oneshot": {
            "mean": 4.50,
            "sd": 2.60,
            "confidence": "medium",
            "note": "One-shot contributions typically run 40-60% of the endowment; "
            "individual-level spread is large.",
        }
    },
    notes="Contributions start well above the Nash prediction of zero. Free-riding is a "
    "minority behaviour, not the modal one.",
)

PUBLIC_GOODS_DECAY = P(
    "public_goods_decay",
    "Public goods game — decay across rounds",
    "social_preferences",
    "repeated voluntary contribution, partners condition",
    "Ledyard (1995); Chaudhuri (2011); Isaac & Walker (1988)",
    NUM(0, 10, "tokens contributed out of 10"),
    [
        {
            "condition_id": "round_1",
            "label": "round 1 of 10",
            "prompt": (
                "You are in a group of 4 people and will play 10 rounds with the same "
                "people. Each round every person receives 10 tokens; tokens placed in a "
                "common pool are multiplied by 1.6 and split equally among the 4 members. "
                "This is round 1. How many of your 10 tokens do you contribute? Answer with "
                "a single number."
            ),
        },
        {
            "condition_id": "round_10",
            "label": "round 10 of 10 (final round)",
            "prompt": (
                "You are in a group of 4 people and have played 9 rounds with the same "
                "people. Each round every person receives 10 tokens; tokens placed in a "
                "common pool are multiplied by 1.6 and split equally among the 4 members. "
                "The average contribution started around 4 tokens and has fallen steadily. "
                "This is round 10, the final round. How many of your 10 tokens do you "
                "contribute? Answer with a single number."
            ),
        },
    ],
    {
        "round_1": {"mean": 4.50, "sd": 2.60, "confidence": "medium", "note": ""},
        "round_10": {"mean": 1.80, "sd": 2.00, "confidence": "medium", "note": ""},
    },
    effect={
        "a": "round_1",
        "b": "round_10",
        "mean_diff": 2.70,
        "cohen_d": 1.10,
        "confidence": "medium-high",
        "source": "Ledyard (1995); Chaudhuri (2011)",
        "note": "The decay of cooperation without punishment or communication is one of the "
        "most robust regularities in experimental economics.",
    },
    notes="A population that holds contributions flat across rounds is missing the entire "
    "dynamics of conditional cooperation.",
)

TRUST_SEND = P(
    "trust_game_send",
    "Trust game — amount sent",
    "social_preferences",
    "one-shot investment game, trustor role",
    "Johnson & Mislin (2011) 'Trust games: a meta-analysis', Journal of Economic "
    "Psychology 32:865-889",
    NUM(0, 10, "dollars sent out of $10 (tripled before transfer)"),
    [
        {
            "condition_id": "trustor",
            "label": "trustor",
            "prompt": (
                "You are given $10 and paired with a stranger. You may send any amount from "
                "$0 to $10. Any amount you send is tripled by the experimenter and given to "
                "the stranger, who then decides how much, if anything, to send back to you. "
                "How many dollars do you send? Answer with a single number."
            ),
        }
    ],
    {
        "trustor": {
            "mean": 5.00,
            "sd": 2.70,
            "confidence": "medium",
            "note": "Meta-analytic mean send is ~50% of the endowment.",
        }
    },
    notes="Sending is positive in nearly every subject pool, but far from the payoff-maximising "
    "100%.",
)

TRUST_RETURN = P(
    "trust_game_return",
    "Trust game — amount returned",
    "social_preferences",
    "one-shot investment game, trustee role",
    "Johnson & Mislin (2011)",
    NUM(0, 18, "dollars returned out of $18 available"),
    [
        {
            "condition_id": "trustee",
            "label": "trustee",
            "prompt": (
                "A stranger was given $10 and sent you $6. The experimenter tripled it, so "
                "you have $18. You may send back any amount from $0 to $18 to the stranger. "
                "How many dollars do you send back? Answer with a single number."
            ),
        }
    ],
    {
        "trustee": {
            "mean": 6.50,
            "sd": 4.00,
            "confidence": "approximate",
            "note": "Meta-analytic 'trustworthiness' is ~0.37 of the amount available; values "
            "here are approximate and sensitive to the amount sent.",
        }
    },
    notes="Reciprocity, not pure self-interest: trustees typically return enough to make "
    "sending worthwhile.",
)

PRISONERS = P(
    "prisoners_dilemma",
    "Prisoner's dilemma — one shot",
    "social_preferences",
    "one-shot 2x2 symmetric game",
    "Sally (1995) 'Conversation and cooperation in social dilemmas', Rationality and "
    "Society 7:58-92",
    BIN("defect", "cooperate"),
    [
        {
            "condition_id": "oneshot",
            "label": "one-shot, anonymous, no communication",
            "prompt": (
                "You and one other person each choose to cooperate or defect, simultaneously "
                "and anonymously. You will never meet again. If both cooperate, each gets $6. "
                "If both defect, each gets $2. If you cooperate and the other defects, you get "
                "$0 and they get $9. If you defect and the other cooperates, you get $9 and "
                "they get $0. Answer 1 to cooperate, 0 to defect."
            ),
        }
    ],
    {
        "oneshot": {
            "mean": 0.47,
            "sd": None,
            "confidence": "medium",
            "note": "Meta-analytic cooperation in the one-shot prisoner's dilemma is ~45-50%; "
            "it collapses toward 0 with experience and rises with communication.",
        }
    },
    notes="Cooperation in the one-shot game is the benchmark case where a purely rational "
    "population and a human population diverge most sharply.",
)


# ---------------------------------------------------------------------------
# 9-14. Heuristics and biases
# ---------------------------------------------------------------------------

ASCH = P(
    "asch_conformity",
    "Asch line-judgement conformity",
    "social_influence",
    "unambiguous perceptual judgement under group pressure",
    "Asch (1951, 1955); Bond & Smith (1996) 'Culture and conformity', Psychological "
    "Bulletin 119:111-137",
    BIN("give the correct answer", "conform to the group's wrong answer"),
    [
        {
            "condition_id": "critical",
            "label": "critical trial, unanimous wrong majority",
            "prompt": (
                "You are judging which of three comparison lines matches a standard line in "
                "length. The correct match is obvious and you are confident about it. Six "
                "other participants answer before you and all six give the same clearly "
                "incorrect answer. It is now your turn, aloud. Answer 1 if you give the "
                "group's incorrect answer, 0 if you give the obviously correct one."
            ),
        }
    ],
    {
        "critical": {
            "mean": 0.32,
            "sd": None,
            "confidence": "medium",
            "note": "~32% of critical trials draw a conforming response in the classic "
            "setting; roughly 75% of participants conform at least once and ~25% never do.",
        }
    },
    notes="The cleanest available test of whether a simulated subject is willing to contradict "
    "an unambiguous fact under social pressure.",
)

ANCHORING = P(
    "anchoring",
    "Anchoring — comparative anchor then estimate",
    "heuristics_biases",
    "anchoring-and-adjustment",
    "Jacowitz & Kahneman (1995) 'Measures of anchoring in estimation tasks', Personality "
    "and Social Psychology Bulletin 21:1161-1166; Tversky & Kahneman (1974)",
    NUM(0, 100, "estimated percentage of African countries in the UN"),
    [
        {
            "condition_id": "high",
            "label": "high anchor (65%)",
            "prompt": (
                "Is the percentage of African countries in the United Nations more or less "
                "than 65%? Now estimate, as accurately as you can, the actual percentage of "
                "African countries in the United Nations. Answer with a single number "
                "between 0 and 100."
            ),
        },
        {
            "condition_id": "low",
            "label": "low anchor (10%)",
            "prompt": (
                "Is the percentage of African countries in the United Nations more or less "
                "than 10%? Now estimate, as accurately as you can, the actual percentage of "
                "African countries in the United Nations. Answer with a single number "
                "between 0 and 100."
            ),
        },
    ],
    {},
    effect={
        "a": "high",
        "b": "low",
        "mean_diff": 20.0,
        "cohen_d": 0.90,
        "confidence": "approximate",
        "source": "Jacowitz & Kahneman (1995)",
        "note": "Absolute estimates are item-specific, so only the contrast is anchored here; "
        "the high-low gap is typically 15-25 percentage points.",
    },
    notes="Deliberately has no level anchor: the point of this protocol is the contrast, not "
    "the absolute estimate. This is the pattern to use whenever only an effect size is "
    "trustworthy.",
)

ASIAN_DISEASE = P(
    "asian_disease",
    "Asian disease problem — risky-choice framing",
    "heuristics_biases",
    "gain vs. loss frame, logically equivalent options",
    "Tversky & Kahneman (1981) 'The framing of decisions and the psychology of choice', "
    "Science 211:453-458",
    BIN("choose the risky option", "choose the sure option"),
    [
        {
            "condition_id": "gain",
            "label": "gain frame (lives saved)",
            "prompt": (
                "Imagine the US is preparing for an unusual disease expected to kill 600 "
                "people. Two programmes are proposed. If programme A is adopted, 200 people "
                "will be saved. If programme B is adopted, there is a one-third probability "
                "that 600 people will be saved and a two-thirds probability that no one will "
                "be saved. Answer 1 for programme A (the sure option), 0 for programme B."
            ),
        },
        {
            "condition_id": "loss",
            "label": "loss frame (lives lost)",
            "prompt": (
                "Imagine the US is preparing for an unusual disease expected to kill 600 "
                "people. Two programmes are proposed. If programme C is adopted, 400 people "
                "will die. If programme D is adopted, there is a one-third probability that "
                "nobody will die and a two-thirds probability that 600 people will die. "
                "Answer 1 for programme C (the sure option), 0 for programme D."
            ),
        },
    ],
    {
        "gain": {"mean": 0.72, "sd": None, "confidence": "high", "note": ""},
        "loss": {"mean": 0.22, "sd": None, "confidence": "high", "note": ""},
    },
    effect={
        "a": "gain",
        "b": "loss",
        "mean_diff": 0.50,
        "cohen_d": 1.00,
        "confidence": "high",
        "source": "Tversky & Kahneman (1981)",
        "note": "Options A/C and B/D are formally identical; only the description differs.",
    },
    notes="One of the most replicated effects in the literature. A population that is "
    "frame-invariant here is not behaving like a human sample.",
)

ENDOWMENT = P(
    "endowment_effect",
    "Endowment effect — WTA vs. WTP",
    "heuristics_biases",
    "buyer vs. seller valuation of the same object",
    "Kahneman, Knetsch & Thaler (1990) 'Experimental tests of the endowment effect and "
    "the Coase theorem', Journal of Political Economy 98:1325-1348",
    NUM(0, 10, "dollars"),
    [
        {
            "condition_id": "wtp",
            "label": "buyer — maximum willingness to pay",
            "prompt": (
                "A coffee mug is for sale in the experiment. You do not own one. What is the "
                "largest amount, from $0 to $10, that you would be willing to pay to buy this "
                "mug? Answer with a single number."
            ),
        },
        {
            "condition_id": "wta",
            "label": "seller — minimum willingness to accept",
            "prompt": (
                "You have just been given a coffee mug and now own it. What is the smallest "
                "amount, from $0 to $10, that you would be willing to accept to sell this "
                "mug? Answer with a single number."
            ),
        },
    ],
    {
        "wtp": {"mean": 3.00, "sd": 1.50, "confidence": "approximate", "note": ""},
        "wta": {"mean": 6.50, "sd": 2.00, "confidence": "approximate", "note": ""},
    },
    effect={
        "a": "wta",
        "b": "wtp",
        "mean_diff": 3.50,
        "cohen_d": 0.80,
        "confidence": "approximate",
        "source": "Kahneman, Knetsch & Thaler (1990); Horowitz & McConnell (2002) meta-analysis",
        "note": "The WTA/WTP ratio is typically 2-3; absolute dollar values depend on the "
        "object and the subject pool.",
    },
    notes="Ownership alone shifts valuation. A population that quotes the same number in both "
    "roles is treating this as a pure valuation problem.",
)

CRT = P(
    "crt_batball",
    "Cognitive reflection — bat and ball",
    "heuristics_biases",
    "intuitive-but-wrong vs. reflective answer",
    "Frederick (2005) 'Cognitive reflection and decision making', Journal of Economic "
    "Perspectives 19:25-42",
    BIN("intuitive wrong answer (10 cents)", "reflective correct answer (5 cents)"),
    [
        {
            "condition_id": "batball",
            "label": "bat and ball",
            "prompt": (
                "A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the "
                "ball. How much does the ball cost? Answer 1 if your answer is 5 cents "
                "(correct), 0 if your answer is 10 cents."
            ),
        }
    ],
    {
        "batball": {
            "mean": 0.40,
            "sd": None,
            "confidence": "approximate",
            "note": "Correct rates on the bat-and-ball item run roughly 30-50% in student "
            "samples and lower in general-population samples.",
        }
    },
    notes="Scored as a binary here so that no free-text grading is needed. If you want the "
    "full 3-item CRT, run it as three binary protocols.",
)

CONJUNCTION = P(
    "conjunction_fallacy",
    "Conjunction fallacy — Linda problem",
    "heuristics_biases",
    "representativeness vs. the conjunction rule",
    "Tversky & Kahneman (1983) 'Extensional versus intuitive reasoning', Psychological "
    "Review 90:293-315",
    BIN("choose the single (logically correct) option", "choose the conjunction"),
    [
        {
            "condition_id": "between",
            "label": "between-subjects, ranking removed",
            "prompt": (
                "Linda is 31 years old, single, outspoken and very bright. She majored in "
                "philosophy. As a student she was deeply concerned with issues of "
                "discrimination and social justice, and she participated in anti-nuclear "
                "demonstrations. Which is more probable? Option 1: Linda is a bank teller. "
                "Option 2: Linda is a bank teller and is active in the feminist movement. "
                "Answer 1 if you choose option 2 (the conjunction), 0 if you choose option 1."
            ),
        }
    ],
    {
        "between": {
            "mean": 0.80,
            "sd": None,
            "confidence": "medium",
            "note": "Roughly 80-90% choose the conjunction in the standard version; rates fall "
            "with transparent wording or within-subjects designs.",
        }
    },
    notes="Choosing the conjunction violates the conjunction rule. This is the classic case "
    "where a well-aligned model looks *worse* than a human sample.",
)


# ---------------------------------------------------------------------------
# 15. Reasoning
# ---------------------------------------------------------------------------

WASON = P(
    "wason_selection",
    "Wason selection task — abstract vs. deontic",
    "reasoning",
    "conditional-reasoning / cheater-detection",
    "Wason (1968); Cosmides & Tooby (1992) 'Cognitive adaptations for social exchange', "
    "Cognition 31:187-276",
    BIN("any other selection", "exactly the two cards that can falsify the rule"),
    [
        {
            "condition_id": "abstract",
            "label": "abstract rule (D / K / 3 / 7)",
            "prompt": (
                "Four cards are on a table, showing D, K, 3 and 7. Every card has a letter on "
                "one side and a number on the other. The rule is: if a card has a D on one "
                "side, then it has a 3 on the other side. You may turn over only the cards "
                "needed to test whether the rule is false. The correct answer is the D card "
                "and the 7 card. Answer 1 if you would turn over exactly those two cards, "
                "0 otherwise."
            ),
        },
        {
            "condition_id": "deontic",
            "label": "social-contract rule (under-age drinking)",
            "prompt": (
                "You are checking whether people are violating the rule 'if a person is "
                "drinking beer, then they must be over 21'. Four people are in front of you: "
                "one drinking beer, one drinking coke, one aged 25, one aged 16. You may check "
                "only the ones needed to find a violation. The correct answer is the beer "
                "drinker and the 16-year-old. Answer 1 if you would check exactly those two "
                "people, 0 otherwise."
            ),
        },
    ],
    {
        "abstract": {"mean": 0.15, "sd": None, "confidence": "medium-high", "note": ""},
        "deontic": {"mean": 0.70, "sd": None, "confidence": "medium", "note": ""},
    },
    effect={
        "a": "deontic",
        "b": "abstract",
        "mean_diff": 0.55,
        "cohen_d": 1.20,
        "confidence": "medium-high",
        "source": "Cosmides & Tooby (1992); Wason (1968)",
        "note": "The content effect is large: the same logical form is easy when framed as "
        "cheater detection and hard when framed abstractly.",
    },
    notes="The correct answers are stated in the prompts, so this measures whether the "
    "population's *selection* matches human selection, not whether it can solve the logic.",
)


# ---------------------------------------------------------------------------
# 16-17. Prosocial behaviour and moral judgement
# ---------------------------------------------------------------------------

BYSTANDER = P(
    "bystander_effect",
    "Bystander effect — alone vs. in a group",
    "social_influence",
    "diffusion of responsibility",
    "Darley & Latané (1968) 'Bystander intervention in emergencies', Journal of Personality "
    "and Social Psychology 8:377-383; Latané & Nida (1981)",
    BIN("do not help", "help"),
    [
        {
            "condition_id": "alone",
            "label": "participant alone",
            "prompt": (
                "You are alone in a room filling out a questionnaire. You hear someone in the "
                "next room fall, cry out in pain and groan. No one else is present. Answer 1 "
                "if you would go to help, 0 if you would not."
            ),
        },
        {
            "condition_id": "group",
            "label": "two passive others present",
            "prompt": (
                "You are in a room with two other people, filling out a questionnaire. You "
                "hear someone in the next room fall, cry out in pain and groan. The other two "
                "people look up, then go back to their questionnaires without reacting. Answer "
                "1 if you would go to help, 0 if you would not."
            ),
        },
    ],
    {
        "alone": {"mean": 0.75, "sd": None, "confidence": "medium", "note": ""},
        "group": {"mean": 0.35, "sd": None, "confidence": "medium", "note": ""},
    },
    effect={
        "a": "alone",
        "b": "group",
        "mean_diff": 0.40,
        "cohen_d": 0.85,
        "confidence": "medium",
        "source": "Darley & Latané (1968); Latané & Nida (1981)",
        "note": "Meta-analytic effect is moderate and smaller than textbook accounts suggest, "
        "but consistently present.",
    },
    notes="A simulated population that helps at the same rate in both conditions shows no "
    "diffusion of responsibility at all.",
)

TROLLEY = P(
    "trolley_dilemma",
    "Trolley problem — switch vs. footbridge",
    "moral_judgment",
    "sacrificial moral dilemmas, means vs. side-effect",
    "Foot (1967); Thomson (1985) 'The trolley problem', Yale Law Journal 94:1395-1415; "
    "large-N replications (e.g. Hauser et al. 2007)",
    BIN("do nothing", "act to save the five"),
    [
        {
            "condition_id": "switch",
            "label": "switch (impersonal)",
            "prompt": (
                "A runaway trolley is heading for five people who will be killed if it "
                "continues. You are standing next to a switch. If you pull it, the trolley "
                "diverts to a side track where it will kill one person instead. Answer 1 if "
                "you pull the switch, 0 if you do not."
            ),
        },
        {
            "condition_id": "footbridge",
            "label": "footbridge (personal)",
            "prompt": (
                "A runaway trolley is heading for five people who will be killed if it "
                "continues. You are on a footbridge above the track next to a large stranger. "
                "The only way to stop the trolley is to push the stranger off the bridge onto "
                "the track; his body will stop the trolley, killing him but saving the five. "
                "Answer 1 if you push the stranger, 0 if you do not."
            ),
        },
    ],
    {
        "switch": {"mean": 0.85, "sd": None, "confidence": "medium-high", "note": ""},
        "footbridge": {"mean": 0.25, "sd": None, "confidence": "medium-high", "note": ""},
    },
    effect={
        "a": "switch",
        "b": "footbridge",
        "mean_diff": 0.60,
        "cohen_d": 1.30,
        "confidence": "medium-high",
        "source": "Thomson (1985); Hauser et al. (2007)",
        "note": "Both dilemmas sacrifice one to save five; the personal/impersonal contrast "
        "drives a very large difference in responding.",
    },
    notes="The two dilemmas are consequentially identical. A population that gives the same "
    "answer to both is doing utilitarian arithmetic, not reproducing human moral judgement.",
)


PROTOCOLS: List[Dict[str, Any]] = [
    DICTATOR,
    ULTIMATUM_OFFER,
    ULTIMATUM_REJECT,
    PUBLIC_GOODS,
    PUBLIC_GOODS_DECAY,
    TRUST_SEND,
    TRUST_RETURN,
    PRISONERS,
    ASCH,
    ANCHORING,
    ASIAN_DISEASE,
    ENDOWMENT,
    CRT,
    CONJUNCTION,
    WASON,
    BYSTANDER,
    TROLLEY,
]


def _validate(p: Dict[str, Any]) -> None:
    ids = {c["condition_id"] for c in p["conditions"]}
    for cid in p["anchors"]:
        assert cid in ids, f"{p['protocol_id']}: anchor for unknown condition {cid}"
    e = p.get("effect")
    if e:
        assert e["a"] in ids and e["b"] in ids, f"{p['protocol_id']}: bad effect condition"
        assert e["mean_diff"] != 0, f"{p['protocol_id']}: zero effect anchor"
    assert p["response"]["min"] < p["response"]["max"]


def main() -> None:
    ap = argparse.ArgumentParser()
    ap.add_argument(
        "--out-dir", default=str(Path(__file__).resolve().parents[1] / "data")
    )
    args = ap.parse_args()

    for p in PROTOCOLS:
        _validate(p)

    out = Path(args.out_dir)
    out.mkdir(parents=True, exist_ok=True)
    with (out / "protocols.jsonl").open("w", encoding="utf-8", newline="\n") as f:
        for p in PROTOCOLS:
            f.write(json.dumps(p, ensure_ascii=False) + "\n")

    n_eff = sum(1 for p in PROTOCOLS if p["effect"])
    n_loc = sum(1 for p in PROTOCOLS if p["anchors"])
    print(f"wrote {len(PROTOCOLS)} protocols -> {out / 'protocols.jsonl'}")
    print(f"  with location/dispersion anchors: {n_loc}")
    print(f"  with a treatment-effect anchor:   {n_eff}")


if __name__ == "__main__":
    main()