Merge v2 into v2-saves

This commit is contained in:
Frederic Jung 2026-10-29 07:32:19 +01:00
commit 5f412f72d8
No known key found for this signature in database
96 changed files with 6237 additions and 321 deletions

View file

@ -610,7 +610,8 @@ test('Australia: hard mode start in Sydney, dear transit and waves, cheap IX por
assert.equal(ev('S.home'), 'syd');
assert.equal(ev("regionMult('syd')"), 3, 'transit into Australia costs more than Asia');
assert.ok(ev("regionMult('syd')>regionMult('sin')&&regionMult('syd')<regionMult('icn')"));
assert.equal(ev("regionMult('akl')"), 1.8, 'Auckland keeps the Oceania price');
assert.ok(ev("regionMult('akl')") < ev('AU_TRANSIT'), 'Auckland is not priced like Australia');
assert.equal(ev("regionMult('akl')"), ev("Math.round(1.8*txComp('akl')*10)/10"), 'Auckland pays the Oceania price, adjusted for its market');
assert.equal(ev("waveMarket('syd','lax',true).reg"), 2.6, 'any subsea wave touching Australia');
assert.equal(ev("waveMarket('mel','syd',false).reg"), 1.8);
assert.ok(ev("ixPortMo('syd',1)<PORT[1].ix"), 'IX ports are the cheap exception');
@ -1070,3 +1071,30 @@ test('city density: no small city crowds a bigger one, Brazil is slimmer than Eu
ev('cam.x=CITY.cpv.x;cam.y=CITY.cpv.y;cam.z=6;draw(0)');
assert.deepEqual(errors, []);
});
test('prices follow real connectivity: thin markets cost more, hubs stay put', () => {
const { ev, errors } = load();
start(ev);
assert.deepEqual(JSON.parse(ev('JSON.stringify(Object.keys(CITY_PDB).filter(c=>!CITY[c]))')), [], 'every entry is a city on the map');
assert.deepEqual(JSON.parse(ev('JSON.stringify(CITIES.filter(c=>!CITY_PDB[c.id]).map(c=>c.id))')), [], 'every city has data, so none keeps the plain price by accident');
assert.ok(ev('Object.values(CITY_PDB).every(q=>Array.isArray(q)&&q.length===3&&q.every(x=>Number.isInteger(x)&&x>=0)&&q[1]>=0)'), '[facilities, presences, ASNs], whole numbers');
// The cities that used to have none: thin markets cost more than Frankfurt, and the Arctic has no neutral data center.
for (const c of ['dus', 'rix', 'mct', 'mle', 'fuk', 'sju', 'kin', 'anc', 'tik']) assert.ok(ev(`txComp('${c}')`) > 1, `${c} is no hub`);
for (const c of ['brw', 'tik', 'pvs', 'hav']) assert.equal(ev(`colo('${c}')`), 1.5, `${c}: no carrier-neutral data center`);
assert.ok(ev("txComp('dus')") < ev("txComp('rix')") && ev("txComp('rix')") < ev("txComp('mle')"), 'Düsseldorf, Riga, Malé: ever thinner');
// A city without data keeps the plain regional price.
assert.equal(ev("(()=>{const q=CITY_PDB.fra;delete CITY_PDB.fra;const r=[txComp('fra'),colo('fra'),popMo('fra')];CITY_PDB.fra=q;return r.join()})()"), `1,1,${ev('POP_MO')}`);
assert.equal(ev("regionMult('syd')"), ev('AU_TRANSIT'), 'Australia keeps its hand-set transit price');
for (const c of ['fra', 'ams', 'lon', 'nyc']) assert.equal(ev(`txComp('${c}')`), 1, `${c} is a hub`);
assert.equal(ev("regionMult('sao')"), 1.6, 'São Paulo keeps the South American price');
assert.ok(ev("regionMult('rbr')") > ev("regionMult('sao')") * 1.5, 'Rio Branco has few sellers');
assert.ok(ev("txComp('rbr')") <= 1.8);
assert.equal(ev("colo('rbr')"), 1.5, 'no neutral data center');
assert.equal(ev("popCost('rbr')"), ev('POP_COST') * 1.5);
assert.equal(ev("popMo('fra')"), ev('POP_MO'));
ev("ACT.buildPop({city:'rbr'});compute()");
assert.ok(ev('R.cost.pops') >= ev("popMo('rbr')"), 'running cost uses the city rent');
ev("selectCity('rbr')");
assert.ok(ev("CITY_PDB.sao[2]>=2000&&CITY_PDB.nyc[2]>=2000&&CITY_PDB.kgl[2]<2000"), 'Brazil and the US are dense in ASNs, Rwanda is not');
assert.deepEqual(errors, []);
});