A day that reroutes no longer stops the page at x8: every routing it needs goes to the route worker
The day split of #312 on its own, from 3.0.0, without its routing core, save or map changes. On a big network at x8 the game stopped whenever a day rerouted: after a failure, an event, the NOC intern's shift or the sales desk's signing, dayPost() routed on the page. * The day is a generator (dayRun(), dayPreRun(), dayPost()): each yield is a compute() it needs. dayTick() answers them on the spot (tests, fallback); in play rwGo() posts each one to the route worker. A failure (failureRun()), a DDoS and Auto-RTBH (ddosNewsRun()), the chaos monkey's snip (mkSnipRun()), an event's cut (eventRun()), the intern's shift (opsRun()) and the sales desk (slAutoRun(), its trials answered by the worker with offerTrial()) are steps of the day. fireFailure(), opsDay() and slAutoDay() still play them in one go. * yield DAY_REST lets a long day draw a frame between two steps (half a frame, 3 to 8 ms, RW.budget). One day in flight at a time, resting or routing: the clock waits for the day, and a half day is never saved. * UI.tick is set around every step (dayStep()), so quiet notifications hold in play, not only in dayTick(). * The daily mood check works out the land islands once per pass over the customers (TERR), instead of walking every land link for each customer afraid of sharks. This fix is thesysadmindev's, from #310; here the islands are worked out again if something routed meanwhile (RW.gen), since the mood loop can now rest between customers. Same game either way: tests/day-steps.test.js plays a second page as the worker and compares each day with dayTick(), the intern on every order, failures, events, DDoS and the monkey forced. Thanks to thesysadmindev for the profiling in #310 that pointed at the reroutes, and for the sharks fix.
This commit is contained in:
parent
9d64aa0144
commit
3c45d7dca1
26 changed files with 497 additions and 127 deletions
18
tests/frame-pacing.test.js
Normal file
18
tests/frame-pacing.test.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// How long a day may run on the page between two frames (src/game/99-loop.js, rwGo()): half a frame, from 3 to 8 ms.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
test("a day's steps follow the screen: half a frame between two, from 3 to 8 ms", () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();closeModal();UI.speed=0;");
|
||||
const run = (hz, n, extra = '') => ev(`(()=>{for(let i=0;i<${n};i++){window.__now=(window.__now||1000)+1000/${hz};${extra};frame(__now);}return RW.budget;})()`);
|
||||
assert.equal(run(240, 300), 3, 'a 240 Hz screen');
|
||||
const b = run(240, 1, '__now+=250');
|
||||
assert.ok(b < 6, `one long frame barely moves it: ${b}`);
|
||||
assert.equal(run(60, 300), 8, 'a 60 Hz screen');
|
||||
assert.ok(Math.abs(run(120, 300) - 1000 / 120 / 2) < 0.1, 'a 120 Hz screen: half its frame');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// The diverse-paths map new offers ask about (60-requirements.js) is built a millisecond a frame, before the first one
|
||||
Loading…
Add table
Add a link
Reference in a new issue