diff --git a/site/i18n/de.js b/site/i18n/de.js index bcc98ff..94baf98 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -406,6 +406,7 @@ "businesses.cloud_gaming_platform":"Cloud-Gaming-Plattform", "businesses.cloud_gaming_platforms_and_the_cloud":"Cloud-Gaming-Plattformen, und die Cloud-Gaming-Ära: Privatkunden wollen weitere 15 %. Ein kostenloser PNI mit Tel-Mess. Hardware: Sienna-WaveMagic-3.2T-Transponder.", "businesses.cloud_on_ramp":"Cloud-On-Ramp", +"businesses.cruise_ship_connectivity":"Internet für Kreuzfahrtschiffe", "businesses.customer_on_a_fabric_transit_over":"Kunde auf einer Fabric (Transit über ein NNI)", "businesses.dark_fiber_pair_lease":"Miete eines Dark-Fiber-Paars", "businesses.dataset_ingest_elephant_flow":"Datensatz-Ingest (Elephant Flow)", @@ -416,12 +417,14 @@ "businesses.esports_world_final":"E-Sport-Weltfinale", "businesses.esports_world_finals_and_the_4k":"E-Sport-Weltfinals, und die Alles-in-4K-Ära: Privatkunden in jeder Stadt wollen 15 % mehr. Hardware: Sonic-the-Whitebox-64-Router.", "businesses.fabric_circuit_to_one_of_your":"Fabric-Verbindung zu einem deiner POPs", +"businesses.flywifi_airline_wi_fi":"WLAN an Bord im Himmel", "businesses.high_frequency_trading_link":"Hochfrequenzhandels-Link", "businesses.hundreds_of_fiber_pairs":"Hunderte Faserpaare", "businesses.internet_weather_system":"Internet-Wettersystem", "businesses.it_s_not_dns_there_s":"Es ist nicht DNS. Auf keinen Fall ist es DNS. Es war DNS.", "businesses.mars_mission_ground_station":"Bodenstation für die Marsmission", "businesses.mars_mission_ground_stations_gear":"Bodenstationen für die Marsmission. Hardware: The Router at the End of the Universe.", +"businesses.mars_mission_over_your_pies":"Mars-Mission über deine Pies", "businesses.metaverse_platforms_it_finally_took":"Metaverse-Plattformen (das Metaverse hat endlich abgehoben) und ein kostenloser PNI mit Etis-a-lot. Hardware: Arrrhipster-7800R5-Router, 102.4T-Fabrics für deinen eigenen Exchange.", "businesses.multi_site_training_run":"Standortübergreifender Trainingslauf", "businesses.peak_12_tbps_25_pops_5":"Spitzenlast 12 Tbps, 25 POPs, 5 Kontinente", @@ -437,6 +440,7 @@ "businesses.peak_6_tbps_15_pops_4":"Spitzenlast 6 Tbps, 15 POPs, 4 Kontinente", "businesses.peak_9_tbps_and_20_pops":"Spitzenlast 9 Tbps und 20 POPs", "businesses.people_phone_you_to_ask_if":"Leute rufen dich an und fragen, ob das Internet down ist. Du bist das Internet. Hast du schon versucht, dich aus- und wieder einzuschalten?", +"businesses.pizza_homes_and_boats_on_orbit":"Häuser und Boote am Pie-Terminal", "businesses.provedor_small_regional_isp":"Provedor (kleiner regionaler ISP)", "businesses.sd_wan_for_a_chain":"SD-WAN für eine Kette", "businesses.six_continent_carrier":"Carrier auf sechs Kontinenten", @@ -3406,6 +3410,7 @@ "pie.crust_line":"{alt} km · {n} von {full} Pies · {q} unterwegs · {p} abgedeckt", "pie.dish_note":"Eine Pie-Schüssel spricht mit den Pies über ihr. Sie braucht einen POP in ihrer Stadt und Landerechte in ihrem Land.", "pie.earned":"Aus dem Orbit verdient", +"pie.earned_mo":"Der Orbit bringt {amt}/Monat · {n} Schüsseln abseits vom Backbone tragen keinen Transit", "pie.factory":"Pie-Fabrik", "pie.factory_pitch":"Backt {m} Pies im Monat, für {mo} im Monat.", "pie.factory_stock":"{n} Pies im Regal · {m} im Monat", diff --git a/site/i18n/es.js b/site/i18n/es.js index d8239f3..312acfd 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -404,6 +404,7 @@ "businesses.cloud_gaming_platform":"Plataforma de juegos en la nube", "businesses.cloud_gaming_platforms_and_the_cloud":"Plataformas de juegos en la nube y la era del cloud gaming: los eyeballs quieren otro 15 %. Un PNI gratis con Tel-Mess. Equipo: transpondedores Sienna WaveMagic 3.2T.", "businesses.cloud_on_ramp":"Acceso a la nube", +"businesses.cruise_ship_connectivity":"Conectividad para cruceros", "businesses.customer_on_a_fabric_transit_over":"Cliente en una fabric (tránsito sobre un NNI)", "businesses.dark_fiber_pair_lease":"Alquiler de par de fibra oscura", "businesses.dataset_ingest_elephant_flow":"Ingesta de conjuntos de datos (elephant flow)", @@ -414,12 +415,14 @@ "businesses.esports_world_final":"Final mundial de esports", "businesses.esports_world_finals_and_the_4k":"Finales mundiales de esports y la era del 4K en todo: los eyeballs de cada ciudad quieren un 15 % más. Equipo: routers Sonic the Whitebox 64.", "businesses.fabric_circuit_to_one_of_your":"Circuito de fabric a uno de tus POPs", +"businesses.flywifi_airline_wi_fi":"Wi-Fi a bordo en el cielo", "businesses.high_frequency_trading_link":"Enlace de trading de alta frecuencia", "businesses.hundreds_of_fiber_pairs":"Cientos de pares de fibra", "businesses.internet_weather_system":"Sistema meteorológico de internet", "businesses.it_s_not_dns_there_s":"No es el DNS. Imposible que sea el DNS. Era el DNS.", "businesses.mars_mission_ground_station":"Estación terrestre de misión a Marte", "businesses.mars_mission_ground_stations_gear":"Estaciones terrestres de misiones a Marte. Equipo: El Router del Fin del Universo.", +"businesses.mars_mission_over_your_pies":"Misión a Marte por tus pies", "businesses.metaverse_platforms_it_finally_took":"Plataformas de metaverso (por fin despegó) y un PNI gratis con Etis-a-lot. Equipo: routers Arrrhipster 7800R5, fabrics de 102.4T para tu propio intercambio.", "businesses.multi_site_training_run":"Entrenamiento en varios sitios", "businesses.peak_12_tbps_25_pops_5":"pico de 12 Tbps, 25 POPs, 5 continentes", @@ -435,6 +438,7 @@ "businesses.peak_6_tbps_15_pops_4":"pico de 6 Tbps, 15 POPs, 4 continentes", "businesses.peak_9_tbps_and_20_pops":"pico de 9 Tbps y 20 POPs", "businesses.people_phone_you_to_ask_if":"La gente te llama para preguntar si internet está caído. Tú eres internet. ¿Has probado a apagarte y encenderte?", +"businesses.pizza_homes_and_boats_on_orbit":"Casas y barcos con un terminal pie", "businesses.provedor_small_regional_isp":"Provedor (pequeño ISP regional)", "businesses.sd_wan_for_a_chain":"SD-WAN para una cadena", "businesses.six_continent_carrier":"Operador de seis continentes", @@ -3404,6 +3408,7 @@ "pie.crust_line":"{alt} km · {n} de {full} tartas · {q} en camino · {p} de cobertura", "pie.dish_note":"Una antena-tarta habla con las tartas que pasan por encima. Necesita un POP en su ciudad y derechos de aterrizaje en su país.", "pie.earned":"Ganado desde la órbita", +"pie.earned_mo":"La órbita gana {amt}/mes · {n} antenas fuera del backbone no llevan tránsito", "pie.factory":"Fábrica de tartas", "pie.factory_pitch":"Hornea {m} tartas al mes, por {mo} al mes.", "pie.factory_stock":"{n} tartas en el almacén · {m} al mes", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index d509327..8bdca8c 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -404,6 +404,7 @@ "businesses.cloud_gaming_platform":"Plateforme de cloud gaming", "businesses.cloud_gaming_platforms_and_the_cloud":"Plateformes de cloud gaming, et l’ère du cloud gaming : les eyeballs veulent encore 15 % de plus. Un PNI gratuit avec Tel-Mess. Matos : transpondeurs Sienna WaveMagic 3.2T.", "businesses.cloud_on_ramp":"On-ramp cloud", +"businesses.cruise_ship_connectivity":"Connexion pour paquebots de croisière", "businesses.customer_on_a_fabric_transit_over":"Client sur un fabric (transit via un NNI)", "businesses.dark_fiber_pair_lease":"Location d’une paire de fibre noire", "businesses.dataset_ingest_elephant_flow":"Ingestion de dataset (elephant flow)", @@ -414,12 +415,14 @@ "businesses.esports_world_final":"Finale mondiale d’esport", "businesses.esports_world_finals_and_the_4k":"Finales mondiales d’esport, et l’ère du tout-4K : les eyeballs de chaque ville veulent 15 % de plus. Matos : routeurs Sonic the Whitebox 64.", "businesses.fabric_circuit_to_one_of_your":"Circuit fabric vers un de tes POP", +"businesses.flywifi_airline_wi_fi":"Wi-Fi à bord dans le ciel", "businesses.high_frequency_trading_link":"Lien de trading haute fréquence", "businesses.hundreds_of_fiber_pairs":"Des centaines de paires de fibre", "businesses.internet_weather_system":"Météo d’Internet", "businesses.it_s_not_dns_there_s":"Ce n’est pas le DNS. Impossible que ce soit le DNS. C’était le DNS.", "businesses.mars_mission_ground_station":"Station sol de mission martienne", "businesses.mars_mission_ground_stations_gear":"Stations sol de missions martiennes. Matos : The Router at the End of the Universe.", +"businesses.mars_mission_over_your_pies":"Mission martienne via tes pies", "businesses.metaverse_platforms_it_finally_took":"Plateformes de métavers (ça a fini par décoller), et un PNI gratuit avec Etis-a-lot. Matos : routeurs Arrrhipster 7800R5, fabrics de 102.4T pour ton propre IX.", "businesses.multi_site_training_run":"Entraînement multi-site", "businesses.peak_12_tbps_25_pops_5":"pic de 12 Tbps, 25 POP, 5 continents", @@ -435,6 +438,7 @@ "businesses.peak_6_tbps_15_pops_4":"pic de 6 Tbps, 15 POP, 4 continents", "businesses.peak_9_tbps_and_20_pops":"pic de 9 Tbps et 20 POP", "businesses.people_phone_you_to_ask_if":"Les gens t’appellent pour savoir si Internet est en panne. Internet, c’est toi. T’as essayé de t’éteindre et de te rallumer ?", +"businesses.pizza_homes_and_boats_on_orbit":"Maisons et bateaux sur un terminal pie", "businesses.provedor_small_regional_isp":"Provedor (petit FAI régional)", "businesses.sd_wan_for_a_chain":"SD-WAN pour une chaîne", "businesses.six_continent_carrier":"Opérateur des six continents", @@ -3404,6 +3408,7 @@ "pie.crust_line":"{alt} km · {n} sur {full} tartes · {q} en route · {p} couvert", "pie.dish_note":"Une antenne-tarte parle aux tartes au-dessus d'elle. Il lui faut un POP dans sa ville et des droits d'atterrissage dans son pays.", "pie.earned":"Gagné depuis l'orbite", +"pie.earned_mo":"L'orbite rapporte {amt}/mois · {n} paraboles hors du backbone ne portent aucun transit", "pie.factory":"Usine à tartes", "pie.factory_pitch":"Cuit {m} tartes par mois, pour {mo} par mois.", "pie.factory_stock":"{n} tartes en stock · {m} par mois", diff --git a/site/i18n/it.js b/site/i18n/it.js index 4610857..abb77b0 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -404,6 +404,7 @@ "businesses.cloud_gaming_platform":"Piattaforma di cloud gaming", "businesses.cloud_gaming_platforms_and_the_cloud":"Piattaforme di cloud gaming, e l'era del cloud gaming: gli eyeball vogliono un altro 15%. Un PNI gratuito con Tel-Mess. Gear: transponder Sienna WaveMagic 3.2T.", "businesses.cloud_on_ramp":"On-ramp cloud", +"businesses.cruise_ship_connectivity":"Connettività per navi da crociera", "businesses.customer_on_a_fabric_transit_over":"Cliente su un fabric (transit via NNI)", "businesses.dark_fiber_pair_lease":"Affitto coppia di dark fiber", "businesses.dataset_ingest_elephant_flow":"Ingest di dataset (elephant flow)", @@ -414,12 +415,14 @@ "businesses.esports_world_final":"Finale mondiale di esport", "businesses.esports_world_finals_and_the_4k":"Finali mondiali di esport, e l'era del 4K ovunque: gli eyeball di ogni città vogliono il 15% in più. Gear: router Sonic the Whitebox 64.", "businesses.fabric_circuit_to_one_of_your":"Circuito dal fabric verso uno dei tuoi POP", +"businesses.flywifi_airline_wi_fi":"Wi-Fi di bordo in volo", "businesses.high_frequency_trading_link":"Link per trader HFT", "businesses.hundreds_of_fiber_pairs":"Centinaia di coppie in fibra", "businesses.internet_weather_system":"Sistema meteorologico di internet", "businesses.it_s_not_dns_there_s":"Non è il DNS. Non può essere il DNS. Era il DNS.", "businesses.mars_mission_ground_station":"Stazione di terra per una missione su Marte", "businesses.mars_mission_ground_stations_gear":"Stazioni di terra per missioni su Marte. Gear: The Router at the End of the Universe.", +"businesses.mars_mission_over_your_pies":"Missione su Marte via i tuoi pie", "businesses.metaverse_platforms_it_finally_took":"Piattaforme metaverso (alla fine è decollato), e un PNI gratuito con Etis-a-lot. Gear: router Arrrhipster 7800R5, fabric da 102.4T per il tuo exchange.", "businesses.multi_site_training_run":"Training multi-sito", "businesses.peak_12_tbps_25_pops_5":"picco 12 Tbps, 25 POP, 5 continenti", @@ -435,6 +438,7 @@ "businesses.peak_6_tbps_15_pops_4":"picco 6 Tbps, 15 POP, 4 continenti", "businesses.peak_9_tbps_and_20_pops":"picco 9 Tbps e 20 POP", "businesses.people_phone_you_to_ask_if":"La gente ti chiama per chiedere se internet è giù. Internet sei tu. Hai provato a spegnerti e riaccenderti?", +"businesses.pizza_homes_and_boats_on_orbit":"Case e barche su un terminale pie", "businesses.provedor_small_regional_isp":"Provedor (piccolo ISP regionale)", "businesses.sd_wan_for_a_chain":"SD-WAN per una catena", "businesses.six_continent_carrier":"Carrier dei sei continenti", @@ -3404,6 +3408,7 @@ "pie.crust_line":"{alt} km · {n} di {full} torte · {q} in arrivo · {p} di copertura", "pie.dish_note":"Una parabola-torta parla con le torte sopra di lei. Le serve un POP nella sua città e i diritti di atterraggio nel suo paese.", "pie.earned":"Guadagnato dall'orbita", +"pie.earned_mo":"L'orbita rende {amt}/mese · {n} parabole fuori dal backbone non portano transito", "pie.factory":"Fabbrica di torte", "pie.factory_pitch":"Sforna {m} torte al mese, per {mo} al mese.", "pie.factory_stock":"{n} torte in magazzino · {m} al mese", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index bed57dc..78dddad 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -404,6 +404,7 @@ "businesses.cloud_gaming_platform":"Plataforma de cloud gaming", "businesses.cloud_gaming_platforms_and_the_cloud":"Plataformas de cloud gaming e a era do cloud gaming: os eyeballs querem mais 15%. Um PNI grátis com a Tel-Mess. Gear: transponders Sienna WaveMagic 3.2T.", "businesses.cloud_on_ramp":"On-ramp de cloud", +"businesses.cruise_ship_connectivity":"Conectividade para navios de cruzeiro", "businesses.customer_on_a_fabric_transit_over":"Cliente num fabric (transit via NNI)", "businesses.dark_fiber_pair_lease":"Aluguel de par de dark fiber", "businesses.dataset_ingest_elephant_flow":"Ingest de dataset (elephant flow)", @@ -414,12 +415,14 @@ "businesses.esports_world_final":"Final mundial de esports", "businesses.esports_world_finals_and_the_4k":"Finais mundiais de esports e a era do 4K em tudo: os eyeballs de cada cidade querem 15% a mais. Gear: routers Sonic the Whitebox 64.", "businesses.fabric_circuit_to_one_of_your":"Circuito de fabric até um dos seus POPs", +"businesses.flywifi_airline_wi_fi":"Wi-Fi de bordo no céu", "businesses.high_frequency_trading_link":"Link para trading HFT", "businesses.hundreds_of_fiber_pairs":"Centenas de pares de fibra", "businesses.internet_weather_system":"Sistema meteorológico da internet", "businesses.it_s_not_dns_there_s":"Não é DNS. Não tem como ser DNS. Era DNS.", "businesses.mars_mission_ground_station":"Estação terrestre de missão a Marte", "businesses.mars_mission_ground_stations_gear":"Estações terrestres de missões a Marte. Gear: The Router at the End of the Universe.", +"businesses.mars_mission_over_your_pies":"Missão a Marte pelos seus pies", "businesses.metaverse_platforms_it_finally_took":"Plataformas de metaverso (finalmente decolou) e um PNI grátis com a Etis-a-lot. Gear: routers Arrrhipster 7800R5, fabrics de 102.4T para o seu próprio exchange.", "businesses.multi_site_training_run":"Treino multi-site", "businesses.peak_12_tbps_25_pops_5":"pico de 12 Tbps, 25 POPs, 5 continentes", @@ -435,6 +438,7 @@ "businesses.peak_6_tbps_15_pops_4":"pico de 6 Tbps, 15 POPs, 4 continentes", "businesses.peak_9_tbps_and_20_pops":"pico de 9 Tbps e 20 POPs", "businesses.people_phone_you_to_ask_if":"As pessoas ligam para perguntar se a internet caiu. A internet é você. Já tentou se desligar e ligar de novo?", +"businesses.pizza_homes_and_boats_on_orbit":"Casas e barcos num terminal pie", "businesses.provedor_small_regional_isp":"Provedor (pequeno ISP regional)", "businesses.sd_wan_for_a_chain":"SD-WAN para uma rede de lojas", "businesses.six_continent_carrier":"Carrier dos seis continentes", @@ -3404,6 +3408,7 @@ "pie.crust_line":"{alt} km · {n} de {full} tortas · {q} a caminho · {p} de cobertura", "pie.dish_note":"Uma antena-torta conversa com as tortas lá em cima. Ela precisa de um POP na cidade e de direitos de pouso no país.", "pie.earned":"Ganho da órbita", +"pie.earned_mo":"A órbita rende {amt}/mês · {n} antenas fora do backbone não levam trânsito", "pie.factory":"Fábrica de tortas", "pie.factory_pitch":"Assa {m} tortas por mês, por {mo} ao mês.", "pie.factory_stock":"{n} tortas no estoque · {m} por mês", diff --git a/src/game/40-progress/10-businesses.js b/src/game/40-progress/10-businesses.js index a5965a6..e0027aa 100644 --- a/src/game/40-progress/10-businesses.js +++ b/src/game/40-progress/10-businesses.js @@ -30,6 +30,13 @@ const BIZ_T={ metav:{l:tr('common.metaverse_platform'),opts:[1600,3200,6400],rate:35,lv:9,names:['Meh-taverse','Second Second Life','Horizon Worlds Apart','The Oasis (Ready Player Done)','Legs Finally Shipped Inc.','Decentra-landlocked']}, agi:{l:tr('businesses.agi_lab_allegedly'),opts:[12800,25600],rate:0,l2:true,div:true,mega:true,km:0.4,lv:11,names:['Almost General Intelligence Inc.','Superintelligence Pending','The Lab That Said Two More Years','Paperclip Maximizer Labs','Deep Thought Two','Benevolent Overlord Research']}, mars:{l:tr('businesses.mars_mission_ground_station'),opts:[100,200,400],rate:0,l2:true,lat:true,km:4,lv:13,names:['Red Planet Relay','Ares Ground Segment','Olympus Mons Uplink','Mars or Bust Mission Control','Interplanetary Ping Society','Light-Minute Logistics','RFC 1149 Avian Carriers (Mars Division)']}, + // Orbit terminals (35-pie-paths.js): no POP of theirs, landed on a pie dish. Priced per Gbps of busy-hour capacity, which a + // satellite operator oversubscribes a hundred times (a hundred homes at $100 a month share one Gbps). + // share: the most of the sky's market (pieMarket()) that kind may hold; there are only so many airlines. + pizza:{l:tr('businesses.pizza_homes_and_boats_on_orbit'),opts:[50,100,200,400],rate:14000,orbit:true,lv:1,names:['Deep Dish Rural Broadband','Crust Mile Connect','Topping Off Telecom','Extra Cheese Islands Net','Slice of Life Homesteads','Calzone Ranch Wi-Fi','Thin Crust Tundra Net','Margherita Marina Moorings','Anchovy Atoll Online','Stuffed Crust Station Hands']}, + flywifi:{l:tr('businesses.flywifi_airline_wi_fi'),opts:[20,50,100,200],rate:24000,orbit:true,las:true,share:0.2,lv:1,names:['Jet Lag Wi-Fi','Wi-Fly Away','Seatback Streaming Co.','Tray Table Upright Telecom','Cabin Pressure Networks','Mile High Megabits','Overhead Bin Broadband','Turbulence Tolerant Transit']}, + boat:{l:tr('businesses.cruise_ship_connectivity'),opts:[100,200,400,800],rate:18000,orbit:true,lv:1,names:['Buffet Overboard Cruises','The Love Bandwidth','Poop Deck Packets','Midnight Buffet Mbps','Shuffleboard Shipping Lines','All-You-Can-Stream Cruises','Iceberg Ahead Voyages']}, + marsorb:{l:tr('businesses.mars_mission_over_your_pies'),opts:[50,100,200],rate:30000,orbit:true,las:true,share:0.05,lv:13,names:['Red Planet Relay (Orbital)','Olympus Mons Uplink (Orbital)','Light-Minute Logistics (Orbital)','Interplanetary Ping Society (Orbital)','Rover Over Pies']}, provedor:{l:tr('businesses.provedor_small_regional_isp'),opts:[5,10,20,40],rate:20,br:true,names:['Provedor Capivara Net','Fibra do Sertão','Rapidinho Telecom','Net Jabuticaba','Caipirinha Online','Wi-Fi do Zé','Pão de Queijo Fibra','Açaí Net','Tucano Telecom','Forró Fibra','Saci Net','Brigadeiro Banda Larga','Mandioca Online','Churrasco Connect']}, }; const LEVELS=[ diff --git a/src/game/80-simulation/30-compute.js b/src/game/80-simulation/30-compute.js index e51950e..10d02a2 100644 --- a/src/game/80-simulation/30-compute.js +++ b/src/game/80-simulation/30-compute.js @@ -39,6 +39,8 @@ function compute(){RW.gen++; // ALONE and the islands (COMP). Kept between calls while the graph is the same (29-route-cache.js). const wW=e=>e.w,wLat=e=>e.lat+0.05,RCON=RC.on,GK=RCON?rcGraphKey(pops,remote,EA):null, {SPD,SPP,SDi,SPi,ALONE,COMP,NCOMP}=rcGraph(GK,pops,adj,EA,NC,wW); + // Orbit (35-pie-paths.js): sky nodes and edges, after the IGP paths, which never use them. + const PX=S.pie?pieGraph(adj,edges,COMP,pops,NE):null;if(PX)NE=PX.ne; const ev=S.ev; const depeer=ev.depeer>day||scnRule('spat'), leak=ev.leak&&ev.leak.until>day?ev.leak.net:null; // Sender pays (Gangnam Style Peering): no carrier hands traffic to the Korean incumbents for you, only a paid PNI does. @@ -89,7 +91,7 @@ function compute(){RW.gen++; index FNJ[F] and has FREM[F] left to place. Gathered in FLB here, then copied into this call's own columns below. */ FLB.n=0;const NN=NETS.length,CNB=[],NCN=NETS.map(n=>!!n.cn),flow=(ci,j,rem,cache,bz)=>{const k=FLB.n;if(k===FLB.cap)flbGrow();FLB.rem[k]=rem;FLB.ci[k]=ci;FLB.nj[k]=j;FLB.ca[k]=cache?1:0;FLB.bz[k]=bz?1:0;FLB.n=k+1;}; // Customer demand per city, added up in S.biz order (what filtering S.biz for each city would give). - const bizBw={};for(const b of S.biz){const T=BIZ_T[b.type];if(!T.l2&&!T.fiber&&(!T.event||eventLive(b))){const v=bizBw[b.city];bizBw[b.city]=(v===undefined?0:v)+b.bw;}} + const bizBw={};for(const b of S.biz){const T=BIZ_T[b.type];if(!T.l2&&!T.fiber&&(!T.event||eventLive(b))){if(T.orbit){const g=PX&&PX.gs[b.id];if(g)bizBw[g]=(bizBw[g]||0)+PX.term[b.id];continue;}const v=bizBw[b.city];bizBw[b.city]=(v===undefined?0:v)+b.bw;}} // Traffic shares by network index, and their sums, for each share table (and with Russia's throttle). const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local'); (()=>{for(const c of Object.keys(S.pops)){ @@ -144,6 +146,7 @@ function compute(){RW.gen++; const disjointI=(A,B)=>{const a=CIDX[A],b=CIDX[B],p1=bfsI(a,b,null);return !!p1&&!!bfsI(a,b,new Set(p1.map(srlg)));}; for(const k in edges){const e=edges[k];let ld=0;for(const l of e.links)ld+=(R.load&&R.load[l.id])||0;e.pl=ld;} const l2Routes=(A,B,b)=>{const m=b.route||'normal',Ai=CIDX[A],Bi=CIDX[B]; + if(PX&&m==='fast')return pieFast(PX,fastSP,A,B,b,wLat); if(m!=='scenic')return [{...walkI(m==='fast'?(fastSP[A]||(fastSP[A]=dijkstra(adj,Ai,wLat))).P:SPP[A],Ai,Bi),share:1}]; const ek='l2:'+b.id,own=e=>(R.efg&&R.efg[e.id]&&R.efg[e.id].get(ek))||0; const wf=e=>e.w*(1+10*(e.cap?Math.max(0,e.pl-own(e))/e.cap:0)); @@ -345,13 +348,13 @@ function compute(){RW.gen++; for(const e of TORD){const m=R2.tNet[e.id]={},b=e.ts*NN;for(const j of TNK[e.ts])m[NET_IDS[j]]=TNA[b+j];} R2.peerShare=R2.served>0?R2.peered/R2.served:0; for(const e of E){if(e.k==='t')R2.useT[e.id]=(R2.useT[e.id]||0)+e.used;else if(e.k==='ix')R2.useIx[e.id]=e.used;else if(e.k==='p')R2.usePni[e.id]=e.used;else R2.useCache[e.id]=e.used;}})(); - computeMoney(R2); + computeMoney(R2,PX); // R.fl: from this call's own columns, made into objects only when something asks. flDefine(R2,{NF,FREM,FCI,FNJ,FCA,FBZ,FGT,FGI,FGP,FGH,FTI,FII,E,CNB,NCN}); R=R2;UI.hotMap=hotByCity(); } // What the network costs and earns per month, from what compute() routed. -function computeMoney(R2){ +function computeMoney(R2,PX=null){ const C=R2.cost,V=R2.rev,pm=S.priceMul; C.pops=Object.entries(S.pops).reduce((a,[c,p])=>a+popMo(c)+((p.routers||1)-1)*ROUTER_MO+cageMo(p.routers)+(p.routers||1)*RG[p.rgen||0].mo+(p.gen?GEN_MO:0),0); C.optical=S.links.filter(l=>l.kind==='df').reduce((a,l)=>a+(l.ready>S.day?0:ampCount(l.km)*AMP_MO*(l.own&&isRdm(l.sys)&&!l.sub?Math.max(1,l.pairs|0):1)+(l.regen|0)*REGEN_MO)+(l.spares?Math.round(150+(l.ch||[]).length*80):0),0); @@ -366,9 +369,10 @@ function computeMoney(R2){ if(S.pie&&S.mode!=='sandbox')C.pie=pieMo(); V.eyeballs=0;V.business=0;V.ix=0;V.grant=grantOn(R2)?GRANT_MO:0; C.wholesale=0;C.levy=0;const lev=scnRule('levy');for(const c in S.pops){const sf=sfOf(R2,c)*(R2.bbF[c]??1),v=R2.cityEye[c]*sf*EYE_RATE*arpuOf(c);V.eyeballs+=v;if(CITY[c].au){if(lev)C.levy+=v*AU_LEVY;else C.wholesale+=v*AU_WHOLESALE;}} - const ids=linkIds();for(const b of S.biz){if(capPend(b))continue;const sf=BIZ_T[b.type].fiber?(fiberOk(b,ids)?1:0):BIZ_T[b.type].l2?clamp((R2.l2[b.id]||0)/b.bw,0,1):sfOf(R2,b.city)*(R2.tgtF[b.id]??1);V.business+=b.bw*b.rate*Math.min(1,sf/0.95);} + const ids=linkIds();for(const b of S.biz){if(capPend(b)||BIZ_T[b.type].orbit)continue;const sf=BIZ_T[b.type].fiber?(fiberOk(b,ids)?1:0):BIZ_T[b.type].l2?clamp((R2.l2[b.id]||0)/b.bw,0,1):sfOf(R2,b.city)*(R2.tgtF[b.id]??1);V.business+=b.bw*b.rate*Math.min(1,sf/0.95);} for(const c in S.myIx)V.ix+=S.myIx[c].members.length*MYIX_FEE; - C.revshare=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity||l.bal>0?l.share||0:0),0)*(V.eyeballs+V.business+V.ix); + if(PX)pieMoney(PX,R2,V); + C.revshare=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity||l.bal>0?l.share||0:0),0)*(V.eyeballs+V.business+V.ix+(V.orbit||0)); R2.costMo=Object.values(C).reduce((a,b)=>a+b,0); - R2.revMo=V.eyeballs+V.business+V.ix+V.grant; + R2.revMo=V.eyeballs+V.business+V.ix+V.grant+(V.orbit||0); } diff --git a/src/game/80-simulation/35-pie-paths.js b/src/game/80-simulation/35-pie-paths.js new file mode 100644 index 0000000..588f06b --- /dev/null +++ b/src/game/80-simulation/35-pie-paths.js @@ -0,0 +1,77 @@ +/* ---------- Pie in the Sky: routing through orbit (rules O2-O4, docs/plans/pie-in-the-sky.md) ---------- + compute() calls pieGraph() once, only when S.pie exists (saves without it pay one falsy check). It adds to the + routing graph, after the IGP shortest paths are known: + - a sky node per connected pie dish (a virtual city index past NC), joined to its POP by an uplink edge: the dish's + antennas (x rain, jamming… from pieDishes()) less what its terminals use; latency one hop up, alt/c + 1 ms; + - with lasers (a crust >= 60% lasered), a space edge between every two sky nodes at least PIE_MIN_KM apart, priced + along the great circle at the shell's height at c in vacuum, capacity the crust's (g x coverage) left after terminals. + Orbit edges have IGP weight Infinity: bulk IP traffic and scenic circuits never see them, only latency-routed + circuits (lat:true customers, route 'fast') do, and only where the sky is faster. Space edges under 3,000 km do not + exist, so orbit never beats fiber there (O4). A dish whose POP is not on the backbone's island is flagged (R.pie.isl) + and gets no sky node: it carries no transit, only its own local terminals (O3). A half-baked crust (< 60%) is not a + hub and carries nothing (O2). + Terminal customers (BIZ_T[].orbit: pizza, flywifi, boat, marsorb) sit anywhere a baked crust covers, with no POP of + theirs; their traffic lands on a ground dish (bent pipe within PIE_BENT km, or lasers to any connected dish) and + enters the network there as business demand. Spats: pieSpatHome(cc) keeps a country's customers on its own dishes, + pieAirBlock(a,b) keeps country a's traffic off country b's dishes. */ +const PIE_C=300,PIE_RE=6371,PIE_MIN_KM=3000,PIE_BENT=1000,PIE_HOP=1,PIE_FOOT=3,PIE_LAT_PREM=0.5; +const pieKm=(a,b)=>{const A=CITY[a],B=CITY[b];return hav(A.lon,A.lat,B.lon,B.lat);}; +// Does crust id cover city c? A shell reaches a few degrees past its inclination; a polar one reaches everywhere. +const pieCovers=(id,c)=>!!CRUSTS[id].polar||Math.abs(CITY[c].lat)<=CRUSTS[id].inc+PIE_FOOT; +const pieLased=id=>pieLiveLas(id)>=CRUSTS[id].full*PIE_BAKED; +// One way through space between two dishes km apart, at shell height alt: up, along the great circle, down. +const pieSkyMs=(km,alt)=>2*(alt/PIE_C+PIE_HOP)+km*(PIE_RE+alt)/PIE_RE/PIE_C; +// May a customer in country ca land on a dish in country dc? (spats) +const pieLandOk=(ca,dc)=>!(pieSpatHome(ca)&&dc!==ca)&&!pieAirBlock(ca,dc); +/* Where a terminal customer in city c lands: {k (index in ds), cr} or null. ds: dishes with .ok (on the backbone). + The nearest dish with room left that a baked crust over c also covers: within PIE_BENT km (bent pipe, any dish), else with lasers on that + crust any dish on the backbone. Some customers need lasers (flywifi, marsorb: T.las). */ +function pieLand(c,t,ds,hubs){const T=BIZ_T[t],cc=CITY[c].cc;let best=null,bk=Infinity; + for(const id of hubs){if(!pieCovers(id,c))continue;const las=pieLased(id);if(T.las&&!las)continue; + for(let k=0;k0&&(km<=PIE_BENT||(las&&d.ok))){const v=km+(d.ok?0:1);if(v=0)cnt.set(k,(cnt.get(k)||0)+1);} + let main=-1,mn=0;const hk=S.home&&S.pops[S.home]?COMP[CIDX[S.home]]:-1;for(const [k,n] of cnt)if(n>mn||(n===mn&&k===hk)){main=k;mn=n;} + for(const d of ds){const ci=CIDX[d.city];d.ok=COMP[ci]>=0&&COMP[ci]===main;d.left=d.g;if(!d.ok)X.isl.push(d.city);} + // Terminals first: each takes what its dish and its crust have left, in S.biz order. + if(hubs.length)for(const b of S.biz){const T=BIZ_T[b.type];if(!T.orbit)continue;const L=pieLand(b.city,b.type,ds,hubs);if(!L)continue;const d=ds[L.k]; + const a=Math.max(0,Math.min(b.bw,d.left,X.cr[L.cr]));d.left-=a;X.cr[L.cr]-=a;X.term[b.id]=a;X.gs[b.id]=d.city;X.gsBw[d.city]=(X.gsBw[d.city]||0)+a;} + const las=hubs.filter(pieLased).sort((a,b)=>CRUSTS[a].alt-CRUSTS[b].alt); + if(las.length){const sky=[]; + for(const d of ds){if(!d.ok||!(d.left>0))continue;const cs=las.filter(id=>pieCovers(id,d.city));if(!cs.length)continue;const ci=CIDX[d.city],n=NC+sky.length;adj[n]=[]; + const e={id:'pie:'+d.city,a:d.city,b:d.city,ai:ci,bi:n,i:X.ne++,km:0,cap:d.left,scap:0,w:Infinity,lat:CRUSTS[cs[0]].alt/PIE_C+PIE_HOP,slat:Infinity,links:[],res:0,ld:0,tr:null,pl:0,f:1,sky:d}; + edges[e.id]=e;adj[ci].push([n,e]);adj[n].push([ci,e]);X.up.push(e);sky.push({d,n,cs});} + for(let i=0;iq.cs.includes(id));if(!cs.length)continue;const cap=cs.reduce((a,id)=>a+X.cr[id],0);if(!(cap>0))continue; + const e={id:'pie:'+p.d.city+'~'+q.d.city,a:p.d.city,b:q.d.city,ai:p.n,bi:q.n,i:X.ne++,km:Math.round(km),cap,scap:0,w:Infinity,lat:km*(PIE_RE+CRUSTS[cs[0]].alt)/PIE_RE/PIE_C,slat:Infinity,links:[],res:0,ld:0,tr:null,pl:0,f:1,sky:'las'}; + edges[e.id]=e;adj[p.n].push([q.n,e]);adj[q.n].push([p.n,e]);} + // Every Gbps through space goes up one dish and down another: the uplinks together carry at most twice what the crusts have left. + const room=2*las.reduce((a,id)=>a+X.cr[id],0),up=X.up.reduce((a,e)=>a+e.cap,0);if(up>room)for(const e of X.up)e.cap*=room/up;} + return X;} +// A latency-routed circuit from A to B (compute()'s l2Routes, mode 'fast'): the fastest path, through the sky where it is +// faster and the spats allow it; uplinks only in the two end countries when either asks to keep traffic home. +// Only latency customers fly, and never between cities under PIE_MIN_KM apart (O4): the rest get the fiber-only answer. +function pieFast(X,fastSP,A,B,b,wLat){const Ai=CIDX[A],Bi=CIDX[B]; + if(!BIZ_T[b.type].lat||pieKm(A,B)!!e.sky));return [{...walkI(r.P,Ai,Bi),share:1}];} + const r=fastSP[A]||(fastSP[A]=dijkstra(X.adj,Ai,wLat));let w=walkI(r.P,Ai,Bi);if(!w.path.some(e=>e.sky))return [{...w,share:1}]; + const ca=CITY[A].cc,cb=CITY[B].cc,home=pieSpatHome(ca)||pieSpatHome(cb),bad=e=>e.sky!=='las'&&(pieAirBlock(ca,e.sky.cc)||pieAirBlock(cb,e.sky.cc)||(home&&e.sky.cc!==ca&&e.sky.cc!==cb)); + if(w.path.some(e=>e.sky&&bad(e)))w=walkI(dijkstra(X.adj,Ai,wLat,(v,e)=>!!e.sky&&bad(e),Bi).P,Ai,Bi); + if(w.path.some(e=>e.sky))X.l2o[b.id]=1; + return [{...w,share:1}];} +// After routing: what orbit earns (terminals, and a premium on circuits riding the sky) and what each dish carries. +function pieMoney(X,R2,V){let rev=0;const sf={}; + for(const b of S.biz){const T=BIZ_T[b.type]; + if(T.orbit){const a=X.term[b.id]||0,s=b.bw>0?a/b.bw*(X.gs[b.id]?sfOf(R2,X.gs[b.id]):0):0;sf[b.id]=s;rev+=b.bw*b.rate*Math.min(1,s/0.95);} + else if(X.l2o[b.id]&&T.l2)rev+=b.bw*b.rate*PIE_LAT_PREM*clamp((R2.l2[b.id]||0)/b.bw,0,1);} + const used={};for(const d of X.ds)used[d.city]=d.g-d.left;for(const e of X.up)used[e.sky.city]+=e.ld||0; + V.orbit=rev;R2.pie={rev,sf,gs:X.gs,isl:X.isl,used,term:X.gsBw,hubs:X.hubs,sky:X.up.length};} +// What the network could sell from orbit today (offers, F3 spirit): a city a baked crust covers and a dish with room left +// can land; read from the last compute (R.pie), never computed here. +function pieServe(c,t){if(!S.pie||!R||!R.pie)return null;const ds=pieDishes();if(!ds.length)return null;const isl=new Set(R.pie.isl);for(const d of ds){d.ok=!isl.has(d.city);d.left=d.g-(R.pie.term[d.city]||0);}return pieLand(c,t,ds,R.pie.hubs.filter(pieUp));} +// Book what orbit earned, day by day. +PIE_ON.day.push(()=>{if(R&&R.pie&&R.pie.rev>0)S.pie.book.earned+=R.pie.rev/30;}); diff --git a/src/game/80-simulation/70-customers-and-events.js b/src/game/80-simulation/70-customers-and-events.js index ef723a1..cf037a7 100644 --- a/src/game/80-simulation/70-customers-and-events.js +++ b/src/game/80-simulation/70-customers-and-events.js @@ -1,8 +1,8 @@ -function bizSf(b,ids){const T=BIZ_T[b.type];return T.fiber?(fiberOk(b,ids)?1:0):T.l2?clamp((R.l2[b.id]||0)/b.bw,0,1):bizSfOf(R,b.city)*((R.tgtF&&R.tgtF[b.id])??1);} +function bizSf(b,ids){const T=BIZ_T[b.type];return T.orbit?((R.pie&&R.pie.sf[b.id])||0):T.fiber?(fiberOk(b,ids)?1:0):T.l2?clamp((R.l2[b.id]||0)/b.bw,0,1):bizSfOf(R,b.city)*((R.tgtF&&R.tgtF[b.id])??1);} // Protected business traffic has its own served share; without the rule it shares the city's. function bizSfOf(r,c){const d=r.bizDem&&r.bizDem[c];return teRules()&&teRules().protect&&d>1e-6?clamp(r.bizSrv[c]/d,0,1):sfOf(r,c);} function bCities(o){return o.sites?o.sites.slice():[o.city,o.city2].filter(Boolean);} -function bHas(o){return !!BIZ_T[o.type].cap||bCities(o).every(c=>S.pops[c]);} +function bHas(o){return !!BIZ_T[o.type].cap||!!BIZ_T[o.type].orbit||bCities(o).every(c=>S.pops[c]);} function eventLive(b){return BIZ_T[b.type].event&&S.day>=b.start&&S.day⚠️ ${tr('customers_and_events.gaming_attracts_attacks')}`:'';} diff --git a/src/game/93-ui/85-pie-control.js b/src/game/93-ui/85-pie-control.js index 3ec7b54..84fc1f9 100644 --- a/src/game/93-ui/85-pie-control.js +++ b/src/game/93-ui/85-pie-control.js @@ -41,6 +41,7 @@ function pieModal(){if(!S||!pieOn())return;const P=S.pie||pieBlank(S.day),can=pi }else{ const F=P.founder;h+=`
${tr('pie.promises')}${tr('pie.promises_line',{n:F.promises,b:F.broken})}
`; h+=`
${tr('pie.spent')}${fmt$(P.book.spent)}
${tr('pie.earned')}${fmt$(P.book.earned)}
`; + if(R&&R.pie)h+=`

${tr('pie.earned_mo',{amt:fmt$(R.pie.rev),n:R.pie.isl.length})}

`; if(pieSand())h+=`
${tr('pie.would_have')}${fmt$(P.book.wouldHave)}
`; h+=`

${tr('pie.founder_feed')}

`+(F.posts.length?F.posts.map(p=>`
${esc(dateStr(p.d))}
${esc(pieFpText(p))}
`).join(''):`

${tr('pie.feed_empty')}

`); } diff --git a/src/i18n/en.js b/src/i18n/en.js index 5835672..77705dc 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -405,6 +405,7 @@ "businesses.cloud_gaming_platform":"Cloud gaming platform", "businesses.cloud_gaming_platforms_and_the_cloud":"Cloud gaming platforms, and the cloud gaming era: eyeballs want another 15%. A free PNI with Tel-Mess. Gear: Sienna WaveMagic 3.2T transponders.", "businesses.cloud_on_ramp":"Cloud on-ramp", +"businesses.cruise_ship_connectivity":"Cruise ship connectivity", "businesses.customer_on_a_fabric_transit_over":"Customer on a fabric (transit over an NNI)", "businesses.dark_fiber_pair_lease":"Dark fiber pair lease", "businesses.dataset_ingest_elephant_flow":"Dataset ingest (elephant flow)", @@ -415,12 +416,14 @@ "businesses.esports_world_final":"Esports world final", "businesses.esports_world_finals_and_the_4k":"Esports world finals, and the 4K-everything era: eyeballs in every city want 15% more. Gear: Sonic the Whitebox 64 routers.", "businesses.fabric_circuit_to_one_of_your":"Fabric circuit to one of your POPs", +"businesses.flywifi_airline_wi_fi":"Airline Wi-Fi in the sky", "businesses.high_frequency_trading_link":"High-frequency trading link", "businesses.hundreds_of_fiber_pairs":"Hundreds of fiber pairs", "businesses.internet_weather_system":"Internet weather system", "businesses.it_s_not_dns_there_s":"It's not DNS. There's no way it's DNS. It was DNS.", "businesses.mars_mission_ground_station":"Mars mission ground station", "businesses.mars_mission_ground_stations_gear":"Mars mission ground stations. Gear: The Router at the End of the Universe.", +"businesses.mars_mission_over_your_pies":"Mars mission over your pies", "businesses.metaverse_platforms_it_finally_took":"Metaverse platforms (it finally took off), and a free PNI with Etis-a-lot. Gear: Arrrhipster 7800R5 routers, 102.4T fabrics for your own exchange.", "businesses.multi_site_training_run":"Multi-site training run", "businesses.peak_12_tbps_25_pops_5":"peak 12 Tbps, 25 POPs, 5 continents", @@ -436,6 +439,7 @@ "businesses.peak_6_tbps_15_pops_4":"peak 6 Tbps, 15 POPs, 4 continents", "businesses.peak_9_tbps_and_20_pops":"peak 9 Tbps and 20 POPs", "businesses.people_phone_you_to_ask_if":"People phone you to ask if the internet is down. You are the internet. Have you tried turning yourself off and on again?", +"businesses.pizza_homes_and_boats_on_orbit":"Homes and boats on a pie terminal", "businesses.provedor_small_regional_isp":"Provedor (small regional ISP)", "businesses.sd_wan_for_a_chain":"SD-WAN for a chain", "businesses.six_continent_carrier":"Six-continent carrier", @@ -3405,6 +3409,7 @@ "pie.crust_line":"{alt} km · {n} of {full} pies · {q} on the way · {p} covered", "pie.dish_note":"A pie dish talks to the pies overhead. It needs a POP in its city and landing rights in its country.", "pie.earned":"Earned from orbit", +"pie.earned_mo":"Orbit earns {amt}/mo · {n} dishes off the backbone carry no transit", "pie.factory":"Pie factory", "pie.factory_pitch":"Bakes {m} pies a month, for {mo} a month.", "pie.factory_stock":"{n} pies on the shelf · {m} a month", diff --git a/tests/pie-routing.test.js b/tests/pie-routing.test.js new file mode 100644 index 0000000..d87260c --- /dev/null +++ b/tests/pie-routing.test.js @@ -0,0 +1,171 @@ +// Pie in the Sky: routing through orbit and the customers who pay for it (src/game/80-simulation/35-pie-paths.js, +// src/game/60-features/99-pie-orbit-customers.js). Seeded; state is set directly where luck would decide. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const { load } = require('./harness'); + +// A sandbox with London and New York joined by a transatlantic wave, Frankfurt 640 km from London, a company, and a +// 16-antenna dish with landing rights at each POP. +const world = (ev, opt = {}) => { + ev("ACT.modeSet({m:'sandbox'});ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.nextFail=1e9;S.nextEvent=1e9"); + ev("for(const c of ['lon','nyc','fra'])if(!S.pops[c])ACT.buildPop({city:c});S.links=S.links.filter(l=>0);" + + "S.links.push({id:'ln',a:'lon',b:'nyc',kind:'wave',tier:3,km:5818,sub:true,cable:'grace',cut:0,mo:1},{id:'lf',a:'lon',b:'fra',kind:'wave',tier:3,km:640,sub:false,cut:0,mo:1});for(const c of ['lon','nyc','fra'])ACT.buyTransit({city:c,net:'cog',tier:1})"); + ev(`ACT.pieFound();for(const c of ${JSON.stringify(opt.dishes || ['lon', 'nyc', 'fra'])}){ACT.pieDish({city:c});S.pie.lic[CITY[c].cc]={state:'ok',until:1e6};}for(const x of S.pie.dishes)x.ant=PIE_ANT_MAX`); + ev(`S.pie.crusts.short.cohorts=[{n:${opt.n || 'CRUSTS.short.full'},day:S.day,las:${opt.las !== false}}];compute()`); +}; +const circuit = (ev, id, a, b, type = 'hft', bw = 5) => ev(`S.biz.push({id:'${id}',type:'${type}',city:'${a}',city2:'${b}',bw:${bw},rate:1000,reqs:[],latMax:null,route:'fast',name:'${id}',mood:100,since:0,sites:null});compute()`); +const term = (ev, id, city, type = 'pizza', bw = 50) => ev(`S.biz.push({id:'${id}',type:'${type}',city:'${city}',city2:null,bw:${bw},rate:BIZ_T.${type}.rate,reqs:[],latMax:null,route:'normal',name:'${id}',mood:100,since:0,sites:null});compute()`); +const skyOf = (ev, id) => ev(`R.l2route?false:false`) || ev(`Object.keys(R.ef).filter(k=>k.startsWith('pie:')&&R.ef[k].eg['l2:${id}']>0).length>0`); + +test('London to New York: a latency customer takes the lasers when they are on, and the fiber otherwise', () => { + const { ev, errors } = load(); + world(ev); + const fiber = ev("linkLat(S.links.find(l=>l.id==='ln'))"); + circuit(ev, 'hft1', 'lon', 'nyc'); + assert.equal(skyOf(ev, 'hft1'), true, 'through space'); + assert.ok(ev("R.l2lat.hft1") < fiber - 2, `orbit ${ev('R.l2lat.hft1')} ms beats glass ${fiber} ms`); + assert.equal(ev('R.l2.hft1'), 5, 'carried in full'); + assert.ok(ev('R.pie.rev') > 0, 'the premium for the faster path is orbit revenue'); + // vacuum: ~1.47x faster than glass over the great circle, plus the hop up and down + const km = ev("pieKm('lon','nyc')"), v = ev(`pieSkyMs(${km},550)`); + assert.ok(Math.abs(ev('R.l2lat.hft1') - v) < 1.5, `${ev('R.l2lat.hft1')} ≈ ${v}`); + ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:false}];compute()"); + assert.equal(skyOf(ev, 'hft1'), false, 'no lasers: no space path'); + assert.ok(Math.abs(ev('R.l2lat.hft1') - fiber) < 0.2, 'on the fiber'); + assert.deepEqual(errors, []); +}); + +test('O4: short routes never use orbit, and neither does bulk or plain IP traffic', () => { + const { ev, errors } = load(); + world(ev); + circuit(ev, 'near', 'lon', 'fra'); + assert.equal(skyOf(ev, 'near'), false, 'London–Frankfurt stays on fiber'); + circuit(ev, 'bk', 'lon', 'nyc', 'l2vpn', 10); + assert.equal(skyOf(ev, 'bk'), false, 'a circuit that does not care about latency stays on fiber'); + ev("S.pops.lon.bb={d:400};compute()"); + assert.equal(ev("Object.keys(R.ef).filter(k=>k.startsWith('pie:')).every(k=>!Object.keys(R.ef[k].eg).some(e=>!e.startsWith('l2:')))"), true, 'IP flows never cross a sky edge'); + assert.equal(ev("Object.values(R.load).every(Number.isFinite)"), true); + // and the graph itself has no space edge shorter than the threshold + assert.equal(ev("Object.keys(R.ef).some(k=>k==='pie:lon~fra'||k==='pie:fra~lon')"), false); + assert.deepEqual(errors, []); +}); + +test('O2: a half-baked crust carries nothing, and orbit never carries more than the dishes hold', () => { + const { ev, errors } = load(); + world(ev, { n: 'Math.floor(CRUSTS.short.full*0.59)' }); + circuit(ev, 'hft1', 'lon', 'nyc'); + term(ev, 'pz', 'pcn'); + assert.deepEqual(ev('JSON.stringify(pieHubs())'), '[]'); + assert.equal(skyOf(ev, 'hft1'), false); + assert.equal(ev("R.pie.sf.pz"), 0, 'a home on Pitcairn gets nothing from a half-baked crust'); + assert.equal(ev('R.pie.rev'), 0); + // baked: now load it far past the dishes + ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:true}];for(let i=0;i<20;i++)S.biz.push({id:'big'+i,type:'boat',city:'pcn',city2:null,bw:800,rate:1,reqs:[],route:'normal',name:'b'+i,mood:100,since:0,sites:null});compute()"); + const dishG = ev('pieDishes().reduce((a,d)=>a+d.g,0)'); + const used = ev('Object.values(R.pie.used).reduce((a,b)=>a+b,0)'); + assert.ok(used <= dishG + 1e-6, `orbit carries ${used} G on ${dishG} G of antennas`); + for (const c of ['lon', 'nyc', 'fra']) assert.ok(ev(`R.pie.used.${c}`) <= ev(`pieDishes().find(d=>d.city==='${c}').g`) + 1e-6, c); + assert.ok(ev("Object.keys(R.pie.term).length") > 0); + assert.deepEqual(errors, []); +}); + +test('O3: a dish whose POP is off the backbone is flagged and carries no transit, only its own terminals', () => { + const { ev, errors } = load(); + world(ev); + ev("ACT.buildPop({city:'syd'});ACT.pieDish({city:'syd'});S.pie.lic.AU={state:'ok',until:1e6};for(const x of S.pie.dishes)x.ant=PIE_ANT_MAX;compute()"); + assert.deepEqual(ev('JSON.stringify(R.pie.isl)'), '["syd"]', 'Sydney has no fiber to the rest'); + circuit(ev, 'hs', 'lon', 'syd'); + assert.equal(ev('R.l2.hs||0'), 0, 'no way through the island dish'); + assert.equal(ev("Object.keys(R.ef).some(k=>k.includes('syd'))"), false); + // a home next to it still lands there (bent pipe, local only) + term(ev, 'pz', 'cbr'); + assert.equal(ev('R.pie.gs.pz'), 'syd'); + assert.deepEqual(errors, []); +}); + +test('Pitcairn and the Arctic are servable from orbit, and offers only come when the network can serve them', () => { + const { ev, errors } = load(); + world(ev, { las: false }); + assert.equal(ev("pieServe('pcn','pizza')"), null, 'no lasers and no dish within 1,000 km: Pitcairn waits'); + ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:true}];compute()"); + assert.ok(ev("!!pieServe('pcn','pizza')"), 'with lasers it lands on a dish of yours'); + term(ev, 'pz', 'pcn'); + assert.ok(ev('R.pie.sf.pz') > 0.9, `Pitcairn served ${ev('R.pie.sf.pz')}`); + assert.ok(ev("bizSf(S.biz.find(b=>b.id==='pz'))") > 0.9); + assert.ok(ev('R.rev.orbit') >= 50 * ev('BIZ_T.pizza.rate') * 0.9); + // Utqiaġvik at 71°N: past Shortcrust's reach, but a polar crust covers it + assert.equal(ev("pieServe('brw','pizza')"), null); + ev("S.pie.crusts.frozen.cohorts=[{n:CRUSTS.frozen.full,day:S.day,las:true}];compute()"); + assert.ok(ev("!!pieServe('brw','pizza')"), 'the frozen crust reaches the Arctic'); + // offers: only kinds the sky can serve, sized to fit + ev("S.offers=[];for(let i=0;i<60;i++)pieSpawn(pick(pieOfferTypes()))"); + const offers = JSON.parse(ev("JSON.stringify(S.offers)")); + assert.ok(offers.length > 3, 'orbit customers call'); + assert.ok(offers.every(o => ev(`!!BIZ_T.${o.type}.orbit&&!!pieServe('${o.city}','${o.type}')`)), 'each one servable'); + assert.ok(ev('pieSold()') <= ev('pieMarket()') + 1e-6, 'never more than the market'); + ev("S.offers=[];S.pie.crusts.short.cohorts=[];S.pie.crusts.frozen.cohorts=[];compute()"); + assert.equal(ev('pieOfferTypes().length'), 0, 'nothing in the sky: nobody calls'); + assert.deepEqual(errors, []); +}); + +test('the Mars mission gets its orbital option only in saves of this version', () => { + const { ev, errors } = load(); + world(ev); + ev('S.lvl=13'); + assert.ok(ev("pieOfferTypes().includes('marsorb')")); + ev('S.pieV=0'); + assert.equal(ev("pieOfferTypes().includes('marsorb')"), false); + assert.deepEqual(errors, []); +}); + +test('spats: data stays home, and not over my airspace', () => { + const { ev, errors } = load(); + world(ev); + // A home in Ireland lands on London's dish (bent pipe) until Ireland wants its customers on Irish soil. + term(ev, 'ie', 'dub'); + assert.equal(ev('R.pie.gs.ie'), 'lon'); + ev("S.pie.spat.home={st:'on',cc:'IE',ask:S.day,until:S.day+90,c:0};compute()"); + assert.equal(ev('pieSpatHome("IE")'), true); + assert.equal(ev('R.pie.gs.ie||null'), null, 'no Irish dish: not served'); + // London–New York circuit: the US and the UK fall out; New York traffic must not touch a British dish. + circuit(ev, 'hft1', 'nyc', 'fra'); + assert.equal(ev("Object.keys(R.ef).some(k=>k==='pie:lon'&&R.ef[k].eg['l2:hft1']>0)"), false); + ev("S.pie.spat.air={st:'on',cc:'US',cc2:'GB',ask:S.day,until:S.day+90,c:0};compute()"); + assert.equal(ev("pieAirBlock('US','GB')"), true); + term(ev, 'us', 'bos'); + assert.equal(ev('R.pie.gs.us'), 'nyc'); + term(ev, 'gb', 'man'); + assert.equal(ev('R.pie.gs.gb'), 'lon'); + circuit(ev, 'hft2', 'nyc', 'lon'); + assert.equal(ev("Object.keys(R.ef).some(k=>k==='pie:lon'&&R.ef[k].eg['l2:hft2']>0)"), false, 'US traffic avoids the British dish'); + assert.ok(ev('R.l2.hft2') > 0, 'and goes by fiber'); + assert.deepEqual(errors, []); +}); + +test('saves without pies route identically, and pay nothing for orbit', () => { + const { ev, errors } = load(); + const save = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8'); + ev(`S=migrate(JSON.parse(${JSON.stringify(save)}));compute()`); + assert.equal(ev('S.pie'), null); + const out = () => ev("JSON.stringify([R.served,R.demand,R.revMo,R.egT,R.load,R.l2,R.l2lat,R.rev])"); + const a = out(); + assert.equal(ev("R.pie===undefined&&R.rev.orbit===undefined"), true); + // the same save with a rocket company that has nothing in the sky routes the same traffic + ev("S.pieV=1;pieInit();compute()"); + const b = JSON.parse(ev("JSON.stringify([R.served,R.demand,R.egT,R.load,R.l2,R.l2lat])")); + const a0 = JSON.parse(a); + assert.deepEqual(b, [a0[0], a0[1], a0[3], a0[4], a0[5], a0[6]]); + assert.deepEqual(errors, []); +}); + +test('orbit earnings go into the book, day by day', () => { + const { ev, errors } = load(); + world(ev); + term(ev, 'pz', 'pcn'); + const mo = ev('R.pie.rev'); + ev('for(let i=0;i<30;i++)dayTick()'); + assert.ok(Math.abs(ev('S.pie.book.earned') - mo) / mo < 0.05, `${ev('S.pie.book.earned')} ≈ ${mo}`); + assert.deepEqual(errors, []); +});