Commit ·
a044289
1
Parent(s): a89d872
Auto-close the outcome after 2s (no Space) + move practice tip clear of table legs
Browse files- OUTCOME screen now holds the open chest for OUTCOME_HOLD_MS (2s), then closes and
advances automatically; manual keys ignored during the hold so viewing time is uniform
- pausable: a break cancels the close-timer and resume restarts a fresh 2s (no soft-lock)
- on-screen 'Press SPACE to continue' -> 'the chest closes by itself...'; HOW_TO_PLAY
updated to describe the automatic close (no Space)
- practice teaching tip moved into the gap below the table legs and above the YOU/PARTNER
labels (was overlapping the legs)
- rating still uses arrows + Space to confirm (unchanged)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files changed (2)
51 unmodified lines525354555657412 unmodified lines470471472473474475476477478479480481482113 unmodified lines59659759859960060160 unmodified lines66266366466566666766851 unmodified linesM_OVERWORLD, M_CHOICE, M_OUTCOME, M_RATING = 0, 1, 2, 3A_UP, A_DOWN, A_LEFT, A_RIGHT, A_SPACE = 0, 1, 2, 3, 4action_keys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "]action_to_name = ["up", "down", "left", "right", "continue"]action_array = jnp.arange(len(action_keys))412 unmodified linesT(d, cx + 32, y0 - 74, "PARTNER", size=14, bold=True, fill=(255, 255, 255), center=True, outline=True)T(d, W // 2, 8, _earn(s_out, "YOURSELF"), size=18, bold=True, fill=accent, center=True, outline=True)T(d, W // 2, 34, _earn(o_out, "your PARTNER"), size=18, bold=True, fill=accent, center=True, outline=True)T(d, W // 2, H - 30, "Press SPACE to continue", size=16, bold=True,fill=(255, 255, 255), center=True, outline=True)# ---- practice: a rotating teaching tip, centred on the floor below the table ----if practice:tip = PRACTICE_TIPS[trial % len(PRACTICE_TIPS)]T(d, W // 2, floor_y + 18, tip, size=15, bold=True, fill=(255, 120, 120),center=True, outline=True)# ---- you + partner at the bottom; show only THIS try's outcome (never a running score) ----113 unmodified lineswith container.style("align-items: center;"):nicewebrl.clear_element(container)ui.html(_img_html(image))def never_success(timestep, params=None):60 unmodified lineskeyboard to open that chest.- Each **unique chest** brings a certain amount of coins — that's what matters. Watch out:the chests can **swap sides**, so don't click too fast!- You'll see what you and your partner got, then press **Space**.- Each house gives you **20 tries** — choose carefully, and finish all 20 before leavingeach house.- Then you'll **rate which unique chest you preferred**, and head to the next house.51 unmodified lines52535455565758412 unmodified lines471472473474475476477478479480481482483484113 unmodified lines59859960060160260360460560660760860961061161261361461561661760 unmodified lines67867968068168268368468551 unmodified linesM_OVERWORLD, M_CHOICE, M_OUTCOME, M_RATING = 0, 1, 2, 3A_UP, A_DOWN, A_LEFT, A_RIGHT, A_SPACE = 0, 1, 2, 3, 4OUTCOME_HOLD_MS = 2000 # the open chest stays visible this long, then closes automaticallyaction_keys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "]action_to_name = ["up", "down", "left", "right", "continue"]action_array = jnp.arange(len(action_keys))412 unmodified linesT(d, cx + 32, y0 - 74, "PARTNER", size=14, bold=True, fill=(255, 255, 255), center=True, outline=True)T(d, W // 2, 8, _earn(s_out, "YOURSELF"), size=18, bold=True, fill=accent, center=True, outline=True)T(d, W // 2, 34, _earn(o_out, "your PARTNER"), size=18, bold=True, fill=accent, center=True, outline=True)T(d, W // 2, H - 28, "the chest closes by itself…", size=14, bold=True,fill=(210, 210, 218), center=True, outline=True)# ---- practice: a rotating teaching tip, in the gap below the table legs (which end at# floor_y+40) and above the bottom YOU/PARTNER labels (at H-98) ----if practice:tip = PRACTICE_TIPS[trial % len(PRACTICE_TIPS)]T(d, W // 2, floor_y + 62, tip, size=13, bold=True, fill=(255, 120, 120),center=True, outline=True)# ---- you + partner at the bottom; show only THIS try's outcome (never a running score) ----113 unmodified lineswith container.style("align-items: center;"):nicewebrl.clear_element(container)ui.html(_img_html(image))# On the OUTCOME screen the open chest is shown for a fixed time, then it closes and the# next try appears automatically — no Space. Manual keys are ignored so the viewing time# is the same for everyone. Other screens (overworld / choice / rating) accept keys.# (armOutcomeTimer / cancelOutcomeTimer are installed in web_app so a break can pause it.)if int(timestep.state.mode) == M_OUTCOME:ui.run_javascript(f"window.accept_keys = false; window.__inOutcome = true;"f"if (window.armOutcomeTimer) window.armOutcomeTimer({OUTCOME_HOLD_MS});")else:ui.run_javascript("window.__inOutcome = false; window.accept_keys = true;""if (window.cancelOutcomeTimer) window.cancelOutcomeTimer();")def never_success(timestep, params=None):60 unmodified lineskeyboard to open that chest.- Each **unique chest** brings a certain amount of coins — that's what matters. Watch out:the chests can **swap sides**, so don't click too fast!- The chest **opens and shows** what you and your partner got for a couple of seconds, thenit **closes on its own** and the next try begins — you don't need to press anything.- Each house gives you **20 tries** — choose carefully, and finish all 20 before leavingeach house.- Then you'll **rate which unique chest you preferred**, and head to the next house.
87 unmodified lines888990919293526 unmodified lines62062162262362462519 unmodified lines6456466476486496502 unmodified lines65365465565665765887 unmodified lineslogger.warning(f"log_tech failed: {e}")def setup_telemetry():"""Log every button/mouse click (label + position + time) into the data file."""async def _on_click(e):526 unmodified linesfooter_container = ui.row()with meta_container.style("align-items: center;"):await footer(footer_container)setup_break_ui() # floating 'Take a break' button (shown only in main task)setup_telemetry() # log device/browser/version + every click + frameratewith display_container.style("align-items: center;"):19 unmodified linesms = round((_dt.datetime.now() - state["start"]).total_seconds() * 1000)await log_event("break", phase="end", break_ms=ms)app.storage.user["on_break"] = Falsedialog.close()ui.button("Keep playing", icon="play_arrow", on_click=resume) \2 unmodified linesasync def take_break():state["start"] = _dt.datetime.now()app.storage.user["on_break"] = Trueawait log_event("break", phase="start")dialog.open()87 unmodified lines888990919293949596979899100101102103104105106107108109110111112113114115116526 unmodified lines64364464564664764864919 unmodified lines6696706716726736746756766772 unmodified lines68068168268368468568687 unmodified lineslogger.warning(f"log_tech failed: {e}")def install_outcome_timer():"""Client-side helpers that auto-close the OUTCOME chest after a fixed time (no Space).Kept here so a break can cancel/restart the countdown without losing the trial."""ui.add_body_html("<script>""window.armOutcomeTimer = function(ms){"" if (window.__autoCont) clearTimeout(window.__autoCont);"" window.__autoCont = setTimeout(async function(){"" if (window.next_states && (' ' in window.next_states)){"" var ns = window.next_states[' ']; window.next_states = null;"" var img = document.getElementById('stateImage'); if (img) img.src = ns;"" window.next_imageSeenTime = new Date();"" await emitEvent('key_pressed', {key:' ', keydownTime:new Date(),"" imageSeenTime: window.imageSeenTime});"" }"" }, ms);""};""window.cancelOutcomeTimer = function(){"" if (window.__autoCont){ clearTimeout(window.__autoCont); window.__autoCont = null; }""};""</script>")def setup_telemetry():"""Log every button/mouse click (label + position + time) into the data file."""async def _on_click(e):526 unmodified linesfooter_container = ui.row()with meta_container.style("align-items: center;"):await footer(footer_container)install_outcome_timer() # auto-close the outcome chest after a fixed timesetup_break_ui() # floating 'Take a break' button (shown only in main task)setup_telemetry() # log device/browser/version + every click + frameratewith display_container.style("align-items: center;"):19 unmodified linesms = round((_dt.datetime.now() - state["start"]).total_seconds() * 1000)await log_event("break", phase="end", break_ms=ms)app.storage.user["on_break"] = False# if the break happened during an open chest, restart its close-timer freshui.run_javascript(f"if (window.__inOutcome && window.armOutcomeTimer) window.armOutcomeTimer({E.OUTCOME_HOLD_MS});")dialog.close()ui.button("Keep playing", icon="play_arrow", on_click=resume) \2 unmodified linesasync def take_break():state["start"] = _dt.datetime.now()app.storage.user["on_break"] = Trueui.run_javascript("if (window.cancelOutcomeTimer) window.cancelOutcomeTimer();") # pause countdownawait log_event("break", phase="start")dialog.open()
experiment_structure.py+22-5
web_app.py+28