Satellite teleports: GEO and MEO circuits for islands and remote towns (#83)
The early and mid-game satellite option, before Pie in the Sky. Build a teleport at a POP that a satellite sees, then rent capacity from it to a remote POP: GEO (Intelsplat, Kacophony) needs no capex but costs a lot a month per Gbps, 1-10 Gbps at about 600 ms; MEO (O3bservant) needs tracking antennas at the teleport and gives multi-Gbps at about 130 ms where both ends are under its ring, at least 5 degrees up. Coverage follows each bird's footprint by ocean region. Latency feeds the latency model: users who ride a satellite notice, in proportion to the share. A circuit beside a cable goes on standby, whichever came first, and carries only what the cable cannot: the classic single-cable island backup. Satellites are not subsea links for covenants, scenario goals or subsidies (Pitcairn's UK grant needs a cable). Express fiber and the build standard leave satellite circuits alone.
This commit is contained in:
parent
8e1f2d66a5
commit
e1ae8e0164
46 changed files with 1176 additions and 55 deletions
|
|
@ -32,7 +32,7 @@ const EXCEPTIONS = {
|
|||
W3: {
|
||||
ivc: 'Invercargill waits for its AI campus; nobody sells transit there yet',
|
||||
jub: 'Nobody sells transit in Juba: MTN and Zain haul it in from abroad',
|
||||
pcn: 'Pitcairn: no cable, no network, land your own (#124), or reach it with a pie dish (backhaul through orbit)',
|
||||
pcn: 'Pitcairn: no cable, no network, land your own (#124), reach it with a pie dish (backhaul through orbit), or rent a satellite circuit from a teleport (#83)',
|
||||
prr: 'Prince Rupert is a remote town with no carrier in it',
|
||||
smr: 'San Marino buys its transit from Italian carriers in Bologna and Rimini; nobody sells it in the town',
|
||||
sre: "Sucre has no exchange or carrier facility: Bolivia's transit is bought in La Paz",
|
||||
|
|
@ -118,6 +118,8 @@ const REAL_NAMES = [
|
|||
'ACMA', 'ASEAN Explorer', 'ASEAN Protector', 'ASEAN Restorer', 'Cable Innovator', 'Cable Retriever', 'Global Marine', 'Léon Thévenin', 'MECMA', 'Orange Marine', 'Pierre de Fermat', 'René Descartes', 'SEAIOCMA', 'Sophie Germain', 'Sovereign', 'Wave Sentinel', 'Yokohama Zone',
|
||||
// rockets and satellite networks (Pie in the Sky)
|
||||
'Blue Origin', 'Falcon 9', 'Falcon Heavy', 'Iridium', 'Kuiper', 'OneWeb', 'Project Kuiper', 'SpaceX', 'Starship', 'Starlink',
|
||||
// satellite operators and their birds (teleports, #83)
|
||||
'Galaxy 19', 'Intelsat', 'Intelsat 18', 'Intelsat 20', 'Intelsat 37e', 'Intelsat Galaxy 19', 'Kacific', 'Kacific-1', 'O3b', 'O3b mPOWER', 'SES',
|
||||
// vendors
|
||||
'Arista', 'Brocade', 'Ciena', 'Cisco', 'Extreme Networks', 'Huawei', 'Infinera', 'Juniper', 'MikroTik', 'Nokia',
|
||||
];
|
||||
|
|
@ -182,7 +184,7 @@ test('N2: names are puns: no network, cable, exchange, data center, router, opti
|
|||
const norm = (s) => String(s).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[’`]/g, "'").replace(/\s+/g, ' ').trim();
|
||||
const real = new Set(REAL_NAMES.map(norm));
|
||||
const names = J(`[...NETS.map(n=>['network',n.name]),...CABLES.map(c=>['cable',c.name]),...XIX.map(x=>['exchange',x.name]),
|
||||
...CITIES.flatMap(c=>[['exchange',c.ix],['data center',c.dc],['data center',c.dc2]]),...RG.map(r=>['router',r.n]),...Object.values(OPT).map(o=>['optic',o.n]),...Object.values(SEAT_ROUTES).flat().map(r=>['cable',r[2]]),...SHIPS.map(x=>['cable ship',x.n]),...LAY_SHIPS.map(n=>['cable ship',n]),...Object.values(SHIP_CLUBS).map(c=>['maintenance club',c.n]),...PIE_NAMES.map(n=>['rocket company',tr(n)]),...Object.values(ROCKETS).map(r=>['rocket',tr(r.n)]),...Object.values(CRUSTS).map(c=>['constellation',tr(c.n)])].filter(x=>x[1])`);
|
||||
...CITIES.flatMap(c=>[['exchange',c.ix],['data center',c.dc],['data center',c.dc2]]),...RG.map(r=>['router',r.n]),...Object.values(OPT).map(o=>['optic',o.n]),...Object.values(SEAT_ROUTES).flat().map(r=>['cable',r[2]]),...SHIPS.map(x=>['cable ship',x.n]),...LAY_SHIPS.map(n=>['cable ship',n]),...Object.values(SHIP_CLUBS).map(c=>['maintenance club',c.n]),...PIE_NAMES.map(n=>['rocket company',tr(n)]),...Object.values(ROCKETS).map(r=>['rocket',tr(r.n)]),...Object.values(CRUSTS).map(c=>['constellation',tr(c.n)]),...Object.values(SAT_PROV).map(p=>['satellite operator',p.n]),...Object.values(SATS).map(b=>['satellite',b.n])].filter(x=>x[1])`);
|
||||
fail('N2', names.filter(([, n]) => real.has(norm(n))).map(([k, n]) => `${k} “${n}” is a real name`), 'find a pun');
|
||||
fail('N2', names.filter(([, n]) => /-ish\b/i.test(n)).map(([k, n]) => `${k} “${n}”`), 'no lazy -ish names: find a real pun, or keep the plain word');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@ test('a dry run prices every command that has a price, and changes nothing', ()
|
|||
opsHire: { id: ev('Object.keys(INTERNS)[0]') }, opsNewPop: { city: 'nyc' }, pniAll: { net: 'cog', tier: 1 }, seatBuy: { n: 2 }, layShip: { id: df }, seaRush: { id: df },
|
||||
utilityKit: { city: 'fra' }, utilityCaches: { city: 'fra' }, teDeploy: { script: 'spill at 85%' }, upLinkX: {},
|
||||
pieRd: { k: 'reuse' }, pieAnt: { id: 'none' }, ip4Buy: { len: 24 }, ip4Lease: { len: 22 },
|
||||
teleBuild: { city: 'fra' }, teleTrk: { city: 'fra' }, buySat: { a: 'fra', b: 'rek', bird: 'is37', g: 1 }, satSize: { id: wave, g: 2 },
|
||||
};
|
||||
const missing = quoted.filter((n) => !sample[n] && T('schema', { section: 'commands' })[n].args.some((a) => a.required));
|
||||
assert.deepEqual(missing, [], 'every priced command with arguments has a sample here');
|
||||
|
|
|
|||
445
tests/satellites.test.js
Normal file
445
tests/satellites.test.js
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
// Teleports and rented satellite capacity (#83): a teleport at a POP rents GEO or MEO circuits to small islands and
|
||||
// remote towns its birds see. A circuit is a link (kind 'sat'): its radio path is its km, so routers take a cable
|
||||
// whenever there is one; its orbit's latency is what users notice; next to the island's only cable it waits on standby.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { load } = require('./harness');
|
||||
const { createSession, TOOLS } = require('../scripts/lib/mcp-game');
|
||||
|
||||
const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
|
||||
// Level 3, Change Freeze (nothing breaks, lead times quick), plenty of cash.
|
||||
const BASE = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=3;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');";
|
||||
// Sydney (transit, broadband) and Nuku'alofa (broadband, no transit of its own).
|
||||
const ISLE = "ACT.buildPop({city:'syd'});ACT.launchBB({city:'syd'});ACT.buyTransit({city:'syd',net:'cog',tier:1});ACT.buildPop({city:'tbu'});ACT.launchBB({city:'tbu'});";
|
||||
function game(t, setup = '') {
|
||||
const h = load();
|
||||
t.after(() => h.dom.window.close());
|
||||
h.ev(BASE + setup);
|
||||
return h;
|
||||
}
|
||||
const J = (ev, s) => JSON.parse(ev(`JSON.stringify(${s})`));
|
||||
const sat = "S.links.find(l=>l.kind==='sat')";
|
||||
// Past the day a circuit is commissioned.
|
||||
const ready = `S.day=${sat}.ready;compute()`;
|
||||
|
||||
test('the footprint: which birds see where, who a satellite serves, and how long the trip is', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
const sees = J(ev, "[['is18','syd'],['is18','tbu'],['is18','mia'],['is37','mia'],['is37','sju'],['kac1','tbu'],['kac1','hnl'],['is20','mru'],['o3b','tbu'],['o3b','yfb']].map(([b,c])=>CITY[c]?satSees(b,c):null)");
|
||||
assert.deepEqual(sees, [true, true, false, true, true, true, false, true, true, false], 'the Pacific bird does not see Miami, Kacophony’s spot beams miss Hawaii, the MEO ring misses Iqaluit');
|
||||
// Both ends of a MEO circuit must see one satellite at a time.
|
||||
assert.ok(ev("kmBetween('sju','hnl')") > ev('SAT_ORB.meo.km') && !ev("satPairOk('o3b','sju','hnl')"), 'San Juan to Honolulu is too far apart for one MEO satellite');
|
||||
assert.equal(ev("satPairOk('is18','syd','tbu')"), true);
|
||||
assert.deepEqual(J(ev, "['tbu','pcn','asp','sju','lon','syd','mel'].map(satRemote)"), [true, true, true, true, false, false, false], 'small islands and remote towns, never a big city');
|
||||
const geo = ev("satRtt('is18','syd','tbu')"), meo = ev("satRtt('o3b','syd','tbu')");
|
||||
assert.ok(geo > 520 && geo < 650, 'GEO: about 600 ms round trip, got ' + geo);
|
||||
assert.ok(meo > 110 && meo < 160, 'MEO: about 130 ms round trip, got ' + meo);
|
||||
assert.ok(ev("satKm('is18','syd','tbu')") > 2 * 35786, 'the radio path goes up to the GEO belt and back down');
|
||||
// A MEO satellite halfway between Winnipeg and Vaduz is below both horizons: within 7,500 km and 50 degrees is not enough.
|
||||
assert.ok(ev("kmBetween('ywg','vdz')") <= ev('SAT_ORB.meo.km') && ev("satSees('o3b','ywg')&&satSees('o3b','vdz')"));
|
||||
assert.equal(ev("satPairOk('o3b','ywg','vdz')"), false, 'Winnipeg to Vaduz: no MEO satellite sees both');
|
||||
assert.ok(ev("satElev(satArc(0,satLon('o3b','ywg','vdz'),CITY.ywg.lat,CITY.ywg.lon),SAT_ORB.meo.h)") < ev('SAT_ORB.meo.el'));
|
||||
assert.ok(ev("satPairOk('o3b','syd','tbu')") && ev("satElev(0,SAT_ORB.meo.h)") === 90, 'straight overhead is 90 degrees');
|
||||
// Every MEO pair on sale clears the horizon at both ends, so its radio path never runs through the Earth.
|
||||
const low = J(ev, "(()=>{const O=SAT_ORB.meo,out=[];for(const A of CITIES)for(const B of CITIES){if(A.id>=B.id||!satRemote(B.id)||!satPairOk('o3b',A.id,B.id))continue;const lon=satLon('o3b',A.id,B.id);for(const C of [A,B])if(satElev(satArc(0,lon,C.lat,C.lon),O.h)<O.el)out.push(A.id+'-'+B.id);}return out;})()");
|
||||
assert.deepEqual(low, []);
|
||||
// A bird over the Americas: inland North America and Mexico see a GEO satellite too.
|
||||
assert.deepEqual(J(ev, "['chi','den','dal','mex','yeg','yfb'].map(c=>Object.keys(SATS).some(id=>SATS[id].orb==='geo'&&satSees(id,c)))"), [true, true, true, true, true, true]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a teleport and a GEO circuit: level, price, lead time, capacity, latency, the bill, resizing and cancelling', (t) => {
|
||||
const { ev, errors } = game(t, ISLE);
|
||||
ev("S.lvl=1;ACT.teleBuild({city:'syd'})");
|
||||
assert.equal(ev("teleOf('syd')"), 0, 'teleports unlock at level 2');
|
||||
ev('S.lvl=3');
|
||||
let c0 = ev('S.cash');
|
||||
ev("ACT.teleBuild({city:'syd'})");
|
||||
assert.equal(ev("S.pops.syd.tele"), 1);
|
||||
assert.equal(c0 - ev('S.cash'), ev('TPORT_COST'));
|
||||
c0 = ev('S.cash');
|
||||
ev("ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:2})");
|
||||
const l = J(ev, sat);
|
||||
assert.equal(l.bird, 'kac1');
|
||||
assert.equal(l.g, 2);
|
||||
assert.equal(l.sub, true, 'never a land route');
|
||||
assert.equal(!!l.standby, false, 'alone between the two cities, it carries');
|
||||
assert.equal(c0 - ev('S.cash'), ev("satMo('kac1',2)"), 'no build: the first month up front');
|
||||
assert.equal(l.ready, ev('S.day+leadDays(SAT_ORB.geo.days)'));
|
||||
ev('compute()');
|
||||
assert.equal(ev(`linkDown(${sat})`), true, 'down while it is pointed and tested');
|
||||
assert.equal(ev(`R.load[${sat}.id]||0`), 0);
|
||||
ev(ready);
|
||||
assert.equal(ev(`capOf(${sat})`), 2);
|
||||
const ld = ev(`R.load[${sat}.id]`);
|
||||
assert.ok(ld > 1 && ld <= 2 + 1e-9, 'the island’s traffic fills the circuit: ' + ld);
|
||||
const ms = ev(`linkLat(${sat})`);
|
||||
assert.ok(ms > 255 && ms < 310, 'one way over GEO: ' + ms);
|
||||
assert.equal(ev('R.latF.tbu'), 0.5, 'broadband over GEO counts as half the service');
|
||||
assert.ok(ev("sfOf(R,'tbu')") <= 0.5);
|
||||
ev("UI.sel={type:'city',id:'tbu'};UI.tab='cust';renderAll()");
|
||||
assert.match(ev("document.querySelector('#panel').textContent"), /users ride a satellite/, 'the island’s panel says why');
|
||||
assert.equal(ev('R.cost.sat'), ev(`TPORT_MO+${sat}.mo`), 'the teleport and the rent have a row of their own');
|
||||
assert.equal(ev("S.links.filter(l=>l.kind!=='sat').reduce((a,l)=>a+l.mo,0)"), ev('R.cost.links'), 'and are not in waves and fiber');
|
||||
// Bigger pays its month up front; smaller just costs less from now on.
|
||||
c0 = ev('S.cash');
|
||||
ev(`ACT.satSize({id:${sat}.id,g:5})`);
|
||||
assert.equal(c0 - ev('S.cash'), ev("satMo('kac1',5)"));
|
||||
assert.equal(ev(`${sat}.mo`), ev("satMo('kac1',5)"));
|
||||
c0 = ev('S.cash');
|
||||
ev(`ACT.satSize({id:${sat}.id,g:1})`);
|
||||
assert.equal(ev('S.cash'), c0);
|
||||
assert.equal(ev(`${sat}.g`), 1);
|
||||
ev(`ACT.satSize({id:${sat}.id,g:3})`);
|
||||
assert.equal(ev(`${sat}.g`), 1, 'only the sizes on sale');
|
||||
// Satellite capacity costs several times a subsea wave per Gbps, so a cable wins once there is one; the cheapest
|
||||
// backup still fits inside what a small island's homes pay.
|
||||
const wave = ev("waveMo(kmBetween('suv','tbu'),true,1)/LT[1].g");
|
||||
for (const id of ['is18', 'kac1']) assert.ok(ev(`satMo('${id}',10)/10`) > 3 * wave, id + ' per Gbps against a wave');
|
||||
assert.ok(ev("satMo('o3b',20)/20") > 3 * wave, 'MEO per Gbps against a wave');
|
||||
assert.ok(ev("satMo('kac1',1)") <= ev("CITY.suv.P*EYE_RATE"), 'a 1G backup costs less than Suva’s homes pay');
|
||||
// Cancelling asks twice.
|
||||
ev(`ACT.rmLink({id:${sat}.id})`);
|
||||
assert.ok(ev(`!!${sat}`), 'armed, not gone');
|
||||
ev(`ACT.rmLink({id:${sat}.id})`);
|
||||
assert.equal(ev(`!!${sat}`), false);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('MEO needs tracking antennas and a higher level, and users barely notice it', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
|
||||
ev("ACT.buySat({a:'syd',b:'tbu',bird:'o3b',g:5})");
|
||||
assert.equal(ev(`!!${sat}`), false, 'no tracking antennas yet');
|
||||
assert.match(ev("satWhy('syd','tbu','o3b',5)"), /tracking antennas/);
|
||||
ev("S.lvl=2;ACT.teleTrk({city:'syd'})");
|
||||
assert.equal(ev("teleOf('syd')"), 1, 'MEO comes at level 3');
|
||||
ev('S.lvl=3');
|
||||
const c0 = ev('S.cash');
|
||||
ev("ACT.teleTrk({city:'syd'})");
|
||||
assert.equal(ev("teleOf('syd')"), 2);
|
||||
assert.equal(c0 - ev('S.cash'), ev('TRK_COST'));
|
||||
ev("ACT.buySat({a:'syd',b:'tbu',bird:'o3b',g:5})");
|
||||
assert.equal(ev(`${sat}.bird`), 'o3b');
|
||||
assert.equal(ev(`${sat}.ready`), ev('S.day+leadDays(SAT_ORB.meo.days)'));
|
||||
ev(ready);
|
||||
const ms = ev(`linkLat(${sat})`);
|
||||
assert.ok(ms > 55 && ms < 80, 'one way over MEO: ' + ms);
|
||||
assert.ok(Math.abs(ev('R.latF.tbu') - 0.92) < 1e-9, 'MEO costs users 8% of the service, GEO half');
|
||||
assert.ok(ev("sfOf(R,'tbu')") >= 0.9, 'enough for broadband to keep growing');
|
||||
assert.equal(ev('R.cost.sat'), ev(`TPORT_MO+TRK_MO+${sat}.mo`));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('orders outside a footprint, to a big city or without a teleport are refused, in words', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});ACT.buildPop({city:'mel'});ACT.buildPop({city:'sju'});");
|
||||
const tries = [
|
||||
["{a:'syd',b:'tbu',bird:'is37',g:1}", /does not see both/],
|
||||
["{a:'syd',b:'sju',bird:'is18',g:1}", /does not see both/],
|
||||
["{a:'syd',b:'mel',bird:'is18',g:1}", /too big a market/],
|
||||
["{a:'tbu',b:'syd',bird:'is18',g:1}", /no teleport in Nuku/],
|
||||
["{a:'syd',b:'tbu',bird:'is18',g:3}", /No such satellite circuit/],
|
||||
["{a:'syd',b:'tbu',bird:'nope',g:1}", /No such satellite circuit/],
|
||||
];
|
||||
const c0 = ev('S.cash');
|
||||
for (const [a, why] of tries) {
|
||||
const o = JSON.parse(ev(`JSON.stringify(${a})`));
|
||||
assert.match(ev(`satWhy(${JSON.stringify(o.a)},${JSON.stringify(o.b)},${JSON.stringify(o.bird)},${o.g})`), why, a);
|
||||
ev(`ACT.buySat(${a})`);
|
||||
}
|
||||
assert.equal(ev("S.links.filter(l=>l.kind==='sat').length"), 0);
|
||||
assert.equal(ev('S.cash'), c0, 'nothing charged');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('beside the island’s only cable, a satellite waits on standby and takes over when the cable is cut', (t) => {
|
||||
const { ev, errors } = game(t, "ACT.buildPop({city:'suv'});ACT.launchBB({city:'suv'});ACT.buyTransit({city:'suv',net:" +
|
||||
"NETS.find(n=>sellsAt(n,'suv')).id,tier:1});ACT.buildPop({city:'tbu'});ACT.launchBB({city:'tbu'});UI.pending={a:'suv',b:'tbu'};ACT.buildLink({tier:1});ACT.teleBuild({city:'suv'});");
|
||||
const wave = "S.links.find(l=>l.kind==='wave')";
|
||||
assert.equal(ev(`${wave}.cable`), 'tonga', 'the wave rides the only cable');
|
||||
ev("ACT.buySat({a:'suv',b:'tbu',bird:'kac1',g:5})");
|
||||
assert.equal(ev(`${sat}.standby`), true, 'next to the cable it goes on standby by itself');
|
||||
ev(ready);
|
||||
assert.equal(ev(`R.load[${sat}.id]`), 0, 'idle while the cable is up');
|
||||
assert.ok(ev(`R.load[${wave}.id]`) > 1);
|
||||
assert.equal(ev('R.latF.tbu'), undefined, 'nobody notices a satellite that carries nothing');
|
||||
// The anchor drags across the cable: the satellite carries the island.
|
||||
ev(`${wave}.cut=S.day+30;compute()`);
|
||||
assert.ok(ev(`R.load[${sat}.id]`) > 1, 'the satellite takes over');
|
||||
assert.ok(ev('R.citySrv.tbu') > 1);
|
||||
assert.equal(ev('R.latF.tbu'), 0.5, 'at GEO’s latency');
|
||||
// Without it, the island is dark.
|
||||
ev(`S.links=S.links.filter(l=>l.kind!=='sat');compute()`);
|
||||
assert.ok((ev('R.citySrv.tbu') || 0) < 1e-6, 'no satellite, no internet in Tonga');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a cable laid beside a circuit puts it on standby; overflow and a shared load cost users their share', (t) => {
|
||||
// The issue's own order: the satellite first, a cable later.
|
||||
const { ev, errors } = game(t, "ACT.buildPop({city:'suv'});ACT.launchBB({city:'suv'});ACT.buyTransit({city:'suv',net:" +
|
||||
"NETS.find(n=>sellsAt(n,'suv')).id,tier:1});ACT.buildPop({city:'tbu'});ACT.launchBB({city:'tbu'});ACT.teleBuild({city:'suv'});");
|
||||
const wave = "S.links.find(l=>l.kind==='wave')";
|
||||
ev("ACT.buySat({a:'suv',b:'tbu',bird:'kac1',g:10});" + ready);
|
||||
assert.equal(!!ev(`${sat}.standby`), false, 'alone, it carries the island');
|
||||
assert.equal(ev('R.latF.tbu'), 0.5);
|
||||
ev("UI.pending={a:'suv',b:'tbu'};ACT.buildLink({tier:0})");
|
||||
assert.equal(ev(`${sat}.standby`), true, 'the cable puts it on standby');
|
||||
assert.match(ev("document.querySelector('#toasts').textContent"), /goes on standby beside the new link/);
|
||||
ev('compute()');
|
||||
assert.equal(ev(`R.load[${sat}.id]`), 0, 'idle while the cable has room');
|
||||
assert.ok(ev(`R.load[${wave}.id]`) > 1);
|
||||
assert.equal(ev('R.latF.tbu'), undefined, 'nobody notices');
|
||||
assert.equal(ev("R.satU.tbu||0"), 0);
|
||||
assert.doesNotMatch(ev("traceroute('tbu',{city:'suv'}).text"), /Kacophony/, 'the trace takes the cable');
|
||||
// The cable loses three quarters of its light: the satellite takes the overflow, and users notice that share.
|
||||
ev(`${wave}.loss={until:S.day+60,f:0.25};compute()`);
|
||||
const cab = ev(`capOf(${wave})`), dem = ev('R.cityDem.tbu');
|
||||
assert.ok(dem > cab, 'more than the cable carries');
|
||||
const sl = ev(`R.load[${sat}.id]`), wl = ev(`R.load[${wave}.id]`), share = sl / (sl + wl);
|
||||
assert.ok(Math.abs(wl - cab) < 1e-6 && sl > 0.5, 'the cable fills, the satellite takes the rest');
|
||||
assert.ok(Math.abs(ev('R.latF.tbu') - (1 - 0.5 * share)) < 1e-6, 'GEO costs half the service of the share it carries: ' + ev('R.latF.tbu'));
|
||||
assert.ok(Math.abs(ev('R.satU.tbu') / ev('R.citySrv.tbu') - share) < 1e-6);
|
||||
ev("UI.sel={type:'city',id:'tbu'};UI.tab='cust';renderAll()");
|
||||
assert.match(ev("document.querySelector('#panel').textContent"), /users ride a satellite/);
|
||||
ev("UI.sel={type:'city',id:'suv'};renderAll()");
|
||||
assert.doesNotMatch(ev("document.querySelector('#panel .facts').textContent"), /users ride a satellite/, 'not on the teleport’s own city');
|
||||
// Taken off standby by hand, it shares the load by capacity, and users notice that share too.
|
||||
ev(`ACT.setStandby({id:${sat}.id,on:false})`);
|
||||
const s2 = ev(`R.load[${sat}.id]`) / (ev(`R.load[${sat}.id]`) + ev(`R.load[${wave}.id]`));
|
||||
assert.ok(Math.abs(s2 - 10 / (10 + cab)) < 1e-6, 'split by capacity');
|
||||
assert.ok(Math.abs(ev('R.latF.tbu') - (1 - 0.5 * s2)) < 1e-6);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the teleport city’s own users get the satellite tag only when they ride it', (t) => {
|
||||
// Honolulu: transit only in Los Angeles (a haul users notice), and a teleport carrying Papeete.
|
||||
const { ev, errors } = game(t, "ACT.buildPop({city:'lax'});ACT.buyTransit({city:'lax',net:NETS.find(n=>sellsAt(n,'lax')).id,tier:1});ACT.buildPop({city:'hnl'});ACT.launchBB({city:'hnl'});" +
|
||||
"UI.pending={a:'hnl',b:'lax'};ACT.buildLink({tier:1});ACT.teleBuild({city:'hnl'});ACT.buildPop({city:'ppt'});ACT.launchBB({city:'ppt'});ACT.buySat({a:'hnl',b:'ppt',bird:'is18',g:1});");
|
||||
ev('S.day=Math.max(...S.links.map(l=>l.ready||0))+1;compute()');
|
||||
assert.ok(ev(`R.load[${sat}.id]`) > 0.5, 'Papeete rides the satellite');
|
||||
assert.ok(ev('R.latF.hnl') < 1, 'Honolulu’s users notice the haul to Los Angeles');
|
||||
assert.equal(ev("R.satU.hnl||0"), 0, 'but none of their traffic goes up');
|
||||
assert.equal(ev("satFact('hnl')"), '');
|
||||
assert.match(ev("satFact('ppt')"), /users ride a satellite/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('subsea counts leave satellites out: a no-subsea covenant and the cables overseas of Fibre to the Basement', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
|
||||
ev("S.loanOffers.push({id:'wf1',bank:'wf',amount:200000,exp:S.day+25,covs:['nosub','logo','reach99'],apr:0.15,term:12,pay:Math.round(annuity(200000,0.15,12))});ACT.takeLoan({id:'wf1'})");
|
||||
const L = "S.loans.find(l=>l.id==='wf1')";
|
||||
assert.equal(ev(`COVS.nosub.ok(${L})`), true);
|
||||
ev("ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:1})");
|
||||
assert.equal(ev(`COVS.nosub.ok(${L})`), true, 'a satellite circuit is no subsea link');
|
||||
const bal = ev(`${L}.bal`);
|
||||
ev('for(let i=0;i<40;i++){S.day++;loanTick(S.day);}');
|
||||
assert.ok(!(ev(`${L}.breach`) > 0), 'no breach');
|
||||
assert.ok(ev(`${L}.bal`) <= bal, 'no penalty');
|
||||
// A real subsea wave still breaks it.
|
||||
ev("ACT.buildPop({city:'akl'});UI.pending={a:'syd',b:'akl'};ACT.buildLink({tier:1})");
|
||||
assert.equal(ev(`COVS.nosub.ok(${L})`), false);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('two satellite circuits are not two cables overseas in Fibre to the Basement', (t) => {
|
||||
const { ev, errors } = game(t);
|
||||
ev("ACT.startScn({id:'fttb'});S.cash=1e8;S.lvl=2;S.nextFail=S.nextEvent=1e9;ACT.teleBuild({city:'syd'});ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:1});ACT.buySat({a:'syd',b:'nou',bird:'kac1',g:1});");
|
||||
assert.equal(ev("S.links.filter(l=>l.kind==='sat').length"), 2);
|
||||
ev('S.day=Math.max(...S.links.map(l=>l.ready||0))+1;compute()');
|
||||
assert.equal(ev('auExits()'), 0, 'no cable leaves Australia');
|
||||
assert.equal(J(ev, 'SCN_PROG.fttb()').find((r) => r.max === 2).v, 0, 'the progress row says so');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a teleport is offered only where a satellite on sale sees the POP, and tracking antennas only under the MEO ring', (t) => {
|
||||
const { ev, errors } = game(t, "S.lvl=2;ACT.buildPop({city:'hpa'});ACT.buildPop({city:'chi'});ACT.buildPop({city:'lon'});");
|
||||
const panel = (c) => { ev(`UI.sel={type:'city',id:'${c}'};UI.tab='links';renderAll()`); return ev("document.querySelector('#panel').textContent"); };
|
||||
const disabled = (c) => ev(`(b=>!!b&&b.disabled)(document.querySelector('#panel [data-act="teleBuild"]'))`);
|
||||
// Haparanda, by the Arctic Circle: nothing on sale sees it, and the panel says so before any money moves.
|
||||
assert.match(panel('hpa'), /No satellite on sale sees this city/);
|
||||
assert.equal(disabled('hpa'), true);
|
||||
const c0 = ev('S.cash');
|
||||
ev("ACT.teleBuild({city:'hpa'})");
|
||||
assert.equal(ev("teleOf('hpa')"), 0);
|
||||
assert.equal(ev('S.cash'), c0, 'nothing charged');
|
||||
assert.match(ev("teleWhy('hpa')"), /No satellite/);
|
||||
// Chicago sees the bird over the Americas, and the panel says what is in reach before the build.
|
||||
assert.match(panel('chi'), /In view: Intelsplat 19/);
|
||||
assert.match(ev("document.querySelector('#panel').textContent"), /in reach at your level/);
|
||||
assert.equal(disabled('chi'), false);
|
||||
ev("ACT.teleBuild({city:'chi'})");
|
||||
assert.equal(ev("teleOf('chi')"), 1);
|
||||
// London is north of the MEO ring: no tracking antennas there, at any level.
|
||||
ev("S.lvl=3;ACT.teleBuild({city:'lon'})");
|
||||
assert.equal(ev("teleOf('lon')"), 1);
|
||||
assert.ok(!J(ev, "(()=>{UI.sel={type:'city',id:'lon'};UI.tab='links';renderAll();return [...document.querySelectorAll('#panel [data-act]')].map(b=>b.dataset.act);})()").includes('teleTrk'));
|
||||
const c1 = ev('S.cash');
|
||||
ev("ACT.teleTrk({city:'lon'})");
|
||||
assert.equal(ev("teleOf('lon')"), 1);
|
||||
assert.equal(ev('S.cash'), c1);
|
||||
assert.match(ev("trkWhy('lon')"), /does not see London/);
|
||||
assert.equal(ev("trkWhy('chi')"), '', 'Chicago is under the ring');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the order sheet prices a new POP with your POP standard, as the list before it does', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});S.pops.syd.rgen=2;ACT.popStdSet({city:'syd'});");
|
||||
const std = ev('newPopCost("pcn")');
|
||||
assert.ok(std > ev('popCost("pcn")'), 'the standard adds routers');
|
||||
ev("ACT.satOpen({a:'syd'})");
|
||||
assert.ok(ev("document.querySelector('#modalCard').textContent").includes(ev(`fmt$(${std})`)));
|
||||
ev("ACT.satOpen({a:'syd',b:'pcn'})");
|
||||
assert.ok(ev("document.querySelector('#modalCard').textContent").includes(ev(`fmt$(${std})`)), 'the same price one tap later');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('MCP: dry runs for satellites quote what the game then does', () => {
|
||||
const s = createSession(), T = (n, a = {}) => TOOLS.find((x) => x.name === n).run(s, a), ev = (x) => s.game.ev(x);
|
||||
T('new_game', { city: 'syd', preset: 'sandbox', seed: 7, name: 'Probe' });
|
||||
ev('S.lvl=Math.max(S.lvl,3);S.cash=1e9');
|
||||
assert.deepEqual(T('act', { action: 'teleBuild', args: { city: 'syd' }, dryRun: true }).quote.blocked, []);
|
||||
T('act', { action: 'teleBuild', args: { city: 'syd' } });
|
||||
assert.deepEqual(T('act', { action: 'teleTrk', args: { city: 'syd' }, dryRun: true }).quote.blocked, [], 'Sydney is under the MEO ring');
|
||||
assert.match(T('act', { action: 'teleTrk', args: { city: 'mel' }, dryRun: true }).quote.blocked.join(' '), /no teleport in Melbourne/);
|
||||
T('act', { action: 'buySat', args: { a: 'syd', b: 'asp', bird: 'is18', g: 1 } });
|
||||
const id = ev("S.links.find(l=>l.kind==='sat').id");
|
||||
// A wave beside the circuit: no diversity premium, in the quote as in the bill.
|
||||
const q = T('act', { action: 'buildLink', args: { a: 'syd', b: 'asp', tier: 1 }, dryRun: true }).quote;
|
||||
const c0 = ev('S.cash');
|
||||
T('act', { action: 'buildLink', args: { a: 'syd', b: 'asp', tier: 1 } });
|
||||
assert.equal(q.setup, c0 - ev('S.cash'), 'quote equals charge');
|
||||
assert.equal(ev(`S.links.find(l=>l.id==='${id}').standby`), true);
|
||||
// Resizing: only sizes the bird sells, and not the one it has.
|
||||
for (const g of [20, 1]) {
|
||||
const r = T('act', { action: 'satSize', args: { id, g }, dryRun: true }).quote;
|
||||
assert.match(r.blocked.join(' '), /No such satellite circuit/, 'g ' + g);
|
||||
}
|
||||
const up = T('act', { action: 'satSize', args: { id, g: 5 }, dryRun: true }).quote;
|
||||
assert.deepEqual(up.blocked, []);
|
||||
const c1 = ev('S.cash');
|
||||
T('act', { action: 'satSize', args: { id, g: 5 } });
|
||||
assert.equal(up.setup, c1 - ev('S.cash'));
|
||||
assert.deepEqual(s.errors(), []);
|
||||
});
|
||||
|
||||
test('a satellite elsewhere is the long way round: routers use the cables and fall back to it only when cut', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.buildPop({city:'suv'});UI.pending={a:'syd',b:'suv'};ACT.buildLink({tier:1});UI.pending={a:'suv',b:'tbu'};ACT.buildLink({tier:1});ACT.teleBuild({city:'syd'});");
|
||||
ev("ACT.buySat({a:'syd',b:'tbu',bird:'is18',g:5})");
|
||||
assert.equal(!!ev(`${sat}.standby`), false, 'no link between Sydney and Tonga: not on standby');
|
||||
ev(ready);
|
||||
assert.ok(ev(`${sat}.km`) > 10 * ev("kmBetween('syd','tbu')"), 'its metric is the radio path');
|
||||
assert.equal(ev(`R.load[${sat}.id]||0`), 0, 'Tonga goes to Sydney over the cables, not the satellite');
|
||||
ev("S.links.find(l=>l.kind==='wave'&&(l.a==='tbu'||l.b==='tbu')).cut=S.day+30;compute()");
|
||||
assert.ok(ev(`R.load[${sat}.id]`) > 1, 'with the Tonga cable cut, the satellite carries it');
|
||||
// Nobody digs up a satellite: cuts land on the cables only.
|
||||
ev("S.links.forEach(l=>l.cut=0);S.inc=[];for(let i=0;i<12;i++){fireFailure('cut');for(const l of S.links)if(l.kind!=='sat')l.cut=0;S.inc=[];}");
|
||||
assert.equal(ev(`${sat}.cut`), 0);
|
||||
// The traceroute names the bird.
|
||||
ev("S.links.find(l=>l.kind==='wave'&&(l.a==='tbu'||l.b==='tbu')).cut=S.day+30;compute()");
|
||||
assert.match(ev("traceroute('tbu',{city:'syd'}).text"), /via Intelsplat 18/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Pitcairn by satellite: a POP comes with the circuit, but GEO is not good enough for the UK grant', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
|
||||
assert.equal(ev("!!S.pops.pcn"), false);
|
||||
const c0 = ev('S.cash');
|
||||
ev("ACT.buySat({a:'syd',b:'pcn',bird:'is18',g:1})");
|
||||
assert.ok(ev('!!S.pops.pcn'), 'the order builds the POP');
|
||||
assert.equal(c0 - ev('S.cash'), ev("satMo('is18',1)+popCost('pcn')"));
|
||||
ev("ACT.launchBB({city:'pcn'});" + ready);
|
||||
assert.ok(ev('R.citySrv.pcn') > 0, 'the islanders are online');
|
||||
assert.ok(ev("sfOf(R,'pcn')") <= 0.5 + 1e-9);
|
||||
assert.equal(ev('grantOn(R)'), false);
|
||||
assert.equal(ev('R.rev.grant'), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Pitcairn over MEO serves the islanders well, but the UK pays its fiber grant only for a cable', (t) => {
|
||||
const { ev, errors } = game(t, "ACT.buildPop({city:'akl'});ACT.launchBB({city:'akl'});ACT.buyTransit({city:'akl',net:NETS.find(n=>sellsAt(n,'akl')).id,tier:1});ACT.teleBuild({city:'akl'});ACT.teleTrk({city:'akl'});");
|
||||
assert.equal(ev("teleOf('akl')"), 2);
|
||||
ev("ACT.buySat({a:'akl',b:'pcn',bird:'o3b',g:2});ACT.launchBB({city:'pcn'});" + ready);
|
||||
assert.ok(ev('R.citySrv.pcn') > 0, 'the islanders are online');
|
||||
assert.ok(ev("sfOf(R,'pcn')") >= 0.9, 'MEO serves them nearly as well as fiber');
|
||||
assert.ok(Math.abs(ev("satShare(R,'pcn')") - 1) < 1e-9, 'all of it over the satellite');
|
||||
assert.equal(ev('grantOn(R)'), false, 'no fiber grant for a satellite');
|
||||
assert.equal(ev('R.rev.grant'), 0);
|
||||
assert.match(ev("grantFact('pcn')"), /needs a cable/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('saves: circuits survive a round trip, broken ones are dropped, and old saves load as they were', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});S.pops.syd.tele=2;ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:2});ACT.buySat({a:'syd',b:'tbu',bird:'o3b',g:5});");
|
||||
const before = J(ev, "S.links.filter(l=>l.kind==='sat')");
|
||||
ev('S=migrate(JSON.parse(JSON.stringify(S)));compute()');
|
||||
assert.deepEqual(J(ev, "S.links.filter(l=>l.kind==='sat')"), before, 'kind, bird, size and dates kept');
|
||||
// Garbage in: an unknown bird, an odd size, a MEO circuit on a GEO-only teleport, a teleport that is not 1 or 2.
|
||||
ev("S.links.push({id:'x1',a:'syd',b:'tbu',kind:'sat',bird:'nope',g:1,km:1,mo:1,cut:0});S.links.find(l=>l.bird==='kac1').g=7;S.links.find(l=>l.bird==='kac1').km=3;S.pops.tbu.tele='big'");
|
||||
ev('S=migrate(JSON.parse(JSON.stringify(S)))');
|
||||
assert.equal(ev("S.links.some(l=>l.id==='x1')"), false, 'an unknown bird is dropped');
|
||||
assert.equal(ev("S.links.find(l=>l.bird==='kac1').g"), 5, 'an odd size becomes the largest size on sale under it');
|
||||
assert.equal(ev("S.links.find(l=>l.bird==='kac1').km"), ev("satKm('kac1','syd','tbu')"), 'the radio path is the physics, not the save');
|
||||
assert.equal(ev("'tele' in S.pops.tbu"), false);
|
||||
// A circuit's order day from a save: a number no later than today, so its commissioning bar is a real width.
|
||||
ev("(k=>{k.day='junk';k.ready=S.day+5;})(S.links.find(l=>l.bird==='kac1'));S=migrate(JSON.parse(JSON.stringify(S)))");
|
||||
assert.equal(ev("S.links.find(l=>l.bird==='kac1').day"), ev('S.day'));
|
||||
ev("S.links.find(l=>l.bird==='kac1').day=S.day+40;S=migrate(JSON.parse(JSON.stringify(S)))");
|
||||
assert.equal(ev("S.links.find(l=>l.bird==='kac1').day"), ev('S.day'), 'not in the future');
|
||||
ev("delete S.links.find(l=>l.bird==='kac1').day;S=migrate(JSON.parse(JSON.stringify(S)));compute()");
|
||||
assert.doesNotMatch(ev("satPanel(S.links.find(l=>l.bird==='kac1'))"), /NaN/);
|
||||
ev("S.pops.syd.tele=1;S=migrate(JSON.parse(JSON.stringify(S)))");
|
||||
assert.equal(ev("S.links.some(l=>l.bird==='o3b')"), false, 'a MEO circuit needs tracking antennas at its teleport');
|
||||
ev("delete S.pops.syd.tele;S=migrate(JSON.parse(JSON.stringify(S)))");
|
||||
assert.equal(ev("S.links.filter(l=>l.kind==='sat').length"), 0, 'no teleport, no circuits');
|
||||
// A save from before satellites: nothing about it changes, not even a row in the bill.
|
||||
ev("S=migrate(JSON.parse(" + JSON.stringify(SAVE) + "));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute()");
|
||||
assert.equal(ev("S.links.some(l=>l.kind==='sat')||Object.values(S.pops).some(p=>'tele' in p)"), false);
|
||||
assert.equal(ev("'sat' in R.cost"), false);
|
||||
assert.ok(ev('R.served') > 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('closing: a teleport with circuits stays open; closing the island or the teleport’s POP takes the circuit along', (t) => {
|
||||
const { ev, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:1});");
|
||||
ev("ACT.teleRm({city:'syd'});ACT.teleRm({city:'syd'})");
|
||||
assert.equal(ev("teleOf('syd')"), 1, 'not while a circuit starts there');
|
||||
ev("decommission(['tbu'])");
|
||||
assert.equal(ev(`!!${sat}`), false, 'the island’s POP takes its circuit along');
|
||||
ev("ACT.teleRm({city:'syd'})");
|
||||
assert.equal(ev("teleOf('syd')"), 1, 'the first tap only arms it');
|
||||
ev("ACT.teleRm({city:'syd'})");
|
||||
assert.equal(ev("teleOf('syd')"), 0);
|
||||
ev("ACT.teleBuild({city:'syd'});ACT.buySat({a:'syd',b:'pcn',bird:'is18',g:1});decommission(['syd'])");
|
||||
assert.equal(ev("S.links.some(l=>l.kind==='sat')"), false, 'so does the teleport’s');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('on a phone: the teleport section, the order sheet, a circuit’s panel and the map, at 360 px', (t) => {
|
||||
const { ev, dom, errors } = game(t, ISLE + "ACT.teleBuild({city:'syd'});");
|
||||
ev('window.innerWidth=360;window.innerHeight=740;window.dispatchEvent(new window.Event("resize"))');
|
||||
assert.equal(ev('isPhone()'), true);
|
||||
const text = (sel) => ev(`(document.querySelector('${sel}')||{}).textContent||''`);
|
||||
const acts = (sel) => J(ev, `[...document.querySelectorAll('${sel} [data-act]')].map(b=>b.dataset.act)`);
|
||||
ev("UI.sel={type:'city',id:'syd'};UI.tab='links';renderAll()");
|
||||
assert.match(text('#panel'), /Satellites/);
|
||||
assert.ok(acts('#panel').includes('satOpen'));
|
||||
// A city without a POP that the teleport reaches.
|
||||
ev("UI.sel={type:'city',id:'apw'};renderAll()");
|
||||
assert.match(text('#panel'), /By satellite/);
|
||||
ev("ACT.satOpen({a:'syd'})");
|
||||
assert.ok(acts('#modalCard').filter((a) => a === 'satOpen').length >= 2, 'a choice of destinations');
|
||||
ev("ACT.satOpen({a:'syd',b:'tbu'})");
|
||||
assert.ok(acts('#modalCard').filter((a) => a === 'buySat').length >= 8, 'every bird that sees both, every size');
|
||||
assert.equal(ev('document.getElementById("modal").hidden'), false);
|
||||
ev("ACT.buySat({a:'syd',b:'tbu',bird:'kac1',g:2});" + ready + ';renderAll()');
|
||||
assert.match(text('#panel'), /round trip/);
|
||||
assert.ok(acts('#panel').includes('satSize') && acts('#panel').includes('rmLink'));
|
||||
for (const s of ['#panel', '#modalCard', '#toasts']) assert.doesNotMatch(text(s), /satellites\.|undefined|NaN/, s);
|
||||
// How the tube looks on the map: dashed like a virtual circuit, in the operator's colour; then a frame is drawn.
|
||||
const look = J(ev, `(()=>{const L=linkLook([${sat}],S.day);return {dash:L.dash,col:L.col,w:L.w0};})()`);
|
||||
assert.equal(look.dash, 2);
|
||||
assert.equal(look.col, ev("SAT_PROV.kac.col"));
|
||||
ev('draw(performance.now())');
|
||||
assert.deepEqual(errors, []);
|
||||
assert.equal(dom.window.document.querySelectorAll('#panel').length, 1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue