Tests: Gangnam reference hauls from Tokyo; Seoul-only, Tokyo-only and the old plan fail
The reference player learns single PNIs and last-resort transit.
This commit is contained in:
parent
b008b3a652
commit
47c3674e8c
3 changed files with 80 additions and 3 deletions
54
tests/gangnam.test.js
Normal file
54
tests/gangnam.test.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// Gangnam Style Peering: sender pays, turned up by the scenario rule `sender` (and only there).
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const start = (ev) => ev(`beginGame('T','icn',{scn:SCN.find(x=>x.id==='gangnam')});if(UI.pendGame)ACT.pitchSkip();closeModal();S.cash=1e8`);
|
||||
const seoul = "ACT.launchBB({city:'icn'});ACT.buyTransit({city:'icn',net:'cog',tier:1});compute();for(let i=0;i<20;i++)dayTick();compute()";
|
||||
|
||||
test('sender pays: fee on Seoul transit, incumbents only over a paid PNI, cheap broadband', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
ev(seoul);
|
||||
assert.ok(ev("scnRule('sender')"));
|
||||
assert.equal(ev("R.reachable.ktt||R.reachable.skb||R.reachable.lgu"), false, 'transit does not carry the incumbents');
|
||||
assert.ok(ev('R.reach') < 0.99);
|
||||
const t = JSON.parse(ev("(()=>{const t=S.transit[0],q=R.p95[t.id];return JSON.stringify({fee:krFee(t,q),q,mo:transitMo(t,q)})})()"));
|
||||
assert.ok(t.q > 0 && t.fee === Math.round(t.q * ev('KR_FEE')), 'a sender-pays fee per Gbps of transit');
|
||||
assert.ok(ev("Math.abs(R.rev.eyeballs-R.cityEye.icn*sfOf(R,'icn')*EYE_RATE*KR_ARPU)<1"));
|
||||
ev("ACT.pni({city:'icn',net:'ktt',tier:0});closeModal();for(let i=0;i<90&&!S.pni.every(pniOn);i++)dayTick();compute()");
|
||||
assert.ok(ev('R.reachable.ktt') && ev('R.reach') >= 0.99, 'a paid PNI with Kay-Tea brings the reach');
|
||||
assert.match(ev('scnCard()'), /Seoul served well/);
|
||||
assert.match(ev('scnCard()'), /Monthly profit/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('sender pays: Korean users mind a haul to Tokyo even over peering', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
ev("ACT.launchBB({city:'icn'});UI.via=null;UI.route=null;openLinkModal('icn','tok');ACT.buildLink({tier:1});closeModal();for(const x of ixIdsIn('tok')){ACT.buyIx({city:x,tier:1,signed:true});ACT.rs({city:x});}compute()");
|
||||
assert.ok(ev('R.egT.ix') > 0 && !ev('R.egT.t'), 'only peering in Tokyo');
|
||||
assert.ok(ev('R.latF.icn') < 0.95, 'the haul costs service');
|
||||
assert.match(ev("latNote('icn')"), /Korean users notice/);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('Korea outside the scenario keeps its usual prices', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("UI.startCity='icn';ACT.start({});closeModal();S.cash=1e8");
|
||||
ev(seoul);
|
||||
assert.ok(!ev("scnRule('sender')"));
|
||||
assert.ok(ev('R.reachable.ktt'), 'transit reaches the incumbents');
|
||||
assert.equal(ev("krFee(S.transit[0],100)"), 0);
|
||||
assert.ok(ev("Math.abs(R.rev.eyeballs-R.cityEye.icn*sfOf(R,'icn')*EYE_RATE)<1"));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('an older Gangnam save picks up the sender-pays rule', () => {
|
||||
const { ev, errors } = load();
|
||||
start(ev);
|
||||
const s = ev("(()=>{const o=JSON.parse(JSON.stringify(S));o.scn.rules={};return JSON.stringify(o);})()");
|
||||
ev(`S=migrate(JSON.parse(${JSON.stringify(s)}))`);
|
||||
assert.ok(ev("S.scn.rules.sender===true"));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
@ -9,6 +9,8 @@ const { play } = require('../scripts/lib/scenario-ref');
|
|||
|
||||
const HIRE = ['hire', ['transit', 'routers', 'repair', 'sales', 'ix']];
|
||||
const home = (c) => [['bb', c], ['tr', c, 1], ['ix', c]];
|
||||
const GN_H = ['hire', ['transit', 'routers', 'repair', 'sales', 'ix', 'caches', 'pni']];
|
||||
const GN_REF = [['bb', 'icn'], ['ix', 'icn'], ['tr', 'icn', 1], ['pni', 'icn', 'ktt', 0], GN_H, ['served', 120], ['link', 'icn', 'tok', 1], ['tr', 'tok', 1], ['ix', 'tok'], ['last', 'icn'], ['pop', 'hkg']];
|
||||
// ref: the reference plan; win: [earliest, latest] day it may win on; cheese: the shortcut, and `by`, the day before
|
||||
// which it must not win (null: never within the scenario's days).
|
||||
const PLAY = {
|
||||
|
|
@ -25,8 +27,9 @@ const PLAY = {
|
|||
win: [70, 200], cheese: [...home('cpt'), ['link', 'cpt', 'cai', 0], ['pop', 'lag'], ['pop', 'nbo'], ['hire']], by: null },
|
||||
ixbr: { ref: [...home('sao'), ...[['sao', 'rio', 1], ['sao', 'cpq', 0], ['sao', 'cwb', 0], ['cwb', 'poa', 0], ['rio', 'bhz', 0], ['bhz', 'bsb', 0], ['bsb', 'gyn', 0], ['rio', 'ssa', 0], ['ssa', 'rec', 0], ['rec', 'for', 0], ['rec', 'nat', 0], ['for', 'bel', 0], ['bel', 'mao', 0], ['bsb', 'cgb', 0], ['sao', 'vix', 0]].flatMap(([a, b, t]) => [['link', a, b, t], ['ix', b, 0]]), ['bb', 'rio'], ['tr', 'rio', 1], ['bb', 'bsb'], ['tr', 'bsb', 1], ['bb', 'for'], ['tr', 'for', 1], HIRE],
|
||||
win: [40, 120], cheese: [['bb', 'sao'], ['tr', 'sao', 1], ...['sao', 'rio', 'bsb', 'bhz', 'cwb', 'poa', 'for', 'rec', 'ssa', 'cpq', 'gyn', 'bel', 'mao', 'nat', 'vix', 'cgb'].flatMap((c) => [['pop', c], ['ix', c, 0]]), ['hire']], by: null },
|
||||
// Seoul at home is enough here: the cheese is just playing, so it only must not be instant.
|
||||
gangnam: { ref: [...home('icn'), ['link', 'icn', 'tok', 1], ['ix', 'tok'], ['tr', 'tok', 1], ['link', 'icn', 'hkg', 1], ['ix', 'hkg'], ['tr', 'hkg', 1], HIRE], win: [50, 120], cheese: [...home('icn'), ['loans']], by: 50 },
|
||||
// Sender pays: Seoul transit to start (dear, but fast), one paid PNI with Kay-Tea for reach, then haul the bulk from
|
||||
// Tokyo and keep Seoul transit as the last resort. Seoul alone loses money on the sender-pays fee and never wins.
|
||||
gangnam: { ref: GN_REF, win: [130, 190], cheese: [...home('icn'), ['loans']], by: null },
|
||||
// Bigger routers bring Flowspec, which also takes floods: without a scrubbing center it takes twice as long.
|
||||
flood: { ref: [...home('ams'), ['scrub', 'ams', 1], ['tr', 'ams', 1], HIRE], win: [80, 200], cheese: [...home('ams'), ['tr', 'ams', 1], ['loans']], by: 180 },
|
||||
fttb: { ref: [...home('syd'), ['link', 'syd', 'akl', 0, 'tasman'], ['link', 'syd', 'nou', 0, 'gond'], ...['mel', 'bne', 'adl', 'per'].flatMap((c) => [['bb', c], ['tr', c, 1]]), ['link', 'syd', 'mel', 1], ['link', 'syd', 'bne', 1], ['link', 'mel', 'adl', 1], ['link', 'adl', 'per', 0], HIRE],
|
||||
|
|
@ -58,3 +61,20 @@ for (const [id, P] of Object.entries(PLAY)) {
|
|||
assert.deepEqual(g.errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
// Gangnam Style Peering bites every way (2.0.0 playtest): paying the sender-pays fee on everything loses money, hauling
|
||||
// everything from Tokyo is too slow for Korean users, and the old plan (transit everywhere, no Kay-Tea) has neither
|
||||
// the reach nor the profit. The reference's Seoul transit as first choice, not last resort, also stays in the red.
|
||||
for (const [name, plan] of Object.entries({
|
||||
'Seoul transit and Kay-Tea': [['bb', 'icn'], ['ix', 'icn'], ['tr', 'icn', 1], ['pni', 'icn', 'ktt', 0], GN_H],
|
||||
'everything from Tokyo': [['bb', 'icn'], ['link', 'icn', 'tok', 1], ['tr', 'tok', 1], ['ix', 'tok'], ['pni', 'tok', 'ktt', 0], ['pop', 'hkg'], GN_H],
|
||||
'the 1.x reference': [...home('icn'), ['link', 'icn', 'tok', 1], ['ix', 'tok'], ['tr', 'tok', 1], ['link', 'icn', 'hkg', 1], ['ix', 'hkg'], ['tr', 'hkg', 1], HIRE],
|
||||
'Tokyo haul, Seoul transit first': GN_REF.filter((s) => s[0] !== 'last'),
|
||||
})) {
|
||||
test(`gangnam: ${name} does not win`, () => {
|
||||
const g = load();
|
||||
const r = play(g.ev, 'gangnam', plan);
|
||||
assert.equal(r.won, null, `${name} won on day ${r.won}`);
|
||||
assert.deepEqual(g.errors, []);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue