Fiber over land inside one country; no circuits between the Koreas

Towns with no road in (Russia's Arctic and Kamchatka, Juneau and Alaska's
Arctic coast, Greenland's towns) keep their own landmass, which now says
which land it is really part of. isSub() lets two cities of one country on
that land build over land; other countries still need the sea. Inside one
country, Europe to Asia (Moscow-Vladivostok, Istanbul-Ankara) is no longer
a crossing between continents.

North and South Korea join Kyiv-Moscow in a table of pairs nobody sells a
circuit between: the link window says so, the actions refuse, and neither
the diversity map nor the latency floor counts a link there.
This commit is contained in:
Frederic Jung 2026-11-04 12:46:37 +00:00
parent ac5ce7fa05
commit 08bf22cfec
No known key found for this signature in database
19 changed files with 125 additions and 43 deletions

View file

@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- Cities of one country on one piece of land can be joined by fiber over land, even where there is no road: Pevek to Anadyr or Moscow, Juneau to Seattle, Nuuk to Sisimiut. Inside one country, crossing from Europe into Asia (Moscow–Vladivostok, Istanbul–Ankara) is no longer priced as a crossing between continents.
- No circuit of any kind can be built between North and South Korea.
- The map zooms in twice as far, for crowded regions like New England or around Washington.
- Cable ships at anchor sit a little further out from their port, and a tap on a city picks the city even with a ship close by.

View file

@ -2602,6 +2602,7 @@
"link_modal.local_telecom_licence_included":"lokale Telekom-Lizenz inklusive",
"link_modal.needs_what_at_both_ends":"braucht {what} an beiden Enden",
"link_modal.new_diverse_route_40_survives_cuts":"Neue redundante Route <small>+40 % · übersteht Schnitte allein</small>",
"link_modal.no_circuit_crosses_between_north_and":"Zwischen Nord- und Südkorea gibt es keine Leitung, und kein Carrier verkauft dir eine. Pjöngjang erreicht die Welt über China und Russland.",
"link_modal.no_subsea_cable_lands_in_both":"Kein Seekabel landet sowohl in {a} als auch in {b} an. Kabel aus {a} erreichen {list}. Nimm den Weg über eine dieser Städte.",
"link_modal.no_subsea_cable_lands_in_city":"In {city} landet kein Seekabel an. Die nächste Landestation ist {near}: Verleg zuerst Glasfaser dorthin und nimm dann von dort ein Kabel.",
"link_modal.nobody_sells_capacity_between_kyiv":"Niemand verkauft Kapazität zwischen Kyjiw und Moskau, und niemand wird es tun. Route stattdessen über Warschau, Bukarest oder Helsinki.",

View file

@ -2600,6 +2600,7 @@
"link_modal.local_telecom_licence_included":"licencia de telecomunicaciones local incluida",
"link_modal.needs_what_at_both_ends":"necesita {what} en ambos extremos",
"link_modal.new_diverse_route_40_survives_cuts":"Ruta diversa nueva <small>+40 % · sobrevive a cortes sola</small>",
"link_modal.no_circuit_crosses_between_north_and":"Ningún circuito cruza entre Corea del Norte y Corea del Sur, y ningún operador te venderá uno. Pyongyang llega al mundo a través de China y Rusia.",
"link_modal.no_subsea_cable_lands_in_both":"Ningún cable submarino aterriza en {a} y {b} a la vez. Los cables de {a} llegan a {list}. Salta por uno de esos.",
"link_modal.no_subsea_cable_lands_in_city":"Ningún cable submarino aterriza en {city}. La estación de aterrizaje más cercana es {near}: tiende fibra hasta allí primero y luego toma un cable desde ella.",
"link_modal.nobody_sells_capacity_between_kyiv":"Nadie vende capacidad entre Kiev y Moscú, y nadie va a hacerlo. Rodea por Varsovia, Bucarest o Helsinki.",

View file

@ -2600,6 +2600,7 @@
"link_modal.local_telecom_licence_included":"licence télécom locale incluse",
"link_modal.needs_what_at_both_ends":"requiert {what} aux deux bouts",
"link_modal.new_diverse_route_40_survives_cuts":"Nouveau parcours diversifié <small>+40 % · survit seul aux coupures</small>",
"link_modal.no_circuit_crosses_between_north_and":"Aucun circuit ne passe entre la Corée du Nord et la Corée du Sud, et aucun opérateur ne t'en vendra un. Pyongyang rejoint le monde par la Chine et la Russie.",
"link_modal.no_subsea_cable_lands_in_both":"Aucun câble sous-marin n’atterrit à la fois à {a} et à {b}. Les câbles partant de {a} vont vers {list}. Fais escale dans l’une de ces villes.",
"link_modal.no_subsea_cable_lands_in_city":"Aucun câble sous-marin n’atterrit à {city}. La station d’atterrissement la plus proche est {near} : amène d’abord la fibre jusque-là, puis prends un câble depuis là-bas.",
"link_modal.nobody_sells_capacity_between_kyiv":"Personne ne vend de capacité entre Kyiv et Moscow, et personne ne le fera. Passe plutôt par Warsaw, Bucharest ou Helsinki.",

View file

@ -2600,6 +2600,7 @@
"link_modal.local_telecom_licence_included":"licenza telecom locale inclusa",
"link_modal.needs_what_at_both_ends":"serve {what} a entrambe le estremità",
"link_modal.new_diverse_route_40_survives_cuts":"Nuovo percorso diverso <small>+40% · sopravvive da solo ai tagli</small>",
"link_modal.no_circuit_crosses_between_north_and":"Nessun circuito attraversa il confine tra Corea del Nord e Corea del Sud, e nessun operatore te ne venderà uno. Pyongyang raggiunge il mondo attraverso Cina e Russia.",
"link_modal.no_subsea_cable_lands_in_both":"Nessun cavo sottomarino approda sia a {a} che a {b}. I cavi da {a} raggiungono: {list}. Fai tappa in una di queste.",
"link_modal.no_subsea_cable_lands_in_city":"Nessun cavo sottomarino approda a {city}. La stazione di approdo più vicina è {near}: porta prima la fibra fin lì, poi prendi un cavo da lì.",
"link_modal.nobody_sells_capacity_between_kyiv":"Nessuno vende capacità tra Kyiv e Moscow, e nessuno lo farà mai. Passa invece da Warsaw, Bucharest o Helsinki.",

View file

@ -2600,6 +2600,7 @@
"link_modal.local_telecom_licence_included":"licença de telecom local incluída",
"link_modal.needs_what_at_both_ends":"precisa de {what} nas duas pontas",
"link_modal.new_diverse_route_40_survives_cuts":"Nova rota diversa <small>+40% · sobrevive a cortes sozinha</small>",
"link_modal.no_circuit_crosses_between_north_and":"Nenhum circuito cruza entre a Coreia do Norte e a Coreia do Sul, e nenhuma operadora vai te vender um. Pyongyang chega ao mundo pela China e pela Rússia.",
"link_modal.no_subsea_cable_lands_in_both":"Nenhum cabo submarino desembarca em {a} e {b} ao mesmo tempo. Os cabos de {a} chegam a {list}. Faça um hop por um deles.",
"link_modal.no_subsea_cable_lands_in_city":"Nenhum cabo submarino chega a {city}. A estação de chegada mais próxima é {near}: leve fibra até lá primeiro e depois pegue um cabo de lá.",
"link_modal.nobody_sells_capacity_between_kyiv":"Ninguém vende capacidade entre Kyiv e Moscou, e ninguém vai vender. Passe por Varsóvia, Bucareste ou Helsinque.",

View file

@ -65,15 +65,16 @@ LANDS_LL.push(
{id:'sak',ll:[[142.34,47.26],[143.14,47.26],[143.14,46.66],[142.34,46.66]]},
);
// Places on a continent with no road or fiber in, only the sea: Juneau, Alaska's Arctic coast and Russia's Arctic and Kamchatka (#145).
// `on` is the land they are really part of: your own country may still dig to them over land (isSub()), nobody else's can.
LANDS_LL.push(
{id:'aks',hide:true,ll:[[-134.76,58.61],[-133.96,58.61],[-133.96,58.01],[-134.76,58.01]]},
{id:'swd',hide:true,ll:[[-165.78,64.82],[-164.98,64.82],[-164.98,64.22],[-165.78,64.22]]},
{id:'nsl',hide:true,ll:[[-157.15,71.58],[-156.35,71.58],[-156.35,70.98],[-157.15,70.98]]},
{id:'tay',hide:true,ll:[[80.25,73.81],[81.05,73.81],[81.05,73.21],[80.25,73.21]]},
{id:'lap',hide:true,ll:[[128.47,71.94],[129.27,71.94],[129.27,71.34],[128.47,71.34]]},
{id:'pvk',hide:true,ll:[[169.91,70.00],[170.71,70.00],[170.71,69.40],[169.91,69.40]]},
{id:'chu',hide:true,ll:[[177.05,65.05],[177.85,65.05],[177.85,64.45],[177.05,64.45]]},
{id:'kam',hide:true,ll:[[158.25,53.32],[159.05,53.32],[159.05,52.72],[158.25,52.72]]},
{id:'aks',hide:true,on:'am',ll:[[-134.76,58.61],[-133.96,58.61],[-133.96,58.01],[-134.76,58.01]]},
{id:'swd',hide:true,on:'am',ll:[[-165.78,64.82],[-164.98,64.82],[-164.98,64.22],[-165.78,64.22]]},
{id:'nsl',hide:true,on:'am',ll:[[-157.15,71.58],[-156.35,71.58],[-156.35,70.98],[-157.15,70.98]]},
{id:'tay',hide:true,on:'eu',ll:[[80.25,73.81],[81.05,73.81],[81.05,73.21],[80.25,73.21]]},
{id:'lap',hide:true,on:'eu',ll:[[128.47,71.94],[129.27,71.94],[129.27,71.34],[128.47,71.34]]},
{id:'pvk',hide:true,on:'eu',ll:[[169.91,70.00],[170.71,70.00],[170.71,69.40],[169.91,69.40]]},
{id:'chu',hide:true,on:'eu',ll:[[177.05,65.05],[177.85,65.05],[177.85,64.45],[177.05,64.45]]},
{id:'kam',hide:true,on:'eu',ll:[[158.25,53.32],[159.05,53.32],[159.05,52.72],[158.25,52.72]]},
);
// The Maldives.
LANDS_LL.push(
@ -84,13 +85,14 @@ LANDS_LL.push(
{id:'ceb',ll:[[123.3,11.3],[124.1,11.3],[124.1,9.4],[123.3,9.4]]},
{id:'mdn',ll:[[121.9,7],[123,8.4],[125.4,9.8],[126.6,7.5],[126.2,5.6],[125,5.6],[122,6.6]]},
);
// Greenland's towns and Iqaluit: no road between them, and no fiber over the ice, only the sea.
// Greenland's towns and Iqaluit: no road between them, and no fiber over the ice, only the sea. Greenland's towns share one
// island ('grl'), so Greenland may dig between them; Iqaluit is on Baffin Island.
LANDS_LL.push(
{id:'baf',hide:true,ll:[[-68.92,64.05],[-68.12,64.05],[-68.12,63.45],[-68.92,63.45]]},
{id:'gln',hide:true,ll:[[-52.12,64.48],[-51.32,64.48],[-51.32,63.88],[-52.12,63.88]]},
{id:'glq',hide:true,ll:[[-46.44,61.02],[-45.64,61.02],[-45.64,60.42],[-46.44,60.42]]},
{id:'gls',hide:true,ll:[[-54.07,67.24],[-53.27,67.24],[-53.27,66.64],[-54.07,66.64]]},
{id:'gla',hide:true,ll:[[-53.27,69.01],[-52.47,69.01],[-52.47,68.41],[-53.27,68.41]]},
{id:'gln',hide:true,on:'grl',ll:[[-52.12,64.48],[-51.32,64.48],[-51.32,63.88],[-52.12,63.88]]},
{id:'glq',hide:true,on:'grl',ll:[[-46.44,61.02],[-45.64,61.02],[-45.64,60.42],[-46.44,60.42]]},
{id:'gls',hide:true,on:'grl',ll:[[-54.07,67.24],[-53.27,67.24],[-53.27,66.64],[-54.07,66.64]]},
{id:'gla',hide:true,on:'grl',ll:[[-53.27,69.01],[-52.47,69.01],[-52.47,68.41],[-53.27,68.41]]},
);
// The eastern Caribbean capitals, each its own island, on ECFS and Southern Caribbean Fiber
LANDS_LL.push(

View file

@ -27,7 +27,11 @@ function kmBetween(a,b){const A=CITY[a],B=CITY[b];return Math.max(20,Math.round(
// Cities on a land bridge belong to two landmasses: Cairo reaches Asia overland across the Sinai, the way
// Istanbul does across the Bosporus (#47). Overland between continents still costs the intercontinental price.
const lands=C=>C.land2?[C.land,C.land2]:[C.land];
const isSub=(a,b)=>{const A=lands(CITY[a]),B=lands(CITY[b]);return !A.some(x=>B.includes(x));};
// On one landmass, so fiber can go overland: the same landmass, or two cities of one country on the land a no-road
// landmass is really part of (Pevek and Moscow, Juneau and Seattle, Nuuk and Sisimiut).
const LAND_ON=Object.fromEntries(LANDS_LL.filter(l=>l.on).map(l=>[l.id,l.on])),landOf=x=>LAND_ON[x]||x;
const overland=(A,B)=>{const P=lands(A),Q=lands(B);return P.some(x=>Q.includes(x))||A.cc===B.cc&&P.some(x=>Q.some(y=>landOf(x)===landOf(y)));};
const isSub=(a,b)=>!overland(CITY[a],CITY[b]);
const popUp=c=>S.pops[c]&&!(S.pops[c].down>S.day);
const regionsCount=()=>new Set(Object.keys(S.pops).map(c=>CITY[c].reg)).size;
const ixCity=x=>String(x).split('~')[0];

View file

@ -43,10 +43,11 @@ function diversityPossible(a,b,state=S){
links were added, as a graph built from a list of them would. */
const cities=CITIES.filter(c=>!(rules.banCities||[]).includes(c.id)).map(c=>c.id),N=cities.length,ix=new Map(cities.map((c,i)=>[c,i]));
const cab=new Map();for(const c of CABLE_PAIRS){const k=c.a<c.b?c.a+'|'+c.b:c.b+'|'+c.a;let L=cab.get(k);if(!L)cab.set(k,L=[]);L.push(c);}
const LS=cities.map(c=>lands(CITY[c])),land=cities.map(landing),cn=cities.map(cnCity),fab=cities.map(c=>FABS.filter(f=>f.cities.includes(c))),ban=rules.banPairs||[];
const land=cities.map(landing),cn=cities.map(cnCity),fab=cities.map(c=>FABS.filter(f=>f.cities.includes(c))),ban=rules.banPairs||[];
const adj=cities.map(()=>[]),grp=new Map();let n=0,k=0;const add=(i,j,g)=>{let r;if(g===undefined)r=k++;else{r=grp.get(g);if(r===undefined)grp.set(g,r=k++);}adj[i].push(j,r);adj[j].push(i,r);n++;};
for(let i=0;i<N;i++)for(let j=i+1;j<N;j++){
const a=cities[i],b=cities[j],cs=cab.get(a<b?a+'|'+b:b+'|'+a),sub=!LS[i].some(x=>LS[j].includes(x));
const a=cities[i],b=cities[j],cs=cab.get(a<b?a+'|'+b:b+'|'+a),sub=!overland(CITY[a],CITY[b]);
if(noTalk(a,b))continue;
if(!sub){add(i,j);add(i,j);}
if(cs)for(const c of cs)if(!ban.some(p=>p===c.cid+':'+a+'-'+b||p===c.cid+':'+b+'-'+a))add(i,j,'cab:'+c.cid);
if(state.won&&land[i]&&land[j]&&(sub||cs)&&!cn[i]&&!cn[j])add(i,j);

View file

@ -10,6 +10,9 @@ function regionMult(c){const C=CITY[c];if(!C||C.cn)return 1;if(C.kr)return KR_TR
// What a home pays, against the usual bill.
const arpuOf=c=>CITY[c].arpu||(CITY[c].kr&&scnRule('sender')?KR_ARPU:1);
const netMult=(n,c)=>regionMult(c)*((n&&n.far&&CITY[c]&&n.far[CITY[c].reg])||1);
// Pairs nobody sells a circuit between, whoever builds it: two cities, or two countries (codes in capitals).
const NO_TALK=[['kyv','mos',N_('link_modal.nobody_sells_capacity_between_kyiv')],['KP','KR',N_('link_modal.no_circuit_crosses_between_north_and')]];
const noTalk=(a,b)=>{const A=[a,CITY[a].cc],B=[b,CITY[b].cc],t=NO_TALK.find(([x,y])=>A.includes(x)&&B.includes(y)||A.includes(y)&&B.includes(x));return t?t[2]:'';};
const uaePair=(a,b)=>!!CITY[a].uae&&!!CITY[b].uae;
const rainPair=(a,b)=>!!(CITY[a].rain||CITY[b].rain);
// Every city has a country (cc), but the border toll is Africa's: elsewhere a wave crosses borders at the plain price.
@ -22,10 +25,11 @@ const andesPair=(a,b)=>!!CITY[a].andes&&!!CITY[b].andes&&CITY[a].andes!==CITY[b]
let ANCHOR_P=null;const anchorPair=l=>(ANCHOR_P||(ANCHOR_P=new Set(CABLE_PAIRS.filter(p=>CAB[p.cid]&&CAB[p.cid].anchor).map(p=>edgeKey(p))))).has(edgeKey(l));
/* Overland between continents (Europe to the Middle East and Asia) crosses a dozen borders and as many
carriers, each taking a cut: in real life it costs ten times the subsea route or more (#40). */
const LAND_X=45,landX=(a,b)=>!isSub(a,b)&&CITY[a].reg!==CITY[b].reg;
// Overland between continents is dear and DIY is out, except inside one country (Moscow–Vladivostok, Istanbul–Ankara).
const LAND_X=45,landX=(a,b)=>!isSub(a,b)&&CITY[a].reg!==CITY[b].reg&&CITY[a].cc!==CITY[b].cc;
function landMult(a,b){if(isSub(a,b))return 1;if(uaePair(a,b))return 3;return (landX(a,b)?LAND_X:1)*(andesPair(a,b)?2:1)*(nullPair(a,b)?NULLARBOR:1)*(rainPair(a,b)?2:1)*(borderPair(a,b)?2:1);}
function landWhy(a,b){if(isSub(a,b))return '';if(uaePair(a,b))return tr('geography_and_latency.inside_the_uae_only_the_two');
const r=[];if(CITY[a].reg!==CITY[b].reg)r.push(tr('geography_and_latency.overland_between_continents_crosses',{x:LAND_X}));if(andesPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_the_andes_2'));if(nullPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_the_nullarbor_x',{x:NULLARBOR}));if(borderPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_a_border_in'));if(rainPair(a,b))r.push(tr('geography_and_latency.this_route_goes_into_the_amazon'));return r.join(' ');}
const r=[];if(landX(a,b))r.push(tr('geography_and_latency.overland_between_continents_crosses',{x:LAND_X}));if(andesPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_the_andes_2'));if(nullPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_the_nullarbor_x',{x:NULLARBOR}));if(borderPair(a,b))r.push(tr('geography_and_latency.this_route_crosses_a_border_in'));if(rainPair(a,b))r.push(tr('geography_and_latency.this_route_goes_into_the_amazon'));return r.join(' ');}
function linkLat(l){const f=l.kind==='df'?(l.own?(l.sub?seaLatencyFactor(l):1.1):1.25):l.kind==='vxc'?1.4:l.cable?(CAB[l.cable].lat||1):1.3;return l.km*f/200;}
/* Wave prices differ a lot by market (TeleGeography): Europe's dense, competitive metro and
long-haul routes are cheap (Frankfurt–London 100G ≈ $1,150/mo), the US costs more, and
@ -51,14 +55,14 @@ function viaSeg(a,b){const cabs=cablesOk(a,b),sub=isSub(a,b);if(!cabs.length)ret
return `<h4 class="sub4">${tr('common.route')}</h4><div class="seg">${opts.map(o=>btn(o.l,'via',{v:o.v},wr&&wr.via===o.v?'pink':'ghost')).join('')}</div>${wr&&wr.cab?`<p class="note">${esc(CAB[wr.cab].blurb)} ${tr('geography_and_latency.all_your_waves_on_one_cable')}</p>`:''}`;}
function bestLat(a,b,f){const ls=S.links.filter(l=>!linkDown(l)&&(!f||f(l)));const dist={[a]:0},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]<ud){u=k;ud=dist[k];}if(u===null)break;if(u===b)return ud;done.add(u);for(const l of ls){if(l.a!==u&&l.b!==u)continue;const v=l.a===u?l.b:l.a,nd=ud+linkLat(l)+0.05;if(nd<(dist[v]??Infinity))dist[v]=nd;}}return Infinity;}
// The lowest one-way latency anything you could build gets between two cities (#273), the way bestLat() adds it up:
// your own fiber over land (×1.1), or the route of a cable that lands at both ends (your own cable in the low-latency
// your own fiber over land (×1.1, wherever isSub() allows it), or the route of a cable that lands at both ends (your own cable in the low-latency
// design follows it at 0.9 or better). A sea route that no cable takes needs a survey, so it does not count.
// Built from the map alone, so it is worked out once per city.
const LATF=new Map();let LATC=null;
function latFloor(a,b){let D=LATF.get(a);if(!D){LATF.set(a,D=latFloor0(a));}return D[CIDX[b]];}
function latFloor0(a){const n=CITIES.length,D=new Float64Array(n).fill(Infinity),done=new Uint8Array(n);
if(!LATC){LATC=new Map();for(const c of CABLE_PAIRS){const k=Math.min(CIDX[c.a],CIDX[c.b])*4096+Math.max(CIDX[c.a],CIDX[c.b]),w=c.km*Math.min(0.9,CAB[c.cid].lat||1);if(!(LATC.get(k)<=w))LATC.set(k,w);}}
D[CIDX[a]]=0;for(;;){let u=-1,ud=Infinity;for(let i=0;i<n;i++)if(!done[i]&&D[i]<ud){u=i;ud=D[i];}if(u<0)break;done[u]=1;const U=CITIES[u],LU=lands(U);
D[CIDX[a]]=0;for(;;){let u=-1,ud=Infinity;for(let i=0;i<n;i++)if(!done[i]&&D[i]<ud){u=i;ud=D[i];}if(u<0)break;done[u]=1;const U=CITIES[u];
for(let i=0;i<n;i++){if(done[i])continue;const V=CITIES[i],cw=LATC.get(Math.min(u,i)*4096+Math.max(u,i));
let w=lands(V).some(x=>LU.includes(x))?kmBetween(U.id,V.id)*1.1:Infinity;if(cw<w)w=cw;if(w<Infinity){const d=ud+w/200+0.05;if(d<D[i])D[i]=d;}}}
let w=overland(U,V)&&!noTalk(U.id,V.id)?kmBetween(U.id,V.id)*1.1:Infinity;if(cw<w)w=cw;if(w<Infinity){const d=ud+w/200+0.05;if(d<D[i])D[i]=d;}}}
return D;}

View file

@ -14,7 +14,7 @@ Object.assign(ACT,{
myIxUp:({city})=>{const m=S.myIx[city];if(!m)return;const f=(m.fab|0)+1,N=MYIX_FAB[f];if(!N)return;if(N.lvl>lvl()){toast(tr('links.a_fab_fabric_unlocks_at_customer',{fab:N.n,lv:N.lvl}),'bad');sfx('err');return;}if(!spend(N.cost))return;m.fab=f;toast(tr('links.ix_now_runs_a_fab_fabric',{ix:esc(m.name),fab:N.n,max:N.max}),'good');m.next=Math.min(m.next,S.day+3);after();},
foundIx:({city})=>{if(!S.pops[city]||S.myIx[city]||CITY[city].ix||CITY[city].cn)return;if(!spend(MYIX_COST))return;const nm=(S.name.split(' ')[0]||'My').replace(/[^A-Za-z0-9]/g,'').slice(0,10)+'-IX '+CITY[city].name;
S.myIx[city]={name:nm,members:[],next:S.day+4};S.ixp[city]=2;toast(tr('links.you_founded_ix_networks_will_join',{ix:esc(nm)}),'goal');after();},
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p)return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
buildLink:({tier})=>{tier=+tier;const p=UI.pending;if(!p||noTalk(p.a,p.b))return;const {a,b}=p;const km=kmBetween(a,b),sub=isSub(a,b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc'),jn=sib.length?routeJoin(a,b):null,same=!!jn,border=cnCity(a)!==cnCity(b),mult=(sib.length&&!(jn&&jn.k===(landTrenches(a,b)[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);
if((cnCity(a)||cnCity(b))&&!cnOk())return;
if(!waveOk(a,b,tier)){toast(tr('links.a_wave_wave_needs_need_at',{wave:LT[tier].n,need:esc(waveNeed(tier))}),'bad');sfx('err');return;}
const wr=waveRoute(a,b,mult,border);if(!wr){toast(tr('links.no_cable_available_for_that_route'),'bad');sfx('err');return;}
@ -26,7 +26,7 @@ Object.assign(ACT,{
buyNni:({city,prov,tier})=>{tier=+tier;if(!NNI[tier]||!isCity(city)||!own(FAB,prov)||!FAB[prov].cities.includes(city)||!S.pops[city])return;const ex=nniPort(city,prov);if(ex&&tier<=ex.tier)return;if(!ex&&!portGate(city,1))return;if(ex&&nniUsed(city,prov)>NNI[tier].g){toast(tr('links.too_many_circuits_for_a_smaller'),'bad');return;}if(!spend(NNI[tier].mo))return;if(ex)ex.tier=tier;else S.nni.push({id:uid(),city,prov,tier});toast(tr('links.fab_port_is_up_in_city',{fab:esc(FAB[prov].name),city:CITY[city].name}),'good');after();},
rmNni:({city,prov})=>{if(nniUsed(city,prov)>0){toast(tr('links.cancel_the_circuits_on_this_port'),'bad');sfx('err');return;}S.nni=S.nni.filter(x=>!(x.city===city&&x.prov===prov));after();},
openVxc:(a)=>openVxcModal(a),
buyVxc:({a,b,prov,t})=>{t=+t;const g=VXC[t].g,pa=nniPort(a,prov);if(!pa||nniUsed(a,prov)+g>NNI[pa.tier].g){toast(tr('links.not_enough_room_on_your_fabric'),'bad');sfx('err');return;}
buyVxc:({a,b,prov,t})=>{t=+t;if(!CITY[a]||!CITY[b]||noTalk(a,b))return;const g=VXC[t].g,pa=nniPort(a,prov);if(!pa||nniUsed(a,prov)+g>NNI[pa.tier].g){toast(tr('links.not_enough_room_on_your_fabric'),'bad');sfx('err');return;}
if(S.pops[b]){const pb=nniPort(b,prov);if(!pb||nniUsed(b,prov)+g>NNI[pb.tier].g){toast(tr('links.not_enough_room_on_your_fab',{fab:esc(FAB[prov].name),city:CITY[b].name}),'bad');sfx('err');return;}}
const km=kmBetween(a,b),sub=isSub(a,b),mo=vxcMo(km,sub,t);if(!spend(mo))return;S.links.push({id:uid(),a,b,kind:'vxc',prov,vt:t,km,sub,mo,cut:0,day:S.day});closeModal();
toast(tr('links.circuit_up_in_59_seconds_vxc',{vxc:VXC[t].n,fab:esc(FAB[prov].name),a:CITY[a].name,b:CITY[b].name})+(S.pops[b]?'':' '+tr('links.now_grab_an_ix_port_there')),'good');if(!S.pops[b])selectCity(b);after();},

View file

@ -7,14 +7,14 @@ Object.assign(ACT,{
ownCab:()=>{UI.lmode='df';UI.dfSrc='cable';UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
dfSrc:({v})=>{UI.dfSrc=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
dfSys:({v})=>{UI.dfSys=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);},
orderCable:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(ownCabWhy(a,b))return;const design=own(SEA_DESIGNS,UI.seaDesign)?UI.seaDesign:'standard',up=seaUps(seaQuote(a,b,design).km),q=seaQuote(a,b,design,up),km=q.km,cost=q.cost+(S.pops[b]?0:popCost(b));if(seaLack(km,up).length||!spend(cost))return;
orderCable:()=>{const p=UI.pending;if(!p||noTalk(p.a,p.b))return;const {a,b}=p;if(ownCabWhy(a,b))return;const design=own(SEA_DESIGNS,UI.seaDesign)?UI.seaDesign:'standard',up=seaUps(seaQuote(a,b,design).km),q=seaQuote(a,b,design,up),km=q.km,cost=q.cost+(S.pops[b]?0:popCost(b));if(seaLack(km,up).length||!spend(cost))return;
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}
const used=new Set(S.links.map(l=>l.cname).filter(Boolean)),cname=OWNCAB_NAMES.find(n=>!used.has(n))||`${pick(OWNCAB_NAMES)} ${used.size+1}`,id=uid(),ship=layName({id}),days=q.days;
S.links.push({id,a,b,kind:'df',own:true,sub:true,seaDesign:design,seaPath:q.pts.map(p=>p.slice()),sys:'roadm',ch:[],km,cable:null,cname,mo:Math.round(km*OWNCAB_OM),trench:'own:'+id,cut:0,day:S.day,ready:S.day+days,spares:false,pairs:1});
const laid=S.links[S.links.length-1];laid.paid=q.cost;for(const k of Object.keys(SUB_UPGRADES))if(up[k])laid['sub'+k]=laid.ready;UI.seaDesign='standard';UI.seaterminal=UI.seaengineering=false;
S.stats.ownCab=(S.stats.ownCab||0)+1;UI.dfSrc='lease';closeModal();UI.sel={type:'link',id};
toast(tr('fiber_and_hardware.the_ship_sets_sail_name_your',{ship,name:cname,km:km.toLocaleString(),a:CITY[a].name,b:CITY[b].name,n:days}),'goal');sfx('build');after();},
orderDf:()=>{const p=UI.pending;if(!p)return;const {a,b}=p;if(!dfAllowed(a,b))return;const sc=isSub(a,b)?subDfCable(a,b):null,km=sc?sc.km:kmBetween(a,b);
orderDf:()=>{const p=UI.pending;if(!p||noTalk(p.a,p.b))return;const {a,b}=p;if(!dfAllowed(a,b))return;const sc=isSub(a,b)?subDfCable(a,b):null,km=sc?sc.km:kmBetween(a,b);
const own=UI.dfSrc==='build'&&!sc,sys=DF_SYS[UI.dfSys]&&techOk('sys',UI.dfSys,DF_SYS[UI.dfSys].lvl)?UI.dfSys:'lite';if(lvl()<2)return;
const up=(own?digCost(km):0)+sysCost(sys)+ampCount(km)*AMP_COST+(S.pops[b]?0:popCost(b));if(!spend(up))return;
if(!S.pops[b]){S.pops[b]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};popStdApply(b);}

View file

@ -8,7 +8,7 @@ function pairLinks(a,b){return S.links.filter(l=>(l.a===a&&l.b===b)||(l.a===b&&l
function prunePairMet(){const m=S.pairMet;if(!m)return;const k=new Set(S.links.map(edgeKey));for(const x of Object.keys(m))if(!k.has(x))delete m[x];}
// Short, busy subsea routes (London–Amsterdam, London–Paris) sell dark fiber pairs too.
function subDfCable(a,b){return cablesOk(a,b).filter(c=>CAB[c.cid].df).sort((x,y)=>x.km-y.km)[0]||null;}
function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)===cnCity(b)&&!uaePair(a,b)&&!landX(a,b);}
function dfAllowed(a,b){if(noTalk(a,b))return false;if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)===cnCity(b)&&!uaePair(a,b)&&!landX(a,b);}
/* Optics you unplug go on a spares shelf instead of in the bin (#45): the next channel of that type uses a spare
for free (only the regen sites' transponders are new), or you sell it on eBuy for part of the price. */
const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE);

View file

@ -1,5 +1,5 @@
function openLinkModal(a,b){
if([a,b].includes('kyv')&&[a,b].includes('mos')){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('common.not_happening')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="lead" style="margin-top:8px">${tr('link_modal.nobody_sells_capacity_between_kyiv')}</p>`);return;}
{const nt=noTalk(a,b);if(nt){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('common.not_happening')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="lead" style="margin-top:8px">${tr(nt)}</p>`);return;}}
if((cnCity(a)||cnCity(b))&&!cnOk()){openModal(`<div style="display:flex;align-items:center"><h2 style="font-size:24px">${tr('link_modal.not_without_a_license')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="lead" style="margin-top:8px">${tr('link_modal.building_into_mainland_china_needs_a',{city:CITY[cnCity(a)?a:b].name})}</p>`);return;}
let route='';UI.pending={a,b};const km=kmBetween(a,b),sub=isSub(a,b),pop=S.pops[b]?0:newPopCost(b),sib=pairLinks(a,b).filter(l=>l.kind!=='vxc');
if(!sib.length)UI.route='diverse';const border=cnCity(a)!==cnCity(b),jn=sib.length?routeJoin(a,b):null,ts=landTrenches(a,b),mult=(sib.length&&!(jn&&jn.k===(ts[0]||{}).k)?DIVERSE:1)*(border?3*(UI.cnPrem&&(a==='hkg'||b==='hkg')?1.6:1):1);

View file

@ -2601,6 +2601,7 @@
"link_modal.local_telecom_licence_included":"local telecom licence included",
"link_modal.needs_what_at_both_ends":"needs {what} at both ends",
"link_modal.new_diverse_route_40_survives_cuts":"New diverse route <small>+40% · survives cuts alone</small>",
"link_modal.no_circuit_crosses_between_north_and":"No circuit crosses between North and South Korea, and no carrier will sell you one. Pyongyang reaches the world through China and Russia.",
"link_modal.no_subsea_cable_lands_in_both":"No subsea cable lands in both {a} and {b}. Cables from {a} reach {list}. Hop through one of those.",
"link_modal.no_subsea_cable_lands_in_city":"No subsea cable lands in {city}. The nearest landing station is {near}: run fiber there first, then take a cable from it.",
"link_modal.nobody_sells_capacity_between_kyiv":"Nobody sells capacity between Kyiv and Moscow, and nobody is going to. Route through Warsaw, Bucharest or Helsinki instead.",

View file

@ -0,0 +1,51 @@
// Fiber over land inside one country: cities on land with no road in (Russia's Arctic and Kamchatka, Alaska, Greenland's
// towns) can be dug to from the rest of their own country, and only their own. North and South Korea, like Kyiv and
// Moscow, get no circuit between them at all.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const start = "ACT.start({});S.cash=1e9;S.lvl=13;S.nextFail=S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;";
test('cities of one country on one piece of land can build terrestrial fiber between them', () => {
const { ev, errors } = load();
ev(start);
for (const [a, b, why] of [['pvs', 'dyr', 'Pevek–Anadyr, both Chukotka'], ['pvs', 'mos', 'Pevek–Moscow, across Russia'], ['pkc', 'vvo', 'Kamchatka–Vladivostok'],
['jnu', 'sea', 'Juneau–Seattle, both US'], ['brw', 'ome', "Alaska's Arctic coast"], ['nuk', 'sis', "Greenland's towns, one island"]]) {
assert.equal(ev(`isSub('${a}','${b}')`), false, `${why}: over land`);
assert.equal(ev(`dfAllowed('${a}','${b}')`), true, `${why}: dark fiber can be built`);
assert.equal(ev(`landMult('${a}','${b}')`) < 45, true, `${why}: not priced as a crossing between continents`);
}
ev("UI.lmode='wave';openLinkModal('pvs','dyr')");
assert.match(ev("document.getElementById('modalCard').textContent"), /Terrestrial/);
assert.deepEqual(errors, []);
});
test('only inside the country: islands and other countries stay across the sea', () => {
const { ev, errors } = load();
ev(start);
for (const [a, b, why] of [['jnu', 'van', 'Juneau–Vancouver: a border'], ['yfb', 'mtl', 'Iqaluit is on Baffin Island'], ['pkc', 'uus', 'Sakhalin is an island'],
['ome', 'vvo', 'Nome–Vladivostok: two countries'], ['hnl', 'sea', 'Hawaii']]) {
assert.equal(ev(`isSub('${a}','${b}')`), true, why);
}
assert.equal(ev("landMult('ist','esb')") < 45, true, 'Istanbul–Ankara is one country, not two continents');
assert.deepEqual(errors, []);
});
test('no circuit of any kind between North and South Korea, and still none between Kyiv and Moscow', () => {
const { ev, errors } = load();
ev(start + "ACT.launchBB({city:'icn'});S.pops.fnj={day:0,bb:null,boost:0,down:0,routers:1,gen:false,rgen:3};compute()");
for (const [a, b, msg] of [['icn', 'fnj', /North and South Korea/], ['fnj', 'icn', /North and South Korea/], ['kyv', 'mos', /Kyiv and Moscow/]]) {
ev(`UI.pending=null;openLinkModal('${a}','${b}')`);
assert.match(ev("document.getElementById('modalCard').textContent"), msg);
assert.equal(ev('UI.pending'), null, 'nothing to order');
assert.equal(ev(`dfAllowed('${a}','${b}')`), false);
}
// Even an action called directly (an agent, a stale window) builds nothing.
const n = ev('S.links.length');
ev("UI.pending={a:'icn',b:'fnj'};ACT.buildLink({tier:0});UI.pending={a:'icn',b:'fnj'};UI.dfSrc='build';ACT.orderDf();UI.pending={a:'icn',b:'fnj'};ACT.orderCable()");
assert.equal(ev('S.links.length'), n);
// Seoul and Pyongyang are still on one landmass, but a latency customer cannot count on a link between them.
assert.ok(ev("latFloor('icn','fnj')") > ev("latMaxOf('icn','fnj')"));
assert.deepEqual(errors, []);
});

View file

@ -92,7 +92,10 @@ test('Alaska and northern British Columbia: towns with no road in are islands, a
}
assert.equal(ev("isSub('anc','sea')"), false, 'Anchorage has a road south');
assert.equal(ev("isSub('prr','van')"), false, 'so does Prince Rupert');
for (const c of ['jnu', 'ome', 'brw', 'dut']) assert.ok(ev(`isSub('${c}','anc')`), `${c}: no road in, only the sea`);
// No road in, but US soil joined to Anchorage: a US network may dig there. Unalaska is an island.
for (const c of ['jnu', 'ome', 'brw']) assert.equal(ev(`isSub('${c}','anc')`), false, `${c}: overland inside the US`);
assert.ok(ev("isSub('dut','anc')"), 'dut: an island, only the sea');
assert.ok(ev("isSub('jnu','van')"), 'Juneau to Canada: a border, so only the sea');
assert.ok(lands(ev, 'qtl', 'ome', 'brw') && lands(ev, 'qtl', 'brw', 'anc') && lands(ev, 'aleu', 'anc', 'dut') && lands(ev, 'topaz', 'van', 'tok'));
assert.equal(ev('CAB.qtl.fragile'), true, 'sea ice keeps the repair ships away');
assert.equal(ev('CITY.anc.ix.length>0'), true, 'Anchorage has its exchange');
@ -120,8 +123,9 @@ test("Russia's Arctic and Pacific: government boxes, real cables only, beaches w
// nothing crosses the Bering Strait
assert.equal(ev("CABLE_PAIRS.some(p=>CITY[p.a].ru!==CITY[p.b].ru&&(CITY[p.a].cc==='US'||CITY[p.b].cc==='US'))"), false);
assert.equal(ev("isSub('dyr','anc')"), true);
// Kamchatka has no road to the rest of Russia; Magadan and Vladivostok do
assert.equal(ev("isSub('pkc','vvo')"), true);
// Kamchatka has no road to the rest of Russia, but it is Russian soil: a Russian route may dig there. Sakhalin is an island.
assert.equal(ev("isSub('pkc','vvo')"), false);
assert.equal(ev("isSub('uus','vvo')"), true);
assert.equal(ev("isSub('gdx','vvo')||isSub('mmk','mos')"), false);
assert.ok(ev("CITY.vvo.ix.length>0&&ixMembers('vvo').includes('mgf')&&ixMembers('vvo').includes('ert')"), 'the Vladivostok exchange');
// a sovereign-internet drill cuts the cable to Japan like any other border link

View file

@ -1,31 +1,39 @@
// #273: a latency offer only asks for a ceiling something you can build meets. Pevek–Anadyr is 635 km apart as the
// crow flies, but only a 1,717 km sea route joins them, so a 4.3 ms ceiling can never be met.
// #273: a latency offer only asks for a ceiling something you can build meets. Iqaluit and Nuuk are about 750 km apart
// as the crow flies, but no cable lands in Iqaluit and no road reaches it, so a 5.5 ms ceiling can never be met.
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
// Spawn many mars offers from a network at Pevek and Anadyr only: most are between the two.
// Spawn many mars offers from a network at two cities only: most are between the two.
const marsOnly = "eval('('+spawnOffer.toString().replace('const t=pick(types)',\"const t='mars'\")+')')";
const spawn = (ev, n) => ev(`(()=>{S.offers=[];const f=${marsOnly};for(let i=0;i<${n};i++)f();return JSON.stringify(S.offers.map(o=>[o.city,o.city2,o.latMax]));})()`);
const start = (ev, cities) => ev(`ACT.start({});S.cash=1e9;S.nextFail=1e9;S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;S.lvl=13;S.pops={};for(const c of ${JSON.stringify(cities)})S.pops[c]={day:0,bb:null,boost:0,down:0,routers:1,gen:false,rgen:0};compute()`);
test('#273 no latency offer between Pevek and Anadyr: no buildable path meets the straight-line ceiling', () => {
test('#273 no latency offer between Iqaluit and Nuuk: no buildable path meets the straight-line ceiling', () => {
const { ev, errors } = load();
start(ev, ['pvs', 'dyr']);
start(ev, ['yfb', 'nuk']);
assert.ok(ev('lvl()') >= 13, 'mars offers are unlocked');
assert.equal(ev("latMaxOf('pvs','dyr')"), 4.3);
const pair = o => [o[0], o[1]].sort().join('-') === 'dyr-pvs';
assert.equal(ev("latMaxOf('yfb','nuk')"), 5.5);
const pair = o => [o[0], o[1]].sort().join('-') === 'nuk-yfb';
const offers = JSON.parse(spawn(ev, 60));
assert.ok(offers.length > 0, 'mars offers still spawn');
assert.deepEqual(offers.filter(pair), [], 'but none asks for 4.3 ms between Pevek and Anadyr');
assert.ok(!(ev("latFloor('pvs','dyr')") <= 4.3), 'nothing on the map gets there in 4.3 ms');
// Even with the player's own Low latency cable, 7.7 ms is the best there is.
ev("S.links.push({id:'own1',a:'pvs',b:'dyr',kind:'df',own:true,sub:true,seaDesign:'express',sys:'roadm',ch:[],km:1717,cable:null,mo:1,trench:'own:own1',cut:0,day:0,ready:0,pairs:1});compute()");
assert.ok(ev("bestLat('pvs','dyr')") > 4.3);
assert.deepEqual(offers.filter(pair), [], 'but none asks for 5.5 ms between Iqaluit and Nuuk');
assert.ok(!(ev("latFloor('yfb','nuk')") <= 5.5), 'nothing on the map gets there in 5.5 ms');
// Even with the player's own Low latency cable round Baffin Island's coast, the best is above the ceiling.
ev("S.links.push({id:'own1',a:'yfb',b:'nuk',kind:'df',own:true,sub:true,seaDesign:'express',sys:'roadm',ch:[],km:1300,cable:null,mo:1,trench:'own:own1',cut:0,day:0,ready:0,pairs:1});compute()");
assert.ok(ev("bestLat('yfb','nuk')") > 5.5);
assert.deepEqual(JSON.parse(spawn(ev, 60)).filter(pair), []);
assert.deepEqual(errors, []);
});
test('#273 Pevek–Anadyr is Russian fiber over land now, so its 4.3 ms offers can be met and do come', () => {
const { ev, errors } = load();
start(ev, ['pvs', 'dyr']);
assert.ok(ev("latFloor('pvs','dyr')") <= ev("latMaxOf('pvs','dyr')"));
assert.ok(JSON.parse(spawn(ev, 60)).some(o => [o[0], o[1]].sort().join('-') === 'dyr-pvs'));
assert.deepEqual(errors, []);
});
test('#273 latency offers still come where a build meets the ceiling', () => {
const { ev, errors } = load();
start(ev, ['lon', 'nyc']);

View file

@ -10,7 +10,7 @@ test('diversity map: the indexed graph answers like disjointRoutes() over every
ev('ACT.start({})');
// The plain map: one record per possible link, in the order the indexed one adds them.
ev(`window.plainLinks=state=>{const rules=state.scn&&state.scn.rules||{},links=[],cities=CITIES.filter(c=>!(rules.banCities||[]).includes(c.id)).map(c=>c.id),add=(a,b,id)=>links.push({a,b,id});
for(let i=0;i<cities.length;i++)for(let j=i+1;j<cities.length;j++){const a=cities[i],b=cities[j];
for(let i=0;i<cities.length;i++)for(let j=i+1;j<cities.length;j++){const a=cities[i],b=cities[j];if(noTalk(a,b))continue;
if(!isSub(a,b)){add(a,b,'land:'+a+':'+b+':1');add(a,b,'land:'+a+':'+b+':2');}
for(const c of cablesFor(a,b))if(!(rules.banPairs||[]).some(p=>p===c.cid+':'+a+'-'+b||p===c.cid+':'+b+'-'+a))add(a,b,'cab:'+c.cid);
if(state.won&&seaCab(a,b)&&landing(a)&&landing(b)&&!cnCity(a)&&!cnCity(b))add(a,b,'own:'+a+':'+b);