Prototype: route each game day in a Web Worker built from the page's own script

The day is split around its routing (dayPre, compute, dayPost). In play, S goes to a
worker started from a Blob URL of the page's inline game script (nothing fetched), the
day waits for R and finishes when it arrives. Actions, failures, events and the intern
still route synchronously; an action mid-day wins over the worker's stale answer.
R crosses as plain data: R.ef as its raw arrays (transferred), flows as columns.
Tests and any worker failure keep the synchronous path.
This commit is contained in:
Frederic Jung 2026-11-01 15:04:45 +01:00
parent 0355eb4e38
commit 9bdc2b70e1
No known key found for this signature in database
6 changed files with 130 additions and 11 deletions

View file

@ -5,6 +5,8 @@
/* A puzzle is never saved: only its stars are, under their own key (sot-puzzles). While one runs, the network it set
aside (UI.pzKeep) is the one saved, to its own slot, so closing the tab mid-puzzle loses nothing. */
function save(force,st){if(!st)st=pzOn()?UI.pzKeep:S;const id=UI.slot;
// Half a day (its routing still in the worker) is never saved: the day's end saves instead.
if(RW.job&&st===S){UI.saveDue=true;UI.lastSave=performance.now();return;}
if(!st||st.lost||st.mode==='puzzle'||!id||SLOT.no.has(id))return;
if(st===S){S.uiSpeed=UI.speed;S.cam={x:cam.x,y:cam.y,z:cam.z};}const f=UI.saveFail,failed=f&&f.s===st;
if(!force&&failed&&performance.now()-f.at<f.wait){UI.lastSave=performance.now();return;}