Spaces:
Running
Practice nights and a quiz before the last field counts
Browse filesThe block ran its first live trial as the first time anyone saw these cards.
For an antisocial condition that is the worst place to be learning the layout,
because a participant still working out who loses what produces choices that
read as indifference, which is the pattern the hypothesis predicts.
Three guided nights, banking nothing: a REST so they watch their own credits
rise while the partner loses 14, a WORK so they see the smaller pay and the
smaller loss, and a REST with the rest side shown as a range so the reveal is
not a surprise on a night that counts. All three use the biggest loss.
Two quiz items, on who loses what under each option, re-asked with the
explanation until both are right and capped at four attempts so nobody is held
at a screen. Both distractors on the REST item deny the harm, which is the one
belief the design depends on. The attempt count is saved, which is what makes
this usable as the prereg's exclusion criterion.
The main comprehension quiz could not cover this: its two items are about the
day task, what resting pays and that working needs every box inside 10
seconds, and neither mentions the partner losing anything.
New NightWatchPractice stage ahead of NightWatch, skipped together when
?watch= is off, STAGE_ORDER updated, and ?start=watchprep to reach the screens
without playing the whole task.
Also recorded: at the shipped pay gap of 1, working runs at 44% against 33% at
the old gap of 2, and the effort cost recovers at 0.77 against 0.72, with the
certainty discount unchanged at 0.92.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Files changed (7)
13 unmodified lines14151613 unmodified lineswith the work side held stated throughout: 0.927MINIMUM DETECTABLE GROUP DIFFERENCE13 unmodified lines141516171813 unmodified lineswith the work side held stated throughout: 0.927MINIMUM DETECTABLE GROUP DIFFERENCErep 0: recovered +0.117 (true +0.165)rep 1: recovered +0.138 (true +0.190)
39 unmodified lines4041424344454639 unmodified linesSTAGE_ORDER = ["Fatigue_pre", "HowToPlay", "Calibration", "Practice","Comprehension", "Ready", "Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty", "NightWatch","QuestionnaireTransition", "Fatigue_post", "NASA_TLX", "Effort_impact","PostTask_Motivation", "PostTask_Effort2", "PostTask_TaskRating","PostTask_Belief", "PostTask_Hypothetical", "PostTask_Strategy",39 unmodified lines404142434445464739 unmodified linesSTAGE_ORDER = ["Fatigue_pre", "HowToPlay", "Calibration", "Practice","Comprehension", "Ready", "Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty","NightWatchPractice", "NightWatch","QuestionnaireTransition", "Fatigue_post", "NASA_TLX", "Effort_impact","PostTask_Motivation", "PostTask_Effort2", "PostTask_TaskRating","PostTask_Belief", "PostTask_Hypothetical", "PostTask_Strategy",
769 unmodified lines770771772773774775769 unmodified linesreturn outif __name__ == "__main__":# quick sanity printmb = 20769 unmodified lines770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821769 unmodified linesreturn outdef make_watch_practice_trials(max_boxes, pid="practice"):"""Three GUIDED nights before the last field starts, banking nothing.The block ran its first live trial as the first time anyone saw thesecards, which for an antisocial condition is the worst place to be learningthe layout: a participant still working out who loses what produces datathat reads as indifference.One of each thing they have to understand. A guided REST so they see theirown credits go up while the partner loses the larger amount, a guided WORKso they see the smaller pay and the smaller loss, and a third with therest side shown as a RANGE so the reveal at the end of the night is not asurprise on a trial that counts."""rng = random.Random(_seed_from_pid(pid) + 11)levels = effort_levels(max_boxes)loss = max(WATCH_LOSS_REST) # the big one, so the stake is obviouslo, hi = WATCH_RANGES[loss]clo, chi = WATCH_RANGES[WATCH_LOSS_WORK]specs = [("rest", True), ("work", True), ("rest", False)]sides = balanced_sides(len(specs), rng)out = []for i, (guide, rest_certain) in enumerate(specs):out.append(dict(trialIndex=i, block=-1, beneficiary="other",nightWatch=True, practice=True, guide=guide,effortLevel="easy50", effortFrac=EFFORT_FRACS[0],reward=0, required=levels["easy50"],restCredit=WATCH_REST_PAY, workCredit=WATCH_WORK_PAY,lossSleep=loss, lossWork=WATCH_LOSS_WORK,saved=loss - WATCH_LOSS_WORK,infoCondition="certain" if rest_certain else "rest_vague",sleepCertain=rest_certain, watchCertain=True,sleepLo=None if rest_certain else lo,sleepHi=None if rest_certain else hi,workLo=None, workHi=None,lossSleepDrawn=(loss if rest_certain else _draw(lo, hi, rng)),lossWorkDrawn=WATCH_LOSS_WORK,endowment=WATCH_ENDOWMENT,condition=f"WATCHPRACTICE/{guide}",workSide=sides[i],decisionMs=DECISION_MS, workMs=WORK_MS, restMs=REST_MS,))return outif __name__ == "__main__":# quick sanity printmb = 20
1160 unmodified lines1161116211631164116511662 unmodified lines116911701171117211731174142 unmodified lines1317131813191320132113221160 unmodified linesHARVEST_SPEED_STAGE = "HarvestSpeed"UNCERTAINTY_STAGE = "Uncertainty"NIGHT_WATCH_STAGE = "NightWatch"def night_watch_on():2 unmodified linesreturn bool(app.storage.user.get("night_watch"))def _night_watch_stage():"""One block of the last field: REST, which fills your bag from the otherplayer's standing crop for a small fixed payment and leaves the rest of it142 unmodified lines# when the link does not ask for it._harvest_speed_stage(),_uncertainty_stage(),_night_watch_stage(),_fb("QuestionnaireTransition", credits_bridge_display),Q.fatigue_stage("post"),1160 unmodified lines11611162116311641165116611672 unmodified lines11701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207142 unmodified lines13501351135213531354135513561160 unmodified linesHARVEST_SPEED_STAGE = "HarvestSpeed"UNCERTAINTY_STAGE = "Uncertainty"NIGHT_WATCH_STAGE = "NightWatch"NIGHT_WATCH_PRACTICE_STAGE = "NightWatchPractice"def night_watch_on():2 unmodified linesreturn bool(app.storage.user.get("night_watch"))def _night_watch_practice_stage():"""Three guided nights, then the two-item quiz, before anything counts.The partner and the endowment are set up HERE rather than in the liveblock, because the practice screens name them and the quiz asks aboutthem. The live block reads what this stage wrote."""async def _display(stage, container):th = TH.current_theme()pid = app.storage.user.get("pid", "0001")# Set here too, so a dev link that jumps straight past the practice# stage still has a partner to name.app.storage.user.setdefault("random_id_night", night_partner_id())app.storage.user.setdefault("partner_avatar_idx_night",night_partner_avatar_idx())partner = partner_label_plain("night")trials = D.make_watch_practice_trials(get_max_boxes(), pid)intro = _last_field_intro(th, partner) + ("\n\n---\n\n**{} practice nights first.** Nothing you do on ""these counts for anyone. Follow the arrow so you have seen both ""choices before the real nights start.".format(len(trials)))res = await _run_block(stage, container, trials, practice=True,intro_md=intro, time_of_day="night",partner_id=app.storage.user["random_id_night"])import questionnaires as Qquiz = await Q.watch_comprehension_body(container)return dict(practice=True, label="NightWatchPractice",partner=app.storage.user.get("random_id_night"),quiz=quiz, trials=res)return _fb(NIGHT_WATCH_PRACTICE_STAGE, _display)def _night_watch_stage():"""One block of the last field: REST, which fills your bag from the otherplayer's standing crop for a small fixed payment and leaves the rest of it142 unmodified lines# when the link does not ask for it._harvest_speed_stage(),_uncertainty_stage(),_night_watch_practice_stage(),_night_watch_stage(),_fb("QuestionnaireTransition", credits_bridge_display),Q.fatigue_stage("post"),
586 unmodified lines587588589590591592586 unmodified linesdef comprehension_stage():async def _display(stage, container):# intro (SL-style wording)586 unmodified lines587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668586 unmodified lines# ----------------------------------------------------------------------------# The last field's own quiz. The main comprehension items are about the day# task -- what resting pays and that working needs every box inside 10 seconds# -- and neither asks the one belief this block depends on, which is that# resting costs the partner. A participant who missed that produces choices# that look like indifference, so the quiz doubles as the exclusion criterion.# ----------------------------------------------------------------------------def watch_comp_items():th = TH.current_theme()big = max(D.WATCH_LOSS_REST)return [dict(key="watch_comp_rest", qid="W1",prompt="On a night when you choose REST, what happens?",options=[(f"I collect {D.WATCH_REST_PAY} credits, and my partner "f"loses the larger amount.","I collect credits and my partner loses the larger amount"),(f"I collect {D.WATCH_REST_PAY} credits, and my partner "f"loses nothing.","I collect credits and my partner loses nothing"),("I collect nothing, and my partner loses nothing.","I collect nothing and my partner loses nothing"),], correct=0,explain=f"Resting pays you **{D.WATCH_REST_PAY} credits** and "f"leaves their field standing, so they lose the larger "f"amount, up to **{big} credits**."),dict(key="watch_comp_work", qid="W2",prompt="On a night when you choose WORK, what happens?",options=[(f"I keep {D.WATCH_WORK_PAY} credit, and my partner loses "f"only a little.","I keep one credit and my partner loses only a little"),(f"I keep {D.WATCH_WORK_PAY} credit, and my partner still "f"loses the larger amount.","I keep one credit and my partner still loses the larger amount"),(f"I collect more than {D.WATCH_REST_PAY} credits, and my "f"partner loses nothing.","I collect more credits and my partner loses nothing"),], correct=0,explain=f"{th['verb'].capitalize()}ing their field in pays you "f"**{D.WATCH_WORK_PAY} credit**, which is less than "f"resting, and holds their loss down to "f"**{D.WATCH_LOSS_WORK} credits**."),]async def watch_comprehension_body(container):"""The quiz itself, callable from another stage.Out here rather than only inside a stage because the last field runs it atthe end of its practice stage: a separate stage for two questions wouldadd a row to STAGE_ORDER and to the analysis progress column for no gain."""items = watch_comp_items()responses = await _comp_round(container, 1, items)attempts = 1while any(not r["is_correct"] for r in responses[-len(items):]):wrong = [items[i] for i, r in enumerate(responses[-len(items):])if not r["is_correct"]]nicewebrl.clear_element(container)ev = asyncio.Event()with container.style("align-items:center; max-width:680px;"):ui.markdown("### Not quite. Let's go through that again.")for it in wrong:ui.markdown(f"- {it['explain']}")ui.button("Try again", on_click=lambda: ev.set())await ev.wait()attempts += 1responses += await _comp_round(container, attempts, wrong)if attempts >= 4: # never trap anyone in the loop, since abreak # participant who cannot get it is data,# not someone to hold at a screenreturn dict(measure="watch_comprehension", attempts=attempts,responses=responses)def comprehension_stage():async def _display(stage, container):# intro (SL-style wording)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115"""The last field's practice nights and its two-item quiz.
The block ran its first live trial as the first time anyone saw these cards.For an antisocial condition that is the worst place to be learning the layout:a participant still working out who loses what produces choices that read asindifference, which is the same pattern the hypothesis predicts.
The quiz doubles as the exclusion criterion, so what it asks has to be thebelief the design depends on."""import os
import pytest
os.environ.setdefault("RELOAD", "0")os.environ.setdefault("STORAGE_SECRET", "test")
import effort_design as Dimport effort_stages as Eimport questionnaires as Q
@pytest.fixturedef storage(monkeypatch): store = {"theme": "harvest"} monkeypatch.setattr(E.app, "storage", type("S", (), {"user": store})()) monkeypatch.setattr(Q.app, "storage", type("S", (), {"user": store})()) monkeypatch.setattr(Q.TH.app, "storage", type("S", (), {"user": store})()) return store
def prac(max_boxes=12): return D.make_watch_practice_trials(max_boxes)
def test_both_choices_are_guided_at_least_once(): """A participant who only ever saw one option would not know the other exists until it mattered.""" guides = {t["guide"] for t in prac()} assert guides == {"rest", "work"}
def test_one_practice_night_shows_a_range(): """So the reveal at the end of a night is not a surprise on a trial that counts for money.""" vague = [t for t in prac() if not t["sleepCertain"]] assert len(vague) >= 1 for t in vague: assert (t["sleepLo"], t["sleepHi"]) == D.WATCH_RANGES[t["lossSleep"]]
def test_practice_uses_the_biggest_loss_so_the_stake_is_visible(): assert {t["lossSleep"] for t in prac()} == {max(D.WATCH_LOSS_REST)}
def test_practice_banks_nothing(storage): """Guided rounds must not move any purse. They are the one place a participant is told what to choose.""" storage.update({"watch_log": [], "self_points": 0, "watch_store": D.WATCH_ENDOWMENT}) for t in prac(): assert t["practice"] is True assert storage["watch_log"] == []
def test_practice_carries_the_fields_the_cards_need(): """_spec_for_js raised KeyError on a missing field twice before, once for `required` and once for `restCredit`, both found by playing.""" for t in prac(): spec = E._spec_for_js(t, "P2-00000", "night") for key in ("restCredit", "workCredit", "lossSleep", "lossWork", "required", "nightWatch", "workSide"): assert spec[key] is not None, key
def test_the_quiz_asks_about_who_loses_on_each_option(storage): """Not what the main quiz asks. That one covers the day task: what resting pays and that working needs every box in 10 seconds.""" items = Q.watch_comp_items() assert len(items) == 2 prompts = " ".join(i["prompt"].lower() for i in items) assert "rest" in prompts and "work" in prompts for it in items: correct = it["options"][it["correct"]][0].lower() assert "partner" in correct
def test_the_correct_rest_answer_says_the_partner_loses_more(storage): rest = Q.watch_comp_items()[0] assert "larger" in rest["options"][rest["correct"]][0] wrong = [o[0] for i, o in enumerate(rest["options"]) if i != rest["correct"]] assert any("nothing" in o for o in wrong), "needs a distractor that denies the harm"
def test_the_quiz_quotes_the_live_amounts(storage): """It drifted from the cards once already, when the uncertainty block's intro still quoted the day task's rest credit.""" items = Q.watch_comp_items() text = " ".join(o[0] for it in items for o in it["options"]) assert f"{D.WATCH_REST_PAY} credits" in text assert f"{D.WATCH_WORK_PAY} credit" in text
def test_the_practice_stage_runs_before_the_live_block(): names = [s.name for s in E.build_experiment().stages] assert names.index(E.NIGHT_WATCH_PRACTICE_STAGE) < names.index(E.NIGHT_WATCH_STAGE)
def test_both_stages_are_skipped_together(storage): """Leaving the practice on while the block is off would walk an ordinary participant through three nights about a partner they never meet.""" import web_app storage.clear() assert E.night_watch_on() is False storage["night_watch"] = True assert E.night_watch_on() is True268 unmodified lines269270271272273274275239 unmodified lines515516517518519520521268 unmodified lines# Straight into the night watch, past everything before it."watch": {"Fatigue_pre", "HowToPlay", "Calibration", "Practice", "Comprehension", "Ready","Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty"},}239 unmodified linesif not E.uncertainty_on():dev_skip = dev_skip | {E.UNCERTAINTY_STAGE}if not E.night_watch_on():dev_skip = dev_skip | {E.NIGHT_WATCH_STAGE}# Combined SONA study only: demographics and the TriPM describe the person,# not the task, so they run once -- for whichever of the two tasks the# participant finishes SECOND. Without this they would answer 58 TriPM items268 unmodified lines269270271272273274275276277278279280281239 unmodified lines521522523524525526527268 unmodified lines# Straight into the night watch, past everything before it."watch": {"Fatigue_pre", "HowToPlay", "Calibration", "Practice", "Comprehension", "Ready","Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty","NightWatchPractice"},# Straight into the last field's practice nights and quiz, which is the only# way to look at those screens without playing the whole task to reach them."watchprep": {"Fatigue_pre", "HowToPlay", "Calibration", "Practice", "Comprehension", "Ready","Harvest1", "Break", "Harvest2","Night1", "Night2", "Night2b", "Night1b", "HarvestSpeed", "Uncertainty"},}239 unmodified linesif not E.uncertainty_on():dev_skip = dev_skip | {E.UNCERTAINTY_STAGE}if not E.night_watch_on():dev_skip = dev_skip | {E.NIGHT_WATCH_STAGE, E.NIGHT_WATCH_PRACTICE_STAGE}# Combined SONA study only: demographics and the TriPM describe the person,# not the task, so they run once -- for whichever of the two tasks the# participant finishes SECOND. Without this they would answer 58 TriPM items