Island Wi-Fi: no new routing fields until you run a zone
emptyR() carried cityWisp, wisp and wispL in every game, so a game with no island zones no longer routed to the same R as main and tests/route-fuzz.test.js failed on its first move. compute() now adds them only while a zone runs (as satU), wispMoney() returns without them, and the agent's results docs say so. tests/wisp-zones.test.js checks that a game without zones, and one below level 2, has none of them. The mp-sim fixtures were written again with tests/lib/mp-sim-fixtures.js (only the three empty fields left them; a second run changes nothing).
This commit is contained in:
parent
66ac7d0af1
commit
5ca8270db9
8 changed files with 14 additions and 12 deletions
|
|
@ -132,9 +132,9 @@ const API_RESULTS_DOC={
|
||||||
cityDem:{type:'map',doc:'Eyeball + customer demand per city.'},
|
cityDem:{type:'map',doc:'Eyeball + customer demand per city.'},
|
||||||
citySrv:{type:'map',doc:'Traffic served per city.'},
|
citySrv:{type:'map',doc:'Traffic served per city.'},
|
||||||
cityEye:{type:'map',doc:'Eyeballs online per city.'},
|
cityEye:{type:'map',doc:'Eyeballs online per city.'},
|
||||||
cityWisp:{type:'map',doc:'Island Wi-Fi: the Gbps of island homes each city carries for its zones (already in cityDem; never in cityEye).'},
|
cityWisp:{type:'map',doc:'Island Wi-Fi: the Gbps of island homes each city carries for its zones (already in cityDem; never in cityEye). Only there while you run a zone.'},
|
||||||
wisp:{type:'map',doc:'Island Wi-Fi zones by zone id (catalog WISP): d, the homes\' Gbps wanted; car, what their backhaul carried; sf, how well they were served (0..1); k, how many may sign up over today\'s link (the take-up cap).'},
|
wisp:{type:'map',doc:'Island Wi-Fi zones by zone id (catalog WISP): d, the homes\' Gbps wanted; car, what their backhaul carried; sf, how well they were served (0..1); k, how many may sign up over today\'s link (the take-up cap). Only there while you run a zone.'},
|
||||||
wispL:{type:'array',doc:'Island Wi-Fi zones in this compute: z, its city c, zd wanted and car carried, in Gbps.'},
|
wispL:{type:'array',doc:'Island Wi-Fi zones in this compute: z, its city c, zd wanted and car carried, in Gbps. Only there while you run a zone.'},
|
||||||
latF:{type:'map',doc:'Fraction of each city\'s traffic that goes far (over a threshold latency).'},
|
latF:{type:'map',doc:'Fraction of each city\'s traffic that goes far (over a threshold latency).'},
|
||||||
latFar:{type:'map',doc:'The far exit each slow city sends traffic through.'},
|
latFar:{type:'map',doc:'The far exit each slow city sends traffic through.'},
|
||||||
satU:{type:'map',doc:'Of each city\'s served traffic, the Gbps that rode a rented satellite circuit (its users notice the orbit\'s latency on that share). Only there while you have a satellite circuit up.'},
|
satU:{type:'map',doc:'Of each city\'s served traffic, the Gbps that rode a rented satellite circuit (its users notice the orbit\'s latency on that share). Only there while you have a satellite circuit up.'},
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ const UI={sel:null,tab:'cust',left:'goals',speed:1,hover:null,drag:null,snap:nul
|
||||||
the player's (an agent drives): no pause, no speed buttons, no auto-pause, and the speed is HOOKS.speed()'s. */
|
the player's (an agent drives): no pause, no speed buttons, no auto-pause, and the speed is HOOKS.speed()'s. */
|
||||||
const HOOKS={};
|
const HOOKS={};
|
||||||
let uidN=1; const uid=()=>'i'+(Date.now()%1e7).toString(36)+(uidN++);
|
let uidN=1; const uid=()=>'i'+(Date.now()%1e7).toString(36)+(uidN++);
|
||||||
function emptyR(){return {nt:{},cone:{},reachNT:0,teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},cityWisp:{},wisp:{},wispL:[],latF:{},latFar:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{},ddos:[],haul:[],tgtF:{},bbF:{},fsUse:{},ddosHot:{}};}
|
function emptyR(){return {nt:{},cone:{},reachNT:0,teBlack:0,tNet:{},egT:{},netEg:{},l2lat:{},nodeLoad:{},nodeCap:{},div:{},l2:{},gfwLost:0,gfwCross:0,ef:{},egDesc:{},p95:{},peered:0,peerShare:0,load:{},useT:{},useIx:{},usePni:{},useCache:{},cityDem:{},citySrv:{},cityEye:{},latF:{},latFar:{},demTo:{},served:0,demand:0,reach:0,sessions:0,revMo:0,costMo:0,cost:{},rev:{},reachable:{},ddos:[],haul:[],tgtF:{},bbF:{},fsUse:{},ddosHot:{}};}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ function wispIn(viral){let L=null;const by={};
|
||||||
/* computeMoney(): what the islanders pay for what reached them, served as well as their city (sfOf), and the towers and
|
/* computeMoney(): what the islanders pay for what reached them, served as well as their city (sfOf), and the towers and
|
||||||
lit spurs' upkeep. R.wisp[z]: d wanted, car carried, sf served, k the take-up cap today. Circuit rent is the
|
lit spurs' upkeep. R.wisp[z]: d wanted, car carried, sf served, k the take-up cap today. Circuit rent is the
|
||||||
satellite row (satMoAll). */
|
satellite row (satMoAll). */
|
||||||
function wispMoney(R2,C,V){const L=R2.wispL;if(!L.length)return;let v=0,up=0;
|
function wispMoney(R2,C,V){const L=R2.wispL;if(!L)return;let v=0,up=0;
|
||||||
for(const x of L){const Z=wispZ(x.z),sf=x.zd>0?sfOf(R2,x.c)*x.car/x.zd:0;R2.wisp[x.z]={d:x.zd,car:x.car,sf,k:wispK(x.z,Z)};v+=x.zd*sf*wispRate(x.z);
|
for(const x of L){const Z=wispZ(x.z),sf=x.zd>0?sfOf(R2,x.c)*x.car/x.zd:0;R2.wisp[x.z]={d:x.zd,car:x.car,sf,k:wispK(x.z,Z)};v+=x.zd*sf*wispRate(x.z);
|
||||||
up+=wispUpMo(x.z)+(wispLit(Z)?wispSpurMo(x.z):0);}
|
up+=wispUpMo(x.z)+(wispLit(Z)?wispSpurMo(x.z):0);}
|
||||||
V.wisp=v;if(up>0)C.wisp=up;}
|
V.wisp=v;if(up>0)C.wisp=up;}
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,9 @@ function compute(){RW.gen++;
|
||||||
const bizBw={};for(const b of S.biz){const T=BIZ_T[b.type];if(!T.l2&&!T.fiber&&(!T.event||eventLive(b))){if(T.orbit){const g=PX&&PX.gs[b.id];if(g)bizBw[g]=(bizBw[g]||0)+PX.term[b.id];continue;}const v=bizBw[b.city];bizBw[b.city]=(v===undefined?0:v)+b.bw;}}
|
const bizBw={};for(const b of S.biz){const T=BIZ_T[b.type];if(!T.l2&&!T.fiber&&(!T.event||eventLive(b))){if(T.orbit){const g=PX&&PX.gs[b.id];if(g)bizBw[g]=(bizBw[g]||0)+PX.term[b.id];continue;}const v=bizBw[b.city];bizBw[b.city]=(v===undefined?0:v)+b.bw;}}
|
||||||
// Traffic shares by network index, and their sums, for each share table (and with Russia's throttle).
|
// Traffic shares by network index, and their sums, for each share table (and with Russia's throttle).
|
||||||
const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local');
|
const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local');
|
||||||
// Island Wi-Fi (46-wisp-zones.js): a zone's homes are its city's demand, as far as its backhaul reaches them.
|
// Island Wi-Fi (46-wisp-zones.js): a zone's homes are its city's demand, as far as its backhaul reaches them. Its
|
||||||
const WZI=wispOn()?wispIn(viral):null;R2.wispL=WZI?WZI.L:[];
|
// fields are only in R while you run a zone, so every other game routes to the same R as before.
|
||||||
|
const WZI=wispOn()?wispIn(viral):null;if(WZI){R2.wispL=WZI.L;R2.cityWisp={};R2.wisp={};}
|
||||||
(()=>{for(const c of Object.keys(S.pops)){
|
(()=>{for(const c of Object.keys(S.pops)){
|
||||||
const p=S.pops[c],ci=CIDX[c],cn=cnCity(c),SH=cn?NSH_CN:ruCity(c)?NSH_RU:CITY[c].kr&&S.krExit?NSH_KRX:NSH;const eye=(p.bb?p.bb.d:0)*viral*(cn&&ev.golden>day?1.4:1);const biz=bizBw[c]??0;
|
const p=S.pops[c],ci=CIDX[c],cn=cnCity(c),SH=cn?NSH_CN:ruCity(c)?NSH_RU:CITY[c].kr&&S.krExit?NSH_KRX:NSH;const eye=(p.bb?p.bb.d:0)*viral*(cn&&ev.golden>day?1.4:1);const biz=bizBw[c]??0;
|
||||||
const wz=WZI?WZI.by[c]||0:0;if(wz)R2.cityWisp[c]=wz;const d0=eye+wz+biz;
|
const wz=WZI?WZI.by[c]||0:0;if(wz)R2.cityWisp[c]=wz;const d0=eye+wz+biz;
|
||||||
|
|
|
||||||
2
tests/fixtures/mp-sim/snap.json
vendored
2
tests/fixtures/mp-sim/snap.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/mp-sim/upd-act.json
vendored
2
tests/fixtures/mp-sim/upd-act.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/mp-sim/upd-day.json
vendored
2
tests/fixtures/mp-sim/upd-day.json
vendored
File diff suppressed because one or more lines are too long
|
|
@ -234,10 +234,11 @@ test('saves: zones and circuits survive a reload, broken ones are repaired, and
|
||||||
assert.equal(ev(`${Z}.d`), d0);
|
assert.equal(ev(`${Z}.d`), d0);
|
||||||
assert.ok(Number.isFinite(ev(`${Z}.d`)));
|
assert.ok(Number.isFinite(ev(`${Z}.d`)));
|
||||||
assert.equal(ev("'wisp' in R.rev||'wisp' in R.cost"), false);
|
assert.equal(ev("'wisp' in R.rev||'wisp' in R.cost"), false);
|
||||||
assert.deepEqual(J(ev, 'R.cityWisp'), {});
|
assert.equal(ev("['cityWisp','wisp','wispL'].some(k=>k in R)"), false, 'and nothing in the routing results');
|
||||||
// An old save has no zones and runs as it did.
|
// An old save has no zones and runs as it did.
|
||||||
ev(`S=migrate(JSON.parse(${JSON.stringify(SAVE)}));compute()`);
|
ev(`S=migrate(JSON.parse(${JSON.stringify(SAVE)}));compute()`);
|
||||||
assert.equal(ev("Object.values(S.pops).some(p=>'wisp' in p)"), false);
|
assert.equal(ev("Object.values(S.pops).some(p=>'wisp' in p)"), false);
|
||||||
|
assert.equal(ev("['cityWisp','wisp','wispL'].some(k=>k in R)"), false, 'no zone, no new fields: R is what main routes (tests/route-fuzz.test.js)');
|
||||||
assert.equal(ev("'wisp' in R.cost||'wisp' in R.rev"), false);
|
assert.equal(ev("'wisp' in R.cost||'wisp' in R.rev"), false);
|
||||||
assert.ok(ev('R.served') > 0);
|
assert.ok(ev('R.served') > 0);
|
||||||
assert.deepEqual(errors, []);
|
assert.deepEqual(errors, []);
|
||||||
|
|
@ -269,7 +270,7 @@ test('gates: never in puzzles, the Architect or scenarios, and not below level 2
|
||||||
assert.equal(ev('wispOn()'), false);
|
assert.equal(ev('wispOn()'), false);
|
||||||
assert.doesNotMatch(ev("document.getElementById('panel').textContent"), /Island Wi-Fi/);
|
assert.doesNotMatch(ev("document.getElementById('panel').textContent"), /Island Wi-Fi/);
|
||||||
assert.equal(ev("wispFact('suv')+wispHtml('suv')"), '');
|
assert.equal(ev("wispFact('suv')+wispHtml('suv')"), '');
|
||||||
assert.equal(ev('R.wispL.length'), 0, 'its homes are no demand');
|
assert.equal(ev("'wispL' in R||'cityWisp' in R"), false, 'its homes are no demand');
|
||||||
assert.match(ev("wispSatWhy('vanualevu','kac1',2)"), /level 2/);
|
assert.match(ev("wispSatWhy('vanualevu','kac1',2)"), /level 2/);
|
||||||
ev("ACT.startScn({id:SCN[0].id})");
|
ev("ACT.startScn({id:SCN[0].id})");
|
||||||
assert.equal(ev('!!S.scn&&wispOn()'), false, 'scenarios');
|
assert.equal(ev('!!S.scn&&wispOn()'), false, 'scenarios');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue