diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c1cd4b..ab025b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] - Networks you reach through an exchange's route server now stay "via RS" (#265). With an Open peering policy, the peering desk used to turn some of them into separate sessions of their own. +- The intern's "Light more fiber" order has a new Optics setting: light new fiber with the biggest optic it can afford, to save channels for later (#262). Once a fiber is lit, the intern still adds more of the same optic and never swaps what is in there. - The Build POP button now shows the whole price of a new POP, including the routers of your standard POP (#261). Before, it showed only the site, although the standard routers were paid for on top; a note under the button now lists them, and the intern's one-tap template prices them in as well. POPs that come with a new wave, dark fiber, your own subsea cable or a consortium seat now get the standard routers too, and those offers show the price with them. ## [2.5.0] — 2026-11-02 diff --git a/site/i18n/de.js b/site/i18n/de.js index 62c0c8b..64d2a77 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -2922,12 +2922,15 @@ "ops.p_keep":"Einen in Reserve", "ops.p_min":"Ablehnen unter", "ops.p_paid":"Paid Peering", +"ops.p_pick":"Optiken", "ops.p_prov":"Anbieter", "ops.p_tier":"Größe", "ops.p_x":"Reserve", "ops.paused":"Pausiert", "ops.per_pop":"Pro POP", "ops.per_pop_note":"Grüne Aufträge laufen in diesem POP. Schalte einen aus, um hier selbst zu entscheiden.", +"ops.pick_big":"die größten auf neuer Faser", +"ops.pick_cheap":"meiste Gbit/s pro Dollar", "ops.really_fire":"Wirklich entlassen?", "ops.report_last":"Schichtbericht der letzten Woche", "ops.report_now":"Diese Woche bisher", diff --git a/site/i18n/es.js b/site/i18n/es.js index 746a61b..869d239 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -2920,12 +2920,15 @@ "ops.p_keep":"Dejar uno de reserva", "ops.p_min":"Rechazar por debajo de", "ops.p_paid":"Peering de pago", +"ops.p_pick":"Ópticas", "ops.p_prov":"Proveedor", "ops.p_tier":"Tamaño", "ops.p_x":"Margen", "ops.paused":"En pausa", "ops.per_pop":"Por POP", "ops.per_pop_note":"Las órdenes en verde se ejecutan en este POP. Apaga una para decidir aquí a mano.", +"ops.pick_big":"las más grandes en fibra nueva", +"ops.pick_cheap":"más Gbps por dólar", "ops.really_fire":"¿Despedir de verdad?", "ops.report_last":"Informe del turno de la semana pasada", "ops.report_now":"Esta semana, hasta ahora", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index e05cb95..6f865b6 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -2920,12 +2920,15 @@ "ops.p_keep":"En garder un de secours", "ops.p_min":"Refuser sous", "ops.p_paid":"Peering payant", +"ops.p_pick":"Optiques", "ops.p_prov":"Fournisseur", "ops.p_tier":"Taille", "ops.p_x":"Marge", "ops.paused":"En pause", "ops.per_pop":"Par POP", "ops.per_pop_note":"Les ordres en vert s'appliquent à ce POP. Désactive-en un pour décider ici à la main.", +"ops.pick_big":"les plus grosses sur fibre neuve", +"ops.pick_cheap":"le plus de Gbps par dollar", "ops.really_fire":"Vraiment remercier ?", "ops.report_last":"Rapport de garde de la semaine dernière", "ops.report_now":"Cette semaine, jusqu'ici", diff --git a/site/i18n/it.js b/site/i18n/it.js index fff5637..5c9db2b 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -2920,12 +2920,15 @@ "ops.p_keep":"Tienine uno di scorta", "ops.p_min":"Rifiuta sotto", "ops.p_paid":"Peering a pagamento", +"ops.p_pick":"Ottiche", "ops.p_prov":"Fornitore", "ops.p_tier":"Taglia", "ops.p_x":"Margine", "ops.paused":"In pausa", "ops.per_pop":"Per POP", "ops.per_pop_note":"Gli ordini in verde valgono per questo POP. Spegnine uno per decidere qui a mano.", +"ops.pick_big":"le più grandi sulla fibra nuova", +"ops.pick_cheap":"più Gbps per dollaro", "ops.really_fire":"Licenziare davvero?", "ops.report_last":"Rapporto del turno della settimana scorsa", "ops.report_now":"Questa settimana, finora", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 67b0b08..a91d9b1 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -2920,12 +2920,15 @@ "ops.p_keep":"Manter um de reserva", "ops.p_min":"Recusar abaixo de", "ops.p_paid":"Peering pago", +"ops.p_pick":"Ópticas", "ops.p_prov":"Provedor", "ops.p_tier":"Tamanho", "ops.p_x":"Folga", "ops.paused":"Em pausa", "ops.per_pop":"Por POP", "ops.per_pop_note":"As ordens em verde valem neste POP. Desligue uma para decidir aqui na mão.", +"ops.pick_big":"as maiores na fibra nova", +"ops.pick_cheap":"mais Gbps por dólar", "ops.really_fire":"Dispensar mesmo?", "ops.report_last":"Relatório do turno da semana passada", "ops.report_now":"Esta semana, até agora", diff --git a/src/game/60-features/95-standing-orders.js b/src/game/60-features/95-standing-orders.js index c2a75ab..15f0e70 100644 --- a/src/game/60-features/95-standing-orders.js +++ b/src/game/60-features/95-standing-orders.js @@ -18,7 +18,7 @@ const OPS=[ {k:'pni',i:'🤝',pop:1,cap:50000,t:N_('ops.o_pni'),d:N_('ops.o_pni_d'),p:{g:{d:25,v:[5,10,25,50,100],l:N_('ops.p_g'),f:v=>fmtG(v)},tier:{d:0,v:[0,1,2],l:N_('ops.p_tier'),f:v=>tr('ops.at_least_port',{port:PORT[v].n})},paid:{d:false,v:[false,true],l:N_('ops.p_paid'),f:v=>tr(v?'common.on':'common.off')}}}, {k:'sales',i:'💼',t:N_('ops.o_sales'),d:N_('ops.o_sales_d'),p:{acc:{d:true,v:[true,false],l:N_('ops.p_acc'),f:v=>tr(v?'common.on':'common.off')},min:{d:0,v:[0,2000,5000,10000,25000,50000],l:N_('ops.p_min'),f:v=>v?tr('common.price_mo',{price:fmt$(v)}):tr('ops.never')}}}, {k:'repair',i:'🔧',cap:50000,t:N_('ops.o_repair'),d:N_('ops.o_repair_d'),p:{}}, - {k:'optics',i:'🌈',cap:250000,t:N_('ops.o_optics'),d:N_('ops.o_optics_d'),p:{at:{d:70,v:[50,60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'}}}, + {k:'optics',i:'🌈',cap:250000,t:N_('ops.o_optics'),d:N_('ops.o_optics_d'),p:{at:{d:70,v:[50,60,70,80,90],l:N_('ops.p_at'),f:v=>v+'%'},pick:{d:'cheap',v:['cheap','big'],l:N_('ops.p_pick'),f:v=>tr({cheap:N_('ops.pick_cheap'),big:N_('ops.pick_big')}[v])}}}, {k:'decom',i:'🧹',t:N_('ops.o_decom'),d:N_('ops.o_decom_d'),p:{keep:{d:true,v:[true,false],l:N_('ops.p_keep'),f:v=>tr(v?'common.on':'common.off')}}}, ]; const OPSK=Object.fromEntries(OPS.map(o=>[o.k,o])),OPS_POP=OPS.filter(o=>o.pop).map(o=>o.k); @@ -101,8 +101,9 @@ function opsQuiet(fn){const a=after,t=toast,s=sfx,f=floater,sel=UI.sel,cf=UI.con function opsShift(){const r=new Map(),broke=new Set(); return {r,broke,dirty:false,up:0,mo:0,rev:0,did(k,w){if(k!=='decline')this.dirty=true;const x=r.get(k)||{n:0,w:[]};x.n++;if(w&&x.w.length<3&&!x.w.includes(w))x.w.push(w);r.set(k,x);}, // A job that costs nothing up front still has to pass the cash floor if it adds to the monthly bill. - can(k,cost,mo=0){const O=S.ops,cap=opsCap(k);if(cost<=0&&!(mo>0))return true; - if(S.cash-Math.max(0,cost)cap)){broke.add(k);return false;}return true;}, + // quiet: only asking, so a no is not logged as the budget running out. + can(k,cost,mo=0,quiet){const O=S.ops,cap=opsCap(k);if(cost<=0&&!(mo>0))return true; + if(S.cash-Math.max(0,cost)cap)){if(!quiet)broke.add(k);return false;}return true;}, book(k,d,dm){const O=S.ops;if(d>0){this.up+=d;if(OPSK[k].cap)O.spent[k]=(O.spent[k]||0)+d;}if(dm){this.mo+=dm;O.addMo[k]=(O.addMo[k]||0)+dm;}}, // Run a click and book what it really cost; false when the action refused (no ports, no cash, a quote changed). pay(k,fn){const c0=S.cash,m0=opsMoNow(),x=fn();this.book(k,c0-S.cash,opsMoNow()-m0);return x===undefined?c0-S.cash>0:x;}};} @@ -153,14 +154,16 @@ const OPS_RUN={ if(i!==undefined)job={cost:PORT[i].setup,go:()=>ACT.buyTransit({city:c,net:n.id,tier:i}),w:'+'+PORT[i].n};}} if(!job||!X.can('transit',job.cost)||!X.pay('transit',job.go))break; X.did('transit',c+' '+job.w);ts=S.transit.filter(t=>t.city===c);}}}, - optics(X){const at=opsP('optics','at')/100; + optics(X){const at=opsP('optics','at')/100,big=opsP('optics','pick')==='big',gpd=(o,l)=>optG(o,l)/optCost(o); for(const l of S.links){if(l.kind!=='df'||l.ready>S.day||l.eqDown>S.day||l.standby||l.cut>S.day)continue; let cap=dfCap(l);const load=(R.load&&R.load[l.id])||0; // New fiber gets its first channel; lit fiber gets more while it runs hot. for(let step=0;step<8&&(cap<=0?!(l.ch||[]).length:load>=cap*at);step++){if(chMax(l)-(l.ch||[]).length-soldSlots(l)<=0)break; const cnt={};for(const k of l.ch||[])cnt[k]=(cnt[k]||0)+1; - // More of what is already lit, or else the most Gbps per dollar that reaches. - const fit=Object.keys(OPT).filter(o=>!chWhy(l,o)),o=fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||fit.sort((a,b)=>optG(b,l)/optCost(b)-optG(a,l)/optCost(a))[0];if(!o)break; + // More of what is already lit, or else the most Gbps per dollar that reaches. Told to go big (#262), the intern + // picks the most Gbps per channel it can afford for a new kind of optic, but never swaps what is already lit. + const fit=Object.keys(OPT).filter(o=>!chWhy(l,o)),cheap=fit.slice().sort((a,b)=>gpd(b,l)-gpd(a,l)), + o=fit.filter(o=>cnt[o]).sort((a,b)=>cnt[b]-cnt[a])[0]||(big&&fit.slice().sort((a,b)=>optG(b,l)-optG(a,l)||gpd(b,l)-gpd(a,l)).find(o=>X.can('optics',opticCountCost(l,o,1),0,true)))||cheap[0];if(!o)break; const n=(cnt[o]||0)+1,cost=opticCountCost(l,o,n),before=(l.ch||[]).length;if(!X.can('optics',cost))break; X.pay('optics',()=>{ACT.setChCount({id:l.id,o,n});return (l.ch||[]).length>before;});if((l.ch||[]).length<=before)break; cap+=optG(o,l);X.did('optics',l.a+'|'+l.b);}}}, diff --git a/src/i18n/en.js b/src/i18n/en.js index b95e358..c1cc63f 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -2921,12 +2921,15 @@ "ops.p_keep":"Keep one spare", "ops.p_min":"Decline below", "ops.p_paid":"Paid peering", +"ops.p_pick":"Optics", "ops.p_prov":"Provider", "ops.p_tier":"Size", "ops.p_x":"Headroom", "ops.paused":"Paused", "ops.per_pop":"Per POP", "ops.per_pop_note":"Green orders run in this POP. Switch one off to decide here by hand.", +"ops.pick_big":"biggest on new fiber", +"ops.pick_cheap":"most Gbps per dollar", "ops.really_fire":"Really let go?", "ops.report_last":"Last week's shift report", "ops.report_now":"This week so far", diff --git a/tests/intern-optics.test.js b/tests/intern-optics.test.js new file mode 100644 index 0000000..0cc9d19 --- /dev/null +++ b/tests/intern-optics.test.js @@ -0,0 +1,59 @@ +// #262: the intern's "Light more fiber" order can be told to light new fiber with the biggest optic instead of the +// most Gbps per dollar. It is still an intern: once a fiber is lit it keeps adding what is in there, never swaps. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { load } = require('./harness'); + +const BASE = "ACT.start({});S.cash=1e8;for(const g of GOALS)S.done[g.id]=0;S.lvl=4;S.nextFail=S.nextEvent=1e9;UI.speed=0;S.rules=makeRules('freeze');" + + "ACT.launchBB({city:'fra'});S.pops.fra.rgen=2;ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buildPop({city:'ams'});S.pops.ams.rgen=2;compute();" + + "ACT.opsHire({id:'kevin'});S.ops.floor=0;closeModal()"; +// A ROADMaster fiber Frankfurt–Amsterdam, dark or lit with `ch`, running at `hot` of what it carries. +const fiber = (ch, hot) => `S.links.push({id:'f',a:'fra',b:'ams',kind:'df',sys:'roadm',ch:${JSON.stringify(ch)},km:450,sub:false,ready:0,cut:0,mo:1,trench:'f'});compute();R.load.f=dfCap(S.links.at(-1))*${hot}`; +function game(t, ch, hot, p, cap) { + const h = load(); + t.after(() => h.dom.window.close()); + h.ev(BASE); + h.ev(fiber(ch, hot)); + h.ev(`S.ops.on.optics=true;S.ops.p.optics=${JSON.stringify(p)};${cap === undefined ? '' : `S.ops.cap.optics=${cap};`}opsDay(S.day)`); + return h; +} +const lit = (ev) => JSON.parse(ev("JSON.stringify(S.links.find(l=>l.id==='f').ch)")); + +test('#262 by default the intern lights new fiber with the most Gbps per dollar, as before', (t) => { + const { ev, errors } = game(t, [], 0, {}); + assert.equal(ev("opsP('optics','pick')"), 'cheap'); + assert.deepEqual(lit(ev), ['zr8']); + assert.deepEqual(errors, []); +}); + +test('#262 told to go big, the intern lights new fiber with the most Gbps per channel', (t) => { + const { ev, errors } = game(t, [], 0, { pick: 'big' }); + assert.deepEqual(lit(ev), ['tp16']); + assert.deepEqual(errors, []); +}); + +test('#262 the biggest optic that fits the budget, and it never swaps what is already lit', (t) => { + const a = game(t, [], 0, { pick: 'big' }, 50000); + assert.deepEqual(lit(a.ev), ['zr8'], 'a 1.6T shelf is over budget, so the next biggest'); + assert.equal(a.ev("S.ops.log.some(e=>/budget/i.test(JSON.stringify(e)))"), false, 'asking is not running out of budget'); + const b = game(t, ['zr4'], 0.95, { pick: 'big' }); + assert.deepEqual(lit(b.ev), ['zr4', 'zr4'], 'hot fiber gets more of what is lit'); + assert.deepEqual(a.errors, []); assert.deepEqual(b.errors, []); +}); + +test('#262 the setting is saved, an unknown value falls back, and it shows on the phone', (t) => { + const { ev, dom, errors } = game(t, [], 0, { pick: 'big' }); + const back = (p) => ev(`(()=>{const s=JSON.parse(JSON.stringify(S));s.ops.p.optics=${JSON.stringify(p)};sanitize(s);return JSON.stringify(s.ops.p.optics);})()`); + assert.deepEqual(JSON.parse(back({ pick: 'big' })), { pick: 'big' }); + assert.deepEqual(JSON.parse(back({ pick: 'huge' })), {}); + assert.deepEqual(JSON.parse(back(undefined)), {}, 'an old save without it'); + dom.window.innerWidth = 360; + ev("ACT.phoneTab({t:'noc'})"); + dom.window.document.querySelector('#leftBody [data-act="opsOpen"]').click(); + const btn = [...dom.window.document.querySelectorAll('#modalCard [data-act="opsParam"]')].find((b) => b.dataset.args.includes('pick')); + assert.ok(btn, 'the Optics button is in the sheet'); + assert.match(btn.textContent, /Optics: biggest on new fiber/); + btn.click(); + assert.equal(ev("opsP('optics','pick')"), 'cheap'); + assert.deepEqual(errors, []); +});