Merge upstream main and resolve ocean-routing conflicts
This commit is contained in:
commit
a20f970fc9
8 changed files with 491 additions and 34 deletions
|
|
@ -1275,3 +1275,23 @@ test('#51 a dark fiber shows what is rented out, and spare capacity can be liste
|
|||
assert.equal(ev('S.offers[0].broker'), true);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#126 you can zoom in far enough, and pick a short link between two close cities', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({city:'sao'});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;for(const c of ['poa','fln'])ACT.buildPop({city:c});UI.pending=null;UI.via=null;UI.lmode='wave';UI.route='main';openLinkModal('poa','fln');ACT.buildLink({tier:1});closeModal()");
|
||||
assert.ok(ev('ZMAX') >= 16);
|
||||
const id = ev("S.links.find(l=>l.a==='poa'||l.b==='poa').id");
|
||||
// the middle of the drawn link, on screen, fully zoomed in on it
|
||||
const at = (z) => JSON.parse(ev(`(()=>{const l=S.links.find(x=>x.id==='${id}'),g=linkGeom(l,pairIdx().get(edgeKey(l))),p=g.pts[Math.floor(g.pts.length/2)];
|
||||
cam.x=p[0];cam.y=p[1];cam.z=1;zoomAt(CW/2,CH/2,${z});const [sx,sy]=toS(p[0],p[1],visibleKs()[0]);const c=toS(CITY.poa.x,CITY.poa.y,visibleKs()[0]);return JSON.stringify({sx,sy,cx:c[0],cy:c[1],z:cam.z});})()`));
|
||||
const m = at(100);
|
||||
assert.equal(m.z, ev('ZMAX'), 'zoom stops at the new maximum');
|
||||
assert.equal(ev(`pickCity(${m.sx},${m.sy})`), null, 'the middle of the link is not grabbed by a city');
|
||||
assert.equal(ev(`hitLink(${m.sx},${m.sy})`), id);
|
||||
assert.equal(ev(`pickCity(${m.cx},${m.cy-4}).id`), 'poa', 'tapping the city icon still picks the city');
|
||||
// even at the old maximum, a click on the link now picks the link where it is not under a city icon
|
||||
const o = at(6);
|
||||
assert.ok(Math.abs(o.z - 6) < 1e-9);
|
||||
assert.equal(ev(`pickCity(${o.sx},${o.sy})`), null);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -132,7 +132,8 @@ test('half speed and deeper zoom', () => {
|
|||
ev("ACT.speed({v:7})");
|
||||
assert.equal(ev("UI.speed"), 0.5, 'bogus speeds are ignored');
|
||||
ev("cam.z=1;for(let i=0;i<40;i++)zoomAt(100,100,1.2)");
|
||||
assert.equal(ev("cam.z"), 6);
|
||||
assert.equal(ev("cam.z"), ev("ZMAX"), 'zooming in stops at the maximum');
|
||||
assert.ok(ev("ZMAX") >= 16, 'deep enough for dense regions (#126)');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
@ -428,3 +429,42 @@ test('#114 Only Spätzle-IX can be won by peering alone', () => {
|
|||
assert.equal(ev("scnRule('local')"), false);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('RouteScript: help, ready-made scripts and the AI button', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'})");
|
||||
ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buyTransit({city:'fra',net:'lvl',tier:1});ACT.buyTE();compute()");
|
||||
// every ready-made script parses on a real network and is listed in the help
|
||||
for (const id of JSON.parse(ev('JSON.stringify(TE_RECIPES.map(r=>r.id))')))
|
||||
assert.deepEqual(JSON.parse(ev(`JSON.stringify(teParse(TE_RECIPES.find(r=>r.id==='${id}').src().join('\\n')).errors)`)), [], id);
|
||||
ev("ACT.teEdit();document.getElementById('teSrc').value='spill at 90%';ACT.teHelp()");
|
||||
const help = ev("document.getElementById('modalCard').textContent");
|
||||
assert.match(help, /How RouteScript works/);
|
||||
assert.match(help, /Penny Pincher/);
|
||||
assert.equal(ev("document.querySelectorAll('[data-act=\"teRecipe\"]').length"), ev('TE_RECIPES.length'));
|
||||
ev("ACT.teBack()");
|
||||
assert.equal(ev("document.getElementById('teSrc').value"), 'spill at 90%', 'the help keeps your draft');
|
||||
ev("ACT.teRecipe({id:'pinch'})");
|
||||
assert.match(ev("document.getElementById('teSrc').value"), /prefer transit cogentle/);
|
||||
// the AI writes a script that parses and does not lose traffic...
|
||||
const served = ev('R.served');
|
||||
ev('Math.random=()=>0.5;ACT.teSlop()');
|
||||
const good = ev("document.getElementById('teSrc').value");
|
||||
assert.match(good, /Written by/);
|
||||
assert.equal(ev(`teParse(${JSON.stringify(good)}).errors.length`), 0);
|
||||
assert.ok(ev(`teTrial(${JSON.stringify(good)}).after.served`) >= served * 0.99);
|
||||
assert.equal(ev('R.served'), served, 'thinking about it changes nothing');
|
||||
ev('ACT.teDeploy()');
|
||||
assert.equal(ev('S.te.script'), good);
|
||||
// ...except sometimes, and it is just as sure of itself
|
||||
ev('Math.random=()=>0.001;ACT.teEdit();ACT.teSlop()');
|
||||
const bad = ev("document.getElementById('teSrc').value");
|
||||
assert.match(bad, /cap transit cogentle at 0 gbps/);
|
||||
assert.match(bad, /Confidence: 100%/);
|
||||
assert.ok(ev(`teTrial(${JSON.stringify(bad)}).after.served`) < served * 0.5, 'it takes the network down');
|
||||
ev('ACT.teDeploy()');
|
||||
assert.match(ev("document.getElementById('toasts').textContent"), /The AI apologises/);
|
||||
ev('ACT.teEdit();ACT.teSlop();ACT.teHelp();ACT.teBack()');
|
||||
ev("UI.dtab='overview';renderAll()");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -577,7 +577,8 @@ test('a Tier 1 reaches every Latin American and African network through the carr
|
|||
test('Africa: more countries, cables along both coasts, border costs and Cape to Cairo', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
const af = JSON.parse(ev("JSON.stringify(CITIES.filter(c=>c.reg==='AF').map(c=>c.id))"));
|
||||
// the mainland: islands like St Helena have no exchange (#120)
|
||||
const af = JSON.parse(ev("JSON.stringify(CITIES.filter(c=>c.reg==='AF'&&c.land==='af').map(c=>c.id))"));
|
||||
assert.ok(af.length >= 26);
|
||||
for (const c of af) {
|
||||
assert.ok(ev(`!!CITY.${c}.cc&&!!CITY.${c}.ix`), `${c} has a country and an IX`);
|
||||
|
|
@ -641,6 +642,63 @@ test('Pacific islands: real landings, real exchanges only, and island hops carry
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Atlantic islands and Halifax: real landings, real exchanges only, and island hops carry more per wave (#120)', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
const isl = ['bda', 'pdl', 'tci', 'rai', 'jam'];
|
||||
for (const c of isl.concat('hfx')) {
|
||||
assert.ok(ev(`CABLE_PAIRS.some(p=>p.a==='${c}'||p.b==='${c}')`), `${c} has a cable`);
|
||||
assert.ok(ev(`NETS.some(n=>n.price&&n.pops.includes('${c}'))`), `${c} has a transit seller`);
|
||||
}
|
||||
for (const c of isl) assert.ok(ev(`isSub('${c}','lis')&&isSub('${c}','mia')&&isSub('${c}','dkr')`), `${c} is an island`);
|
||||
assert.equal(ev("isSub('hfx','mtl')"), false, 'Halifax is on the mainland');
|
||||
// exchanges only where one runs today: CVIXP in Praia and HFXIX in Halifax
|
||||
assert.deepEqual(isl.concat('hfx').filter(c => ev(`!!CITY['${c}'].ix`)), ['rai', 'hfx']);
|
||||
assert.equal(ev(`NETS.filter(n=>Array.isArray(n.ix)&&n.ix.some(c=>CITY[c]&&!CITY[c].ix&&${JSON.stringify(isl)}.includes(c))).length`), 0);
|
||||
// the real landings named in the issue
|
||||
const lands = (cid, a, b) => ev(`CABLE_PAIRS.some(p=>p.cid==='${cid}'&&[p.a,p.b].sort().join()==='${[a, b].sort().join()}')`);
|
||||
assert.ok(lands('hibx', 'hfx', 'lon') && lands('nuvem', 'bda', 'lis') && lands('sol', 'bda', 'pdl') && lands('ella', 'for', 'rai') && lands('equi', 'lag', 'jam'));
|
||||
assert.ok(lands('atl2', 'rai', 'dkr') && lands('atl2', 'dkr', 'tci') && lands('atl2', 'bue', 'for'));
|
||||
// old pairs stay where they were, so saved links keep their cable
|
||||
assert.equal(ev("CAB.hibx.pairs[0].slice(0,2).join()"), 'nyc,lon');
|
||||
assert.equal(ev("CAB.nuvem.pairs[0].slice(0,2).join()"), 'lis,atn');
|
||||
// every island network still reaches a Tier 1
|
||||
assert.equal(ev(`NETS.filter(n=>n.type!=='t1'&&n.pops.some(c=>${JSON.stringify(isl)}.includes(c))&&!(n.up||[]).some(u=>NET[u].type==='t1')&&!n.pops.some(c=>!${JSON.stringify(isl)}.includes(c))).map(n=>n.id).join()`), '');
|
||||
const hop = (path) => ev(`Math.min(...${JSON.stringify(path)}.slice(1).map((c,i)=>Math.max(...cablesFor(${JSON.stringify(path)}[i],c).map(p=>subCarrier(p.km)))))`);
|
||||
const direct = (a, b) => ev(`Math.max(...cablesFor('${a}','${b}').map(p=>subCarrier(p.km)))`);
|
||||
assert.equal(direct('mia', 'mad'), 1200);
|
||||
assert.equal(hop(['mia', 'bda', 'pdl', 'mad']), 1600, 'Florida to Spain via Bermuda and the Azores');
|
||||
assert.equal(hop(['mia', 'pdl', 'lis']), 1600, 'Florida to Lisbon via the Azores');
|
||||
assert.equal(direct('atn', 'lis'), 1200);
|
||||
assert.equal(hop(['atn', 'bda', 'lis']), 1600);
|
||||
assert.equal(direct('lis', 'lag'), 1200);
|
||||
assert.equal(hop(['lis', 'tci', 'lag']), 1600, 'Lisbon to Lagos via the Canaries');
|
||||
assert.equal(direct('for', 'mad'), 1200);
|
||||
assert.equal(hop(['for', 'rai', 'lis']), 1600, 'Brazil to Europe via Cape Verde');
|
||||
assert.equal(hop(['nyc', 'hfx']), 3200);
|
||||
// the Bermuda Triangle has its own cuts
|
||||
ev("ACT.buildPop({city:'mia'});ACT.buildPop({city:'bda'});S.pops.mia.rgen=3;S.pops.bda.rgen=3;UI.via='sol';UI.route='same';openLinkModal('mia','bda');ACT.buildLink({tier:4});closeModal()");
|
||||
const l = ev("JSON.stringify(S.links.find(l=>l.a==='bda'||l.b==='bda'))");
|
||||
assert.ok(l && JSON.parse(l).sub, 'a subsea wave to Bermuda');
|
||||
// a town of 4,500 starts broadband below its ceiling, not above it
|
||||
ev("ACT.buildPop({city:'jam'});ACT.launchBB({city:'jam'})");
|
||||
assert.ok(ev("S.pops.jam.bb.d>0&&S.pops.jam.bb.d<=eyeP('jam')"));
|
||||
// the scenario starts in the Azores with 1.6T gear
|
||||
ev("ACT.startScn({id:'atl',sure:1})");
|
||||
assert.equal(ev('S.scn.id'), 'atl');
|
||||
assert.ok(ev('!!S.pops.pdl') && ev('S.lvl') >= 4);
|
||||
assert.equal(ev('scnProg().items.length'), 3);
|
||||
assert.equal(ev("fastPath('mia','mad',1600)"), false);
|
||||
ev("S.cash=1e9;for(const c of ['mia','bda','mad','lis','tci','lag']){ACT.buildPop({city:c});S.pops[c].rgen=3;}S.pops.pdl.rgen=3;");
|
||||
const wave = (a, b, via) => ev(`UI.via='${via}';UI.route='same';openLinkModal('${a}','${b}');ACT.buildLink({tier:4});closeModal();S.links.length`);
|
||||
wave('mia', 'bda', 'sol'); wave('bda', 'pdl', 'sol'); wave('pdl', 'mad', 'sol'); wave('lis', 'tci', 'ace'); wave('tci', 'lag', 'twoaf');
|
||||
ev('compute()');
|
||||
assert.equal(ev("fastPath('mia','mad',1600)"), true);
|
||||
assert.equal(ev("fastPath('lis','lag',1600)"), true);
|
||||
ev('cam.z=0.5;draw(0);cam.z=6;cam.x=CITY.bda.x;cam.y=CITY.bda.y;draw(0)');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('subsea cable designs trade construction cost and time for previewed latency', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue