Interns: the same orders, each best at one part of the job

The three interns run every order the same way at the same salary;
each is now better at one thing, and says so when hired:
- Anycast Annie peers: the IX order runs every day, not only weekly, and
  the PNI order twice a week.
- Kevin from the night shift does maintenance: two line system swaps a
  night instead of one, and never a fat finger. He rolls the same dice
  (catching it before Enter), so a seeded game plays the same whoever is
  hired.
- Tracy Route plans ahead: the transit, ports, routers, optics and
  optical transport orders act as if traffic were already 10% higher
  (OPS_AHEAD).
This commit is contained in:
Frederic Jung 2026-11-06 20:23:18 +00:00
parent c96f9e7644
commit ed0cac9974
No known key found for this signature in database
13 changed files with 133 additions and 18 deletions

View file

@ -6,12 +6,13 @@ const { load } = require('./harness');
// Frankfurt (transit) and Amsterdam (broadband) joined by a full Rainbow-in-a-Box fiber of 16×400G, and the long way
// round through Paris on two waves. Level 6: every line system and optic unlocked. Change Freeze: no fat fingers.
// Annie runs the shift: Kevin would swap two line systems a night (tests/intern-personas.test.js).
const BASE = "ACT.start({});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;S.lvl=6;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');" +
"for(const c of ['ams','par'])ACT.buildPop({city:c});for(const c of ['fra','ams','par']){S.pops[c].rgen=mainRG(3);S.pops[c].routers=2;}ACT.launchBB({city:'ams'});" +
"S.transit=[];ACT.buyTransit({city:'fra',net:'cog',tier:2});" +
"S.links=[{id:'f',a:'fra',b:'ams',kind:'df',own:true,sys:'lite',ch:Array(16).fill('zr4'),km:450,trench:'t1',ready:0,cut:0,mo:1,pairs:1}," +
"{id:'w1',a:'fra',b:'par',kind:'wave',tier:4,km:480,cut:0,mo:1},{id:'w2',a:'par',b:'ams',kind:'wave',tier:4,km:430,cut:0,mo:1}];compute();" +
"ACT.opsHire({id:'kevin'});S.ops.floor=0;S.ops.cap.optup=0;closeModal()";
"ACT.opsHire({id:'annie'});S.ops.floor=0;S.ops.cap.optup=0;closeModal()";
function game(t, extra) {
const h = load();
t.after(() => h.dom.window.close());

View file

@ -0,0 +1,86 @@
// The three interns run the same orders the same way, at the same salary; each is better at one part of the job.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const BASE = "ACT.start({});S.cash=1e9;for(const g of GOALS)S.done[g.id]=0;S.lvl=6;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');" +
"ACT.launchBB({city:'fra'});S.pops.fra.rgen=1;ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()";
function game(t, id, extra) {
const h = load();
t.after(() => h.dom.window.close());
h.ev(BASE);
if (extra) h.ev(extra);
h.ev(`ACT.opsHire({id:'${id}'});S.ops.floor=0;S.ops.cap={};closeModal()`);
return h;
}
test('the same salary, and each says what they are best at, in the hiring list and once hired', t => {
const h = load();
t.after(() => h.dom.window.close());
h.ev(BASE);
assert.ok(h.ev("Object.values(INTERNS).every(I=>I.g)"));
h.dom.window.innerWidth = 360;
h.ev('opsModal()');
const txt = h.ev("document.getElementById('modalCard').textContent");
for (const s of [/Best at peering/, /Best at maintenance/, /Best at planning ahead/]) assert.match(txt, s);
assert.equal(h.ev("document.querySelectorAll('#modalCard [data-act=opsHire]').length"), 3);
assert.equal(h.ev("[...document.querySelectorAll('#modalCard [data-act=opsHire]')].every(b=>b.textContent.includes(fmt$(INTERN_MO)))"), true, 'one salary for all');
h.ev("ACT.opsHire({id:'tracy'})");
assert.match(h.ev("document.getElementById('modalCard').textContent"), /Best at planning ahead/);
assert.deepEqual(h.errors, []);
});
test('Annie peers every day and orders PNIs twice a week; the others weekly', t => {
const ix = "ACT.buyIx({city:'fra',tier:0,signed:true});compute()";
for (const [id, want] of [['annie', true], ['kevin', false], ['tracy', false]]) {
const { ev, errors } = game(t, id, ix);
ev("S.ops.on.ix=true;S.day=15;opsDay(S.day)");
assert.equal(ev('Object.keys(S.rs).length>0'), want, `${id} on a Tuesday`);
// How often the PNI order looks for networks to order from, over one week.
ev("S.ops.on.ix=false;S.ops.on.pni=true;window.__pb=0;pniBatch=function(){__pb++;return null;};for(let d=21;d<28;d++){S.day=d;opsDay(d);}");
assert.equal(ev('__pb'), want ? 2 : 1, `${id}: PNI rounds a week`);
assert.deepEqual(errors, []);
}
});
test('Kevin never fat-fingers, even on the unluckiest roll', t => {
for (const [id, want] of [['kevin', false], ['annie', true], ['tracy', true]]) {
const { ev, errors } = game(t, id);
ev("S.rules=makeRules('bgp');window.__r=Math.random;Math.random=()=>0;opsDay(S.day);Math.random=__r");
assert.equal(ev('S.ops.log.some(e=>e.f!==undefined)'), want, id);
assert.deepEqual(errors, []);
}
});
test('Kevin swaps two line systems a night, the others one', t => {
const fibers = "for(const c of ['ams','par'])ACT.buildPop({city:c});for(const c of ['fra','ams','par']){S.pops[c].rgen=mainRG(3);S.pops[c].routers=2;}" +
"S.links=[['f1','fra','ams'],['f2','ams','par'],['f3','par','fra'],['f4','fra','ams']].map(([id,a,b])=>({id,a,b,kind:'df',own:true,sys:'lite',ch:['zr4'],km:450,trench:id,ready:0,cut:0,mo:1,pairs:1}));compute()";
for (const [id, want] of [['kevin', 2], ['annie', 1], ['tracy', 1]]) {
const { ev, errors } = game(t, id, fibers);
ev("S.ops.on.optup=true;S.ops.p.optup={sys:'roadm'};opsDay(S.day)");
assert.equal(ev("S.links.filter(l=>l.sys==='roadm').length"), want, id);
assert.deepEqual(errors, []);
}
});
test('Tracy buys a little before it runs hot; at the same price as anyone', t => {
// A POP at 75% with the order set to 80%: Tracy sees 82.5% and adds a router; the others wait.
for (const [id, want] of [['tracy', 2], ['kevin', 1], ['annie', 1]]) {
const { ev, errors } = game(t, id);
ev("S.ops.on.routers=true;S.ops.p.routers={at:80,how:'add'};compute();R.nodeLoad.fra=R.nodeCap.fra*0.75");
const cost = ev("routerCost(S.pops.fra.rgen||0,S.pops.fra.routers||1)"), c0 = ev('S.cash');
ev('opsDay(S.day)');
assert.equal(ev('S.pops.fra.routers'), want, id);
if (want === 2) assert.equal(c0 - ev('S.cash'), cost, 'what Add router costs');
assert.deepEqual(errors, []);
}
// Transit too: a 30-day peak that the headroom just covers, but not with 10% more.
for (const [id, grew] of [['tracy', true], ['kevin', false]]) {
const { ev, errors } = game(t, id);
ev("S.ops.on.transit=true;S.ops.p.transit={x:1.25,prov:'have'};const t=S.transit[0];t.hist=[lagCap(PORT[t.tier].g,t.n)/1.25/1.05]");
const n0 = ev('JSON.stringify(S.transit.map(t=>[t.tier,t.n||1]))');
ev('opsDay(S.day)');
assert.equal(ev('JSON.stringify(S.transit.map(t=>[t.tier,t.n||1]))') !== n0, grew, id);
assert.deepEqual(errors, []);
}
});

View file

@ -284,7 +284,8 @@ test('the mood follows the week, with no dice', t => {
test('fat fingers: never under Change Freeze, rare and harmless in On-call and BGP at 3 a.m.', t => {
const { ev, errors } = game(t);
hire(ev);
// Kevin never fat-fingers anything: Annie does, now and then.
ev("ACT.opsHire({id:'annie'});S.ops.floor=0;closeModal()");
ev('window.__r=Math.random;Math.random=()=>0');
for (let i = 0; i < 50; i++) shift(ev);
assert.equal(ev('S.ops.log.some(e=>e.f!==undefined)'), false, 'Change Freeze: never, even on the unluckiest roll');
@ -477,7 +478,8 @@ test('one order that throws is paused and noted; the rest of the shift and the d
test('the fat-fingered LAG member respects a paused transit order and per-POP exceptions', t => {
const { ev, errors } = game(t);
hire(ev);
// Kevin never fat-fingers anything: Annie does, now and then.
ev("ACT.opsHire({id:'annie'});S.ops.floor=0;closeModal()");
// Each shift rolls: fat finger yes, the only POP, the LAG slip (index 3).
ev("S.rules=makeRules('bgp');window.__r=Math.random;window.__k=0;Math.random=()=>[0,0,0.7][__k++%3]");
const n0 = ev('S.transit[0].n||1'), c0 = cash(ev);