IPv4 address space: scarce, bought, leased, leased out; IPv6 is free (#150)

A rule (ip4), on in On-call and BGP at 3 a.m., off in the gentler
presets, sandbox and puzzles; scenarios only when they opt in. You start
with a /21 from the registry, sized so the early game never notices
(a gameplay-rules F1 test plays six start cities for 50 days). Business
customers need a block by kind and size; broadband homes take what is
left and the rest go behind CGNAT, which costs a box per home and
annoys some customers. An offer that does not fit cannot be signed and
says why, and a customer that cannot grow at renewal stays its size.

The bank's Address space section buys and sells blocks on a transfer
market with a gentle trend, leases blocks in, and leases spare blocks
out for monthly income, in real CIDR sizes (/24 to /16), at most 256
blocks (what a save keeps). Old saves get what they already use, plus
room, so nothing changes on load. The dashboard's AS box now lists the
blocks you announce.
This commit is contained in:
jvanvik 2026-11-07 01:04:00 +01:00
parent 2cd6b71198
commit eac0604300
34 changed files with 957 additions and 32 deletions

View file

@ -256,7 +256,8 @@ test('M3: every subsystem that can annoy the player reads a rule', () => {
const reads = [['dayPost', 'chaosMul()'], ['fireEvent', "rule('market')"], ['ddosTick', 'ddosOff()'],
['soldOut', "rule('market')"], ['hwMul', "rule('market')"], ['leadDays', "rule('lead')"], ['pniLead', 'leadDays'],
['dfBuildDays', 'leadDays'], ['dayPre', "rule('clock')"], ['snub', "rule('market')"], ['fireFailure', 'shipsOn()'],
['upcomingConfs', 'confsOn()'], ['pniLead', 'pniNow()'], ['dayPost', "rule('broke')"], ['dayPost', "rule('moods')"], ['toast', 'quietOn()']];
['upcomingConfs', 'confsOn()'], ['pniLead', 'pniNow()'], ['dayPost', "rule('broke')"], ['dayPost', "rule('moods')"], ['toast', 'quietOn()'],
['ip4On', "rule('ip4')"], ['ip4Fits', 'ip4On()'], ['ip4Money', 'ip4On()'], ['ip4Day', 'ip4On()']];
fail('M3', reads.filter(([f, r]) => !ev(`typeof ${f}==='function'&&${f}.toString().includes(${lit(r)})`)).map(([f, r]) => `${f}() does not read ${r}`), 'gate it on the ruleset (src/game/40-progress/30-rules.js)');
// and in play: no chaos and no market means a quiet year
const g = load();
@ -372,6 +373,23 @@ test('F1: new players get a gentle start: nothing breaks for 45 days, no sold-ou
assert.deepEqual(g.errors, []);
});
test('F1: the first IPv4 block covers the start: no CGNAT, no IPv4 bill and no IPv4 warning before day 50', () => {
// The F2 reference build, signing every offer that fits, in the F2 cities and the fastest-growing big homes (Asia).
const bad = [];
for (const city of ['fra', 'nyc', 'sin', 'jnb', 'tok', 'del']) {
const g = load();
g.ev(`beginGame('Ref','${city}',{mode:'normal',preset:'oncall'});if(UI.pendGame)ACT.pitchSkip()`);
g.ev(`(()=>{const c='${city}',n=NETS.filter(n=>sellsAt(n,c)).sort((a,b)=>a.price*netMult(a,c)-b.price*netMult(b,c))[0];
ACT.launchBB({city:c});ACT.buyTransit({city:c,net:n.id,tier:1});if(ixName(c)){ACT.buyIx({city:c,tier:1,signed:true});ACT.rs({city:c});}})()`);
assert.equal(g.ev('ip4On()'), true, 'On-call has scarce IPv4');
const hit = g.ev(`(()=>{for(let d=0;d<50;d++){for(const o of S.offers.slice())if(bHas(o)&&ip4Fits(o))ACT.accept({id:o.id});dayTick();
const u=ip4Use();if(u.cg>0||S.ip4.w||R.cost.ip4)return 'day '+S.day+': '+u.cg+' of '+u.H+' homes behind CGNAT, bill '+(R.cost.ip4||0);}return '';})()`);
if (hit) bad.push(`${city}: ${hit}`);
assert.deepEqual(g.errors, []);
}
fail('F1', bad, 'size the first allocation (IP4_START, src/game/60-features/33-address-space.js) so the start fits');
});
test('F2: a simple build in a start city makes money within three months on On-call', () => {
// Reference build: launch broadband, the cheapest 100G transit in town, and a port with a route server where there is an exchange.
const bad = [];