diff --git a/CHANGELOG.md b/CHANGELOG.md index 69a9dff..7fe00f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] - Cancelling an IRU, giving up your own fiber or decommissioning a POP now puts the optics on its fibers back on the spares shelf, instead of throwing them away (#229). +- Big networks freeze for less on every game day and every click: working out where traffic goes skips exits whose route is already full, so a game day takes about 40% less time (#210). Traffic goes exactly where it went before. - Premium submarine terminals and Optical engineering can no longer be bought on a cable where they would change nothing (#198). The button now says so, and an upgrade that only helps together with the other one stays available. - A wave size that is sold out on a route can no longer be reached by upgrading a smaller wave on it (#201). The upgrade button says how long it is sold out, just like when buying. - Choosing Both for a PNI with one member now really splits it: the second member arrives in the other building when the augment lands, instead of joining the first (#219). diff --git a/src/game/80-simulation/30-compute.js b/src/game/80-simulation/30-compute.js index eba967a..4c04ae8 100644 --- a/src/game/80-simulation/30-compute.js +++ b/src/game/80-simulation/30-compute.js @@ -182,8 +182,8 @@ function compute(){ let V=L;if(NCOMP>1){const cs=[];for(const e of L){const k=COMP[e.ci];if(k>=0)(cs[k]||(cs[k]=[])).push(e);}for(const s of cs)if(s)idx(s);V={cs};}else idx(L);LIST.set(key,V);m[r]=V;}} // The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index. let f=null,Dv=null,Pv=null,PP=null,vis=0;const walked=[],G=[],REST=[],NEG=[]; - // An exit the flow can still try: not visited yet, not full when the flow started, and reachable from the POP. - const usable=e=>e.vis!==vis&&e.useda.hp-b.hp||Dv[a.ci]-Dv[b.ci]; + // An exit the flow can still try: not visited yet, not full when the flow started, reachable, and not on a saturated path. + const usable=e=>e.vis!==vis&&e.useda.hp-b.hp||Dv[a.ci]-Dv[b.ci]; // Push up to `want` along one path to exit e; returns what fitted. Capacity only shrinks while routing, so a // path with one full link or node fits nothing for the rest of this pass: mark it, and later tries cost nothing // (most tries are into paths that filled up earlier). @@ -238,7 +238,7 @@ function compute(){ when it does not fit. Most often the group is the POP's own exits: with no preferred exit on the list and no other city at distance 0, the usable ones here are exactly the first group, already in order. */ G.length=0; - if(!lst.hi&&ALONE[f.ci]){const here=lst.at.get(f.ci);if(here)for(const e of here)if(e.usede.usede.used=e.cap){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp; + for(let li=0,LN=lst.length;li=e.cap||gone(e)){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp; if(h=lst.length&&full){let k=0;for(let li=0;lie.used(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]); for(let i=0;i1e-6;){ let j=i+1;while(j { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e8;UI.speed=0;for(const g of GOALS)S.done[g.id]=0;"); + ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});"); + ev("ACT.buildPop({city:'par'});ACT.launchBB({city:'par'});"); + ev("S.links.push({id:'x1',a:'fra',b:'par',kind:'wave',tier:0,km:450,mult:1,mo:1000,ready:0,cut:0});"); + ev("compute();"); + assert.ok(ev("R.load['x1'] >= 10 - 1e-6"), 'intercity wave is saturated'); + assert.ok(ev("R.load['x1'] <= 10 + 1e-6"), 'and carries no more than it can'); + // Skipping exits behind the full wave changes nothing: routing again gives the same answer. + const first = ev('JSON.stringify([R.served,R.citySrv,R.load])'); + ev("compute();"); + assert.equal(ev('JSON.stringify([R.served,R.citySrv,R.load])'), first); + assert.deepEqual(errors, []); +});