Commit ·
8410662
1
Parent(s): ed263c4
Coin tweaks + clean SPACE-to-continue after practice (no lingering toast)
Browse filesCoin trial tweaks:
- golden coins now show '10'
- box text is now two side-by-side boxed chips '+10 YOU' / '0 YOUR PARTNER' (dropped 'for',
smaller, next to each other instead of stacked)
Practice -> quiz:
- removed the auto-advance; after the preference choice it shows a clean end card
'Great, practice done! Press SPACE to continue to the quiz.' and SPACE advances
- the nicewebrl 'press any arrow key to continue' toast no longer lingers: env stages now
have a finite msg_display_time (1500ms) and the quiz screen clears any leftover toast
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Files changed (2)
- experiment_structure.py+6-17
- web_app.py+13-9
444 unmodified lines445446447448449450451452453454455456402 unmodified lines85986086186286386486586686786886987087187287387487587687730 unmodified lines90890991091191291391497 unmodified lines101210131014101510161017444 unmodified linesT(d, 16, 40, "Walk with the arrow keys and step onto a house to go inside.",size=15, fill=(205, 210, 220), outline=True)d.rectangle([OX - 2, OY - 2, OX + BOARD_W + 1, OY + BOARD_H + 1], outline=(20, 24, 32), width=2)# once practice is finished we jump straight to the quiz; this frame is only a brief fallbackif practice and explored >= n_active:d.rectangle([0, 0, W, H], fill=(20, 26, 38))T(d, W // 2, H // 2 - 26, "Great, practice done!", size=30, bold=True,fill=(245, 230, 150), center=True, outline=True)T(d, W // 2, H // 2 + 18, "Taking you to the quiz…", size=20,fill=(235, 235, 240), center=True, outline=True)return img402 unmodified linesui.run_javascript("if(window.sfx) window.sfx.step();")elif mode == M_CHOICE:self._maybe_swap(s)# PRACTICE: once it's finished, go straight to the quiz — no 'press any key' screen.# Deferred so it runs after this key-press handler returns (avoids re-entrancy).if self.metadata.get("task") == "practice" and bool(ts.last()):async def _auto_advance():await asyncio.sleep(0.05)try:await self.finish_stage() # idempotent; safe if a key also firescb = self.get_user_data("local_handle_key_press")if cb:await cb()except Exception as e:logger.warning(f"practice auto-advance failed: {e}")asyncio.create_task(_auto_advance())except Exception as e:logger.warning(f"outcome auto-close hook failed: {e}")30 unmodified linesname=name, web_env=jax_web_env, action_keys=action_keys, action_to_name=action_to_name,env_params=params, render_fn=render_state, vmap_render_fn=vmap_render_fn, precompile=False,display_fn=env_stage_display_fn, evaluate_success_fn=never_success, check_finished=all_done,min_success=10_000, max_episodes=1, notify_success=False,custom_data_fn=custom_data_fn, metadata=metadata)97 unmodified linesasync def quiz_display(stage, container):"""Ask each item once; lock the buttons after answering; no re-asking."""nicewebrl.clear_element(container)ev = asyncio.Event()with container.style("align-items:center; max-width:720px;"):ui.markdown("## Let's see if everything's clear!")444 unmodified lines445446447448449450451452453454455456402 unmodified lines85986086186286386430 unmodified lines89589689789889990090197 unmodified lines9991000100110021003100410051006444 unmodified linesT(d, 16, 40, "Walk with the arrow keys and step onto a house to go inside.",size=15, fill=(205, 210, 220), outline=True)d.rectangle([OX - 2, OY - 2, OX + BOARD_W + 1, OY + BOARD_H + 1], outline=(20, 24, 32), width=2)# practice finished: a clean end card; SPACE (any key) takes them to the quizif practice and explored >= n_active:d.rectangle([0, 0, W, H], fill=(20, 26, 38))T(d, W // 2, H // 2 - 30, "Great, practice done!", size=30, bold=True,fill=(245, 230, 150), center=True, outline=True)T(d, W // 2, H // 2 + 16, "Press SPACE to continue to the quiz.", size=20,fill=(235, 235, 240), center=True, outline=True)return img402 unmodified linesui.run_javascript("if(window.sfx) window.sfx.step();")elif mode == M_CHOICE:self._maybe_swap(s)except Exception as e:logger.warning(f"outcome auto-close hook failed: {e}")30 unmodified linesname=name, web_env=jax_web_env, action_keys=action_keys, action_to_name=action_to_name,env_params=params, render_fn=render_state, vmap_render_fn=vmap_render_fn, precompile=False,display_fn=env_stage_display_fn, evaluate_success_fn=never_success, check_finished=all_done,min_success=10_000, max_episodes=1, notify_success=False, msg_display_time=1500,custom_data_fn=custom_data_fn, metadata=metadata)97 unmodified linesasync def quiz_display(stage, container):"""Ask each item once; lock the buttons after answering; no re-asking."""nicewebrl.clear_element(container)# clear any leftover 'press any arrow key to continue' toast from the practice stageui.run_javascript("document.querySelectorAll('.q-notification').forEach(function(e){e.remove();});")ev = asyncio.Event()with container.style("align-items:center; max-width:720px;"):ui.markdown("## Let's see if everything's clear!")
172 unmodified lines1731741751761771781791801811 unmodified line18318418518618718818923 unmodified lines2132142152162172182192202219 unmodified lines231232233234235236237238172 unmodified lines".thclbl{position:fixed;z-index:47;color:#fff;font-weight:bold;font-size:12px;white-space:nowrap;""font-family:'DejaVu Sans',Verdana,Geneva,sans-serif;transform:translateX(-50%);pointer-events:none;""text-shadow:1px 1px 0 #000,-1px 1px 0 #000,1px -1px 0 #000,-1px -1px 0 #000;}" # crisp outline, no soft shadow".thctxt{position:fixed;z-index:47;font-weight:bold;font-size:15px;white-space:nowrap;text-align:center;""font-family:'DejaVu Sans',Verdana,Geneva,sans-serif;transform:translateX(-50%);pointer-events:none;""text-shadow:1px 1px 0 #000,-1px 1px 0 #000,1px -1px 0 #000,-1px -1px 0 #000;}" # '+10 for YOU' style box text"@keyframes thblink{0%,100%{opacity:1}50%{opacity:0.12}}""</style>""<script>"1 unmodified line"window.clearCoinFloat=function(){window.__coins.forEach(function(e){e.remove();});window.__coins=[];};"# a plain GOLD coin (the 'money' that travels) vs a coloured FEEDBACK coin (the result)"window.__gold=function(x,y){var c=document.createElement('div');c.className='thcoin';"" c.style.background='#f1c40f';c.style.border='2px solid #bf960a';"" c.style.left=(x-17)+'px';c.style.top=(y-17)+'px';"" document.body.appendChild(c);window.__coins.push(c);return c;};""window.__feed=function(val,x,y){var c=document.createElement('div');c.className='thcoin';"23 unmodified lines" },620);};"# ---- coin model: ONE golden coin. Text on the box ('+10 for YOU'); a gain coin flies box->pocket,# a loss coin flies pocket->box, a 0 shows text only. (Trial — easy to revert.) ----"window.__coinText=function(val,who,x,y){var c=document.createElement('div');c.className='thctxt';"" c.style.color=(val>0?'#ffd23f':(val<0?'#ff6b5c':'#e6e6ea'));c.style.left=x+'px';c.style.top=y+'px';"" c.textContent=(val>0?'+':'')+val+' for '+who;document.body.appendChild(c);window.__coins.push(c);return c;};""window.__coinMove=function(val,start,pocket,chest){"" if(val>0){var c=window.__gold(start[0],start[1]);window.__moveTo(c,pocket[0],pocket[1]);"" setTimeout(function(){if(window.sfx)window.sfx.kaching();"9 unmodified lines" var P=function(ix,iy){return [r.left+ix*r.width/720, r.top+iy*r.height/560];};"" var leftChest=P(215,250),rightChest=P(505,250),youC=P(282,486),parC=P(438,486);"" var chest=chosenSide==0?leftChest:rightChest;"" window.__coinText(self,'YOU',chest[0],chest[1]-24);" # +10 for YOU" window.__coinText(other,'YOUR PARTNER',chest[0],chest[1]+2);" # -10 for YOUR PARTNER" var yStart=[chest[0]-16,chest[1]+30], pStart=[chest[0]+16,chest[1]+30];" # a gain coin sits on the box" var acts=floatOrder==0?[[self,yStart,youC],[other,pStart,parC]]:[[other,pStart,parC],[self,yStart,youC]];"" acts.forEach(function(it,i){setTimeout(function(){window.__coinMove(it[0],it[1],it[2],chest);},480+i*620);});};"172 unmodified lines1731741751761771781791801811821831 unmodified line18518618718818919019123 unmodified lines2152162172182192202212222232242252269 unmodified lines236237238239240241242172 unmodified lines".thclbl{position:fixed;z-index:47;color:#fff;font-weight:bold;font-size:12px;white-space:nowrap;""font-family:'DejaVu Sans',Verdana,Geneva,sans-serif;transform:translateX(-50%);pointer-events:none;""text-shadow:1px 1px 0 #000,-1px 1px 0 #000,1px -1px 0 #000,-1px -1px 0 #000;}" # crisp outline, no soft shadow".thctxtwrap{position:fixed;z-index:47;transform:translateX(-50%);display:flex;gap:6px;""pointer-events:none;white-space:nowrap;}"".thctxt{font-weight:bold;font-size:13px;font-family:'DejaVu Sans',Verdana,Geneva,sans-serif;""padding:2px 7px;border-radius:7px;background:rgba(18,20,28,0.74);border:1px solid rgba(255,255,255,0.4);""text-shadow:1px 1px 0 #000,-1px 1px 0 #000,1px -1px 0 #000,-1px -1px 0 #000;}" # boxed '+10 YOU' chip"@keyframes thblink{0%,100%{opacity:1}50%{opacity:0.12}}""</style>""<script>"1 unmodified line"window.clearCoinFloat=function(){window.__coins.forEach(function(e){e.remove();});window.__coins=[];};"# a plain GOLD coin (the 'money' that travels) vs a coloured FEEDBACK coin (the result)"window.__gold=function(x,y){var c=document.createElement('div');c.className='thcoin';"" c.style.background='#f1c40f';c.style.border='2px solid #bf960a';c.style.color='#5a4a0a';c.textContent='10';" # coin shows a 10" c.style.left=(x-17)+'px';c.style.top=(y-17)+'px';"" document.body.appendChild(c);window.__coins.push(c);return c;};""window.__feed=function(val,x,y){var c=document.createElement('div');c.className='thcoin';"23 unmodified lines" },620);};"# ---- coin model: ONE golden coin. Text on the box ('+10 for YOU'); a gain coin flies box->pocket,# a loss coin flies pocket->box, a 0 shows text only. (Trial — easy to revert.) ----"window.__coinText=function(self,other,x,y){var wrap=document.createElement('div');wrap.className='thctxtwrap';"" wrap.style.left=x+'px';wrap.style.top=y+'px';"" function chip(v,who){var c=document.createElement('span');c.className='thctxt';"" c.style.color=(v>0?'#ffd23f':(v<0?'#ff6b5c':'#e6e6ea'));c.textContent=(v>0?'+':'')+v+' '+who;return c;}"" wrap.appendChild(chip(self,'YOU'));wrap.appendChild(chip(other,'YOUR PARTNER'));"" document.body.appendChild(wrap);window.__coins.push(wrap);return wrap;};""window.__coinMove=function(val,start,pocket,chest){"" if(val>0){var c=window.__gold(start[0],start[1]);window.__moveTo(c,pocket[0],pocket[1]);"" setTimeout(function(){if(window.sfx)window.sfx.kaching();"9 unmodified lines" var P=function(ix,iy){return [r.left+ix*r.width/720, r.top+iy*r.height/560];};"" var leftChest=P(215,250),rightChest=P(505,250),youC=P(282,486),parC=P(438,486);"" var chest=chosenSide==0?leftChest:rightChest;"" window.__coinText(self,other,chest[0],chest[1]-22);" # side-by-side boxed '+10 YOU 0 YOUR PARTNER'" var yStart=[chest[0]-16,chest[1]+30], pStart=[chest[0]+16,chest[1]+30];" # a gain coin sits on the box" var acts=floatOrder==0?[[self,yStart,youC],[other,pStart,parC]]:[[other,pStart,parC],[self,yStart,youC]];"" acts.forEach(function(it,i){setTimeout(function(){window.__coinMove(it[0],it[1],it[2],chest);},480+i*620);});};"
experiment_structure.py+6-17
web_app.py+13-9