Pie in the Sky: dips in orbit hurt instead of emptying the sky
A crust carries a share of its traffic from 40% coverage, growing to all of it at 60% (pieCarry/pieCap), instead of nothing until 60%. Pies wear out over the last 30% of their life (pieAlive), deterministic, so a launch month no longer deorbits on one day. Storms take 2-10% and food fights 5-10% of a crust (PIE_HIT), down from up to 40% and 20%. Orbit customers lose at most PIE_PATIENCE happiness a day without service, about a month to cancel.
This commit is contained in:
parent
48d2cedbee
commit
d7d5d21372
21 changed files with 135 additions and 51 deletions
|
|
@ -84,7 +84,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
|
|||
| Id | Rule | Why |
|
||||
| --- | --- | --- |
|
||||
| O1 | The rocket company unlocks only on the Tier 1 win of a save started on its version (`S.pieV>=1`, set by `newGame()`; a save without it loads as 0), or from day 0 with open gates (sandbox). Never in puzzles, the Architect or scenarios. Losing Tier 1 keeps everything flying but builds nothing new. | An endgame for people who earned it; old won saves must not change under their players. |
|
||||
| O2 | A half-baked crust (under 60% coverage) carries nothing, and orbit never carries more than the pie dishes' antennas (x rain, jamming): terminals and sky paths share each dish. | Satellites are not magic bandwidth; the ground segment is the bottleneck, as in real life. |
|
||||
| O2 | A crust under 40% coverage carries nothing; from 40% a half-baked crust carries a share that grows to all of its capacity at 60% (a slope, not a cliff), and orbit never carries more than the pie dishes' antennas (x rain, jamming): terminals and sky paths share each dish. | Satellites are not magic bandwidth; the ground segment is the bottleneck, as in real life. |
|
||||
| O3 | A cut-off pie dish (its POP on an island the backbone does not reach) carries only its own POP's traffic (backhaul, to a landing dish on the backbone) and local terminals, never transit between other cities: no POP on the backbone routes through it. Backhaul is small (the dish's antennas, the landing dish's and the crust's room) and pays the orbit's latency. | Orbit extends your network to a town no cable reaches; it does not replace building one, and laying fiber stays the real fix. |
|
||||
| O4 | Through space with lasers, light travels at c in vacuum (about 1.47 times glass), up and down at the shell's height; orbit never carries traffic between cities under 3,000 km apart and only latency-routed circuits fly: IP traffic, bulk and scenic circuits stay on fiber. | Real constellations win only on long routes, and their capacity is small. |
|
||||
| O5 | Launches fail only with chaos on (`rule('chaos')`), and never in the first 90 days after the unlock; heavy test flights explode by design, not by chance. Orbit incidents and geopolitical spats (`pieChaos()`) follow the same rule. | Like F1: learn the thing before it punishes you. |
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ All notable changes to this project are documented here. The project follows
|
|||
- Pie Control now shows what traffic rides your satellites: a new Traffic tab lists who is in orbit (homes, boats, airlines, the Mars mission and trading circuits), how many Gbps each one uses, what it pays, and how much faster orbit is than your fiber. Each crust and pie dish gets a load bar and a plain reason when it sits idle (half-baked, raining, jammed, cut off from your backbone, no landing rights, no lasers, no customers), and an empty sky gets a checklist of what is missing. The globe draws each customer's traffic as a glowing arc you can highlight from the list, dishes on the globe and the map get a load ring, and the traceroute shows a circuit's hops up to orbit, across space and back down.
|
||||
- A town with no cable can now reach your network through your satellites: a pie dish at a POP your fiber does not reach sends all of that town's traffic up to a baked crust and down at one of your dishes on the backbone, nearby or, with laser links, anywhere. The pipe is small (the dishes' antennas and the crust's room) and adds the orbit's delay, so a big town fills it quickly and laying fiber stays the real fix; it never carries traffic between your other cities. Pie Control's Traffic tab shows each backhaul, how full it is, where it lands and how many ms it adds, or why it is missing, the globe draws it, and the traceroute shows its hops through space.
|
||||
- The globe in Pie Control now replays your last few launches: a good one climbs and spills its pies into orbit (and a reusable booster flies home), a failed one goes up in a fireball with debris raining down.
|
||||
- A bad week in orbit now hurts without emptying the sky: a half-baked crust carries part of its traffic from 40% (all of it from 60%) instead of nothing until 60%, satellites wear out a few at a time near the end of their life instead of a whole launch month on one day, no storm or food fight takes more than a tenth of a crust, and orbit customers put up with about a month without service before they cancel.
|
||||
- Your own subsea cables now land right on the city's dot, also in Fujairah, Dubai, Karachi, Barcelona, Osaka and other cities the map shifts slightly so they do not overlap (#305).
|
||||
- Starting a new network no longer leaves the last one's "New POP!" and money pop-ups frozen all over the map until a reload.
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ Pies are cohorts, never one object per satellite. `sanitize()` clamps all of it.
|
|||
| Founder launch party | $2M per launch, automatic | - |
|
||||
|
||||
Crusts: short 550 km / 1584 full / |lat|<=53; frozen 560 km / 520 / polar; upper 1100 km / 1200 / |lat|<=60;
|
||||
flaky 340 km / 2500 / dense cities, life 3y. Life 5y otherwise. Coverage < 60% = half-baked, carries 0.
|
||||
flaky 340 km / 2500 / dense cities, life 3y. Life 5y otherwise. Coverage < 60% = half-baked: carries 0 under 40%, then a share growing to all of it at 60% (pieCarry). Pies wear out over the last 30% of their life, a few a day (pieAlive), not a whole launch month at once.
|
||||
|
||||
## Routing (rules O2-O4)
|
||||
|
||||
Crust >= 60% = virtual hub. Live, licensed, connected dish <-> hub edge: latency (alt up+down)/c + 2 ms.
|
||||
Crust > 40% = virtual hub (capacity pieCap = g x coverage x carry). Live, licensed, connected dish <-> hub edge: latency (alt up+down)/c + 2 ms.
|
||||
With lasers: hub-to-hub along great circle at c (vacuum). Capacity = min(crust cap x coverage,
|
||||
antennas x Gbps x rain). Orbit never beats fiber under ~3000 km. Graph grows by dishes + crusts only.
|
||||
Dishes with no path to the backbone carry no transit (O3), but backhaul their own POP: all its traffic (eyeballs, customers,
|
||||
|
|
|
|||
|
|
@ -3472,7 +3472,7 @@
|
|||
"pie.sandbox_note":"Sandbox: Hier kostet nichts echtes Geld. Bisher hättest du {amt} ausgegeben.",
|
||||
"pie.spent":"Bisher ausgegeben",
|
||||
"pie.stock_line":"{n} Pies stehen in der Fabrik bereit.",
|
||||
"pie.t_baked":"{crust} ist gebacken: genug Pies, um Traffic zu tragen.",
|
||||
"pie.t_baked_all":"{crust} ist gebacken: genug Pies, um ihren ganzen Traffic zu tragen.",
|
||||
"pie.t_booster":"Der Booster kam nicht zurück. Ein neuer kostet Geld.",
|
||||
"pie.t_dish":"Pie-Schüssel in {city} gebaut.",
|
||||
"pie.t_factory":"Die Pie-Fabrik hat geöffnet: {n} Pies im Monat.",
|
||||
|
|
@ -3627,6 +3627,7 @@
|
|||
"pie_traffic.ck_lasers_h":"Ohne Laser erreicht Traffic nur eine Schüssel im Umkreis von 1.000 km, und nichts quert den Weltraum. Schieß Pies mit Lasern hoch.",
|
||||
"pie_traffic.crust_down":"Gerade außer Betrieb (ein Sonnensturm).",
|
||||
"pie_traffic.crust_half":"{crust} ist zu {p} gebacken; Traffic trägt sie ab {min}.",
|
||||
"pie_traffic.crust_part":"{crust} ist zu {p} gebacken: halb gar trägt sie {c} ihres Traffics, alles ab {min}.",
|
||||
"pie_traffic.crust_safe":"Der Sicherheitsmodus ist an: Sie trägt nichts, bis du ihn ausschaltest.",
|
||||
"pie_traffic.crusts":"Krusten",
|
||||
"pie_traffic.d_backhaul":"schickt den eigenen Ort per Backhaul durch den Orbit",
|
||||
|
|
|
|||
|
|
@ -3470,7 +3470,7 @@
|
|||
"pie.sandbox_note":"Sandbox: aquí nada cuesta dinero de verdad. Hasta ahora habrías gastado {amt}.",
|
||||
"pie.spent":"Gastado hasta ahora",
|
||||
"pie.stock_line":"{n} tartas listas en la fábrica.",
|
||||
"pie.t_baked":"{crust} está horneada: tartas suficientes para llevar tráfico.",
|
||||
"pie.t_baked_all":"{crust} está horneada: tartas suficientes para llevar todo su tráfico.",
|
||||
"pie.t_booster":"El propulsor no volvió. Uno nuevo cuesta dinero.",
|
||||
"pie.t_dish":"Antena-tarta construida en {city}.",
|
||||
"pie.t_factory":"La fábrica de tartas ha abierto: {n} tartas al mes.",
|
||||
|
|
@ -3625,6 +3625,7 @@
|
|||
"pie_traffic.ck_lasers_h":"Sin láseres, el tráfico solo llega a una antena a menos de 1.000 km y nada cruza el espacio. Lanza tartas con láser.",
|
||||
"pie_traffic.crust_down":"Fuera de servicio por ahora (una tormenta solar).",
|
||||
"pie_traffic.crust_half":"{crust} está horneada al {p}; lleva tráfico a partir del {min}.",
|
||||
"pie_traffic.crust_part":"{crust} está horneada al {p}: a medio hornear, lleva el {c} de su tráfico, y todo a partir del {min}.",
|
||||
"pie_traffic.crust_safe":"El modo seguro está activo: no lleva nada hasta que lo apagues.",
|
||||
"pie_traffic.crusts":"Cortezas",
|
||||
"pie_traffic.d_backhaul":"lleva por backhaul su propio pueblo a través de la órbita",
|
||||
|
|
|
|||
|
|
@ -3470,7 +3470,7 @@
|
|||
"pie.sandbox_note":"Bac à sable : rien ici ne coûte de vrai argent. Tu aurais dépensé {amt} jusqu'ici.",
|
||||
"pie.spent":"Dépensé jusqu'ici",
|
||||
"pie.stock_line":"{n} tartes prêtes à l'usine.",
|
||||
"pie.t_baked":"{crust} est cuite : assez de tartes pour transporter du trafic.",
|
||||
"pie.t_baked_all":"{crust} est cuite : assez de tartes pour transporter tout son trafic.",
|
||||
"pie.t_booster":"Le booster n'est pas revenu. Un nouveau coûte de l'argent.",
|
||||
"pie.t_dish":"Antenne-tarte construite à {city}.",
|
||||
"pie.t_factory":"L'usine à tartes est ouverte : {n} tartes par mois.",
|
||||
|
|
@ -3625,6 +3625,7 @@
|
|||
"pie_traffic.ck_lasers_h":"Sans lasers, le trafic n’atteint qu’une antenne à moins de 1 000 km et rien ne traverse l’espace. Lance des tartes avec lasers.",
|
||||
"pie_traffic.crust_down":"Hors service pour l’instant (une tempête solaire).",
|
||||
"pie_traffic.crust_half":"{crust} est cuite à {p} ; elle transporte du trafic à partir de {min}.",
|
||||
"pie_traffic.crust_part":"{crust} est cuite à {p} : à moitié cuite, elle transporte {c} de son trafic, et tout à partir de {min}.",
|
||||
"pie_traffic.crust_safe":"Le mode sécurité est activé : elle ne transporte rien tant que tu ne l’éteins pas.",
|
||||
"pie_traffic.crusts":"Croûtes",
|
||||
"pie_traffic.d_backhaul":"fait le backhaul de sa propre ville par l’orbite",
|
||||
|
|
|
|||
|
|
@ -3470,7 +3470,7 @@
|
|||
"pie.sandbox_note":"Sandbox: qui niente costa soldi veri. Finora avresti speso {amt}.",
|
||||
"pie.spent":"Speso finora",
|
||||
"pie.stock_line":"{n} torte pronte in fabbrica.",
|
||||
"pie.t_baked":"{crust} è cotta: abbastanza torte per trasportare traffico.",
|
||||
"pie.t_baked_all":"{crust} è cotta: abbastanza torte per trasportare tutto il suo traffico.",
|
||||
"pie.t_booster":"Il booster non è tornato. Uno nuovo costa.",
|
||||
"pie.t_dish":"Parabola-torta costruita a {city}.",
|
||||
"pie.t_factory":"La fabbrica di torte è aperta: {n} torte al mese.",
|
||||
|
|
@ -3625,6 +3625,7 @@
|
|||
"pie_traffic.ck_lasers_h":"Senza laser il traffico raggiunge solo un'antenna entro 1.000 km e niente attraversa lo spazio. Lancia torte con i laser.",
|
||||
"pie_traffic.crust_down":"Fuori servizio per ora (una tempesta solare).",
|
||||
"pie_traffic.crust_half":"{crust} è cotta al {p}; porta traffico dal {min}.",
|
||||
"pie_traffic.crust_part":"{crust} è cotta al {p}: a metà cottura porta il {c} del suo traffico, e tutto dal {min}.",
|
||||
"pie_traffic.crust_safe":"La modalità sicura è attiva: non porta niente finché non la spegni.",
|
||||
"pie_traffic.crusts":"Croste",
|
||||
"pie_traffic.d_backhaul":"fa il backhaul del suo paese attraverso l’orbita",
|
||||
|
|
|
|||
|
|
@ -3470,7 +3470,7 @@
|
|||
"pie.sandbox_note":"Sandbox: aqui nada custa dinheiro de verdade. Até agora você teria gastado {amt}.",
|
||||
"pie.spent":"Gasto até agora",
|
||||
"pie.stock_line":"{n} tortas prontas na fábrica.",
|
||||
"pie.t_baked":"{crust} está assada: tortas suficientes para carregar tráfego.",
|
||||
"pie.t_baked_all":"{crust} está assada: tortas suficientes para carregar todo o seu tráfego.",
|
||||
"pie.t_booster":"O propulsor não voltou. Um novo custa dinheiro.",
|
||||
"pie.t_dish":"Antena-torta construída em {city}.",
|
||||
"pie.t_factory":"A fábrica de tortas abriu: {n} tortas por mês.",
|
||||
|
|
@ -3625,6 +3625,7 @@
|
|||
"pie_traffic.ck_lasers_h":"Sem lasers, o tráfego só chega a uma antena a até 1.000 km e nada atravessa o espaço. Lance tortas com lasers.",
|
||||
"pie_traffic.crust_down":"Fora de serviço por enquanto (uma tempestade solar).",
|
||||
"pie_traffic.crust_half":"{crust} está {p} assada; leva tráfego a partir de {min}.",
|
||||
"pie_traffic.crust_part":"{crust} está {p} assada: meio assada, leva {c} do seu tráfego, e todo a partir de {min}.",
|
||||
"pie_traffic.crust_safe":"O modo seguro está ligado: não leva nada até você desligar.",
|
||||
"pie_traffic.crusts":"Crostas",
|
||||
"pie_traffic.d_backhaul":"faz o backhaul da própria cidade pela órbita",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const PIE_CO=250e6,PIE_CO_MO=5e6,PIE_FAC=1e9,PIE_FAC_MO=8e6,PIE_FAC_MONTH=120,PI
|
|||
PIE_REUSE=500e6,PIE_HEAVY=3e9,PIE_HEAVY_TESTS=3,PIE_BOOST=40e6,PIE_BOOST_MAX=20,PIE_BOOSTERS=6,PIE_INS=0.08,
|
||||
PIE_DISH=25e6,PIE_ANT=2e6,PIE_ANT_MAX=16,PIE_ANT_G=20,PIE_DISH_MO=3e5,PIE_DISH_MAX=200,
|
||||
PIE_LIC_MIN=10e6,PIE_LIC_MAX=200e6,PIE_LIC_DAYS=360,PIE_LEOIX=50e6,PIE_LEOIX_MO=1e6,PIE_PARTY=2e6,
|
||||
PIE_QUIET=90,PIE_PREP=7,PIE_Q_MAX=40,PIE_COHORTS=240,PIE_POSTS=20,PIE_BAKED=0.6,PIE_SPARE=1.1;
|
||||
PIE_QUIET=90,PIE_PREP=7,PIE_Q_MAX=40,PIE_COHORTS=240,PIE_POSTS=20,PIE_RAW=0.4,PIE_BAKED=0.6,PIE_SPARE=1.1,PIE_WEAR=0.3;
|
||||
// In generation order. fail: chance a launch is lost (x chaos); land: chance a reused booster does not come back.
|
||||
const ROCKETS={
|
||||
falcon:{n:N_('pie.rk_falcon_punch'),cost:60e6,pies:20,fail:0.05,gap:14},
|
||||
|
|
@ -70,8 +70,15 @@ function pieOn(){return !!S&&!S.scn&&S.mode!=='puzzle'&&(!!S.pie||gatesOpen());}
|
|||
const pieT1=()=>!!S.won&&isTier1();
|
||||
// New things (company, factory, pads, R&D, launches, dishes) need you to be Tier 1 now, or a sandbox.
|
||||
function pieCanBuild(){return pieOn()&&(gatesOpen()||pieT1());}
|
||||
function pieLive(id){const c=S&&S.pie&&S.pie.crusts[id];if(!c)return 0;let n=0;for(const k of c.cohorts)if(S.day-k.day<CRUSTS[id].life)n+=k.n;return n;}
|
||||
// Pies wear out over the last PIE_WEAR of their life, a few every day, so a launch month never falls out of the sky at once:
|
||||
// a cohort counts in full until then, then less every day, and nothing at its life's end (no dice, nothing saved).
|
||||
function pieAlive(k,life){const left=life-(S.day-k.day),w=life*PIE_WEAR;return left>=w?k.n:left>0?k.n*left/w:0;}
|
||||
function pieLive(id){const c=S&&S.pie&&S.pie.crusts[id];if(!c)return 0;let n=0;const life=CRUSTS[id].life;for(const k of c.cohorts)n+=pieAlive(k,life);return Math.round(n);}
|
||||
function pieCov(id){return own(CRUSTS,id)?Math.min(1,pieLive(id)/CRUSTS[id].full):0;}
|
||||
// Under 60% a crust is half-baked: too many gaps to carry anything.
|
||||
// A crust is baked from 60%. Under that it is half-baked: from 40% (PIE_RAW) it carries a share of its traffic that grows
|
||||
// to all of it at 60% (pieCarry), under 40% nothing; too many gaps.
|
||||
function pieBaked(id){return pieCov(id)>=PIE_BAKED;}
|
||||
function pieUp(id){const P=S&&S.pie;return !!P&&!P.safe&&pieBaked(id)&&!(P.crusts[id].down>S.day);}
|
||||
function pieCarry(id){return clamp((pieCov(id)-PIE_RAW)/(PIE_BAKED-PIE_RAW),0,1);}
|
||||
function pieUp(id){const P=S&&S.pie;return !!P&&!P.safe&&pieCarry(id)>0&&!(P.crusts[id].down>S.day);}
|
||||
// Gbps a crust carries today: its capacity at its coverage, times the share a half-baked one manages.
|
||||
const pieCap=id=>CRUSTS[id].g*pieCov(id)*pieCarry(id);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
Hooks for the parts that come later (routing, incidents and spats, the globe):
|
||||
- pieDishes() -> [{id,city,cc,ant,g}]: dishes that work today (POP there, not down, landing rights held)
|
||||
- pieHubs() -> ['short',…]: crusts that are baked (>= 60%) and up (not in safe mode, not down)
|
||||
- pieHubs() -> ['short',…]: crusts that carry traffic (over 40%, all of it from 60%: pieCarry) and up (not in safe mode, not down)
|
||||
- pieLicOk(cc) -> true when landing rights in that country are held and in force
|
||||
- pieCov(id), pieBaked(id), pieUp(id), pieLive(id), pieLiveLas(id) (10-catalog/70-pie.js and below)
|
||||
- pieCov(id), pieBaked(id), pieCarry(id), pieCap(id), pieUp(id), pieLive(id), pieLiveLas(id) (10-catalog/70-pie.js and below)
|
||||
- PIE_ON.day / .launch / .fail: arrays of f(d) / f(L,ok) / f(L), called by pieDay() and pieFly()
|
||||
- S.pie.spat[id] with PIE_SPATS[id]={fix(o,s),day?(o,d),end?(o)}: a spat's state, repaired by pieSanitize(), ticked and
|
||||
dropped when o.until<=d by pieSpatDay(d)
|
||||
|
|
@ -31,7 +31,7 @@ const pieCoName=()=>{const n=S.pie&&S.pie.co&&S.pie.co.name;return !n?tr(PIE_NAM
|
|||
function pieSpend(v){const P=S.pie;if(pieSand()){P.book.wouldHave+=v;sfx('build');return true;}if(!spend(v))return false;P.book.spent+=v;return true;}
|
||||
function pieCharge(v){const P=S.pie;if(!P||!(v>0))return;if(pieSand())P.book.wouldHave+=v;else{S.cash-=v;P.book.spent+=v;}}
|
||||
function pieMo(){const P=S.pie;if(!P||!P.co)return 0;return PIE_CO_MO+(P.fac?PIE_FAC_MO:0)+P.pads.length*PIE_PAD_MO+P.dishes.length*PIE_DISH_MO;}
|
||||
const pieLiveLas=id=>{const c=S.pie&&S.pie.crusts[id];let n=0;if(pieLasCut(id))return 0;if(c)for(const k of c.cohorts)if(k.las&&S.day-k.day<CRUSTS[id].life)n+=k.n;return n;};
|
||||
const pieLiveLas=id=>{const c=S.pie&&S.pie.crusts[id];let n=0;if(pieLasCut(id))return 0;if(c)for(const k of c.cohorts)if(k.las)n+=pieAlive(k,CRUSTS[id].life);return Math.round(n);};
|
||||
const pieLicOk=cc=>{const l=S.pie&&S.pie.lic[cc];return !!l&&l.state==='ok'&&l.until>S.day;};
|
||||
function pieDishes(){const P=S&&S.pie;if(!P)return [];const o=[];for(const x of P.dishes){if(!S.pops[x.city]||x.down>S.day)continue;const cc=CITY[x.city].cc;if(pieLicOk(cc))o.push({id:x.id,city:x.city,cc,ant:x.ant,g:x.ant*PIE_ANT_G*pieDishMul(x)});}return o;}
|
||||
function pieHubs(){return S&&S.pie?Object.keys(CRUSTS).filter(pieUp):[];}
|
||||
|
|
@ -98,7 +98,7 @@ function pieDay(d){const P=S.pie;if(!P)return;
|
|||
if(P.fac)P.stock=Math.min(PIE_STOCK_MAX,P.stock+PIE_FAC_MONTH/30);
|
||||
if(P.q.length){const due=P.q.filter(L=>L.day<=d);if(due.length){P.q=P.q.filter(L=>L.day>d);for(const L of due)pieFly(L);}}
|
||||
for(const id in CRUSTS){const c=P.crusts[id],life=CRUSTS[id].life;if(c.cohorts.length&&d-c.cohorts[0].day>=life)c.cohorts=c.cohorts.filter(k=>d-k.day<life);
|
||||
if(!c.bk&&pieBaked(id)){c.bk=1;pieFounder(N_('pie.fp_baked'),{c:id});toast(tr('pie.t_baked',{crust:tr(CRUSTS[id].n)}),'goal');piePromise();}}
|
||||
if(!c.bk&&pieBaked(id)){c.bk=1;pieFounder(N_('pie.fp_baked'),{c:id});toast(tr('pie.t_baked_all',{crust:tr(CRUSTS[id].n)}),'goal');piePromise();}}
|
||||
{const F=P.founder;if(F.due.length&&F.due[0]<=d){F.due.shift();F.broken++;pieFounder(N_('pie.fp_slip'),{n:pieYear(d+360)});}}
|
||||
// Running costs are billed with the rest each day (compute()); the book keeps the tally, and the sandbox its shame.
|
||||
{const mo=pieMo()/30;if(mo){if(pieSand())P.book.wouldHave+=mo;else P.book.spent+=mo;}}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@
|
|||
on offer, so orbit income cannot outgrow the sky (like F5). Remote towns (no POP of yours, few people) are the first
|
||||
to call: Pitcairn, the Arctic, the outer islands. */
|
||||
const PIE_SELL=0.25,PIE_REMOTE=0.6,PIE_OFFER_RATE=1/6,PIE_OFFERS=2;
|
||||
// Gbps the sky can sell: each baked crust's capacity at its coverage.
|
||||
function pieMarket(){if(!S.pie)return 0;let g=0;for(const id of pieHubs())g+=CRUSTS[id].g*pieCov(id)*PIE_SELL;return g;}
|
||||
// Orbit customers know the sky has bad weeks: without service they lose at most PIE_PATIENCE happiness a day (the day tick),
|
||||
// so they grumble, then fume, and cancel only after about a month of nothing, not in three days like a fiber customer.
|
||||
const PIE_PATIENCE=4;
|
||||
// Gbps the sky can sell: what each crust carries (pieCap(): a half-baked one, a share of it).
|
||||
function pieMarket(){if(!S.pie)return 0;let g=0;for(const id of pieHubs())g+=pieCap(id)*PIE_SELL;return g;}
|
||||
// Gbps signed and on offer, of one kind (t) or of all.
|
||||
const pieSold=t=>{let g=0;for(const b of S.biz)if(BIZ_T[b.type].orbit&&(!t||b.type===t))g+=b.bw;for(const o of S.offers)if(BIZ_T[o.type].orbit&&(!t||o.type===t))g+=o.bw;return g;};
|
||||
const pieRoom=t=>{const m=pieMarket(),sh=BIZ_T[t].share;return Math.min(m-pieSold(),sh?m*sh-pieSold(t):Infinity);};
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@
|
|||
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 and backhaul 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.
|
||||
- with lasers (a crust over 40% 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 (pieCap(): g x coverage, x the share a half-baked one carries) 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 (O3). A half-baked crust (< 60%) is not a hub and carries nothing (O2).
|
||||
and gets no sky node: it carries no transit (O3). A crust carries nothing under 40% and is not a hub; from
|
||||
there it carries a share that grows to all of its capacity at 60% (pieCarry(), O2).
|
||||
Backhaul (O3): a cut-off dish lifts its own POP's traffic, all of it, to a landing dish on the backbone: one virtual
|
||||
edge, POP to landing POP ('pie:bh:'+city, e.bh), through a crust covering both (bent pipe within PIE_BENT km, lasers
|
||||
past that). Its capacity is booked after terminals and before sky circuits: min(the dish's room, the landing dish's room,
|
||||
|
|
@ -25,7 +26,7 @@ const PIE_C=300,PIE_RE=6371,PIE_MIN_KM=3000,PIE_BENT=1000,PIE_HOP=1,PIE_FOOT=3,P
|
|||
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;
|
||||
const pieLased=id=>pieLiveLas(id)>CRUSTS[id].full*PIE_RAW;
|
||||
// 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)
|
||||
|
|
@ -40,7 +41,7 @@ function pieLand(c,t,ds,hubs){const T=BIZ_T[t],cc=CITY[c].cc;let best=null,bk=In
|
|||
return best;}
|
||||
function pieGraph(adj,edges,COMP,pops,NE){const NC=CITIES.length,hubs=pieHubs(),ds=pieDishes();
|
||||
const X={hubs,ds,term:{},gs:{},gsBw:{},cr:{},isl:[],l2o:{},l2p:{},up:[],ne:NE,adj,nc:NC,sk:[],bh:[],bhNo:[],res:{},main:-1};
|
||||
for(const id of hubs)X.cr[id]=CRUSTS[id].g*pieCov(id);
|
||||
for(const id of hubs)X.cr[id]=pieCap(id);
|
||||
// The backbone: the island with the most POPs (ties: the home city's).
|
||||
const cnt=new Map();for(const p of pops){const k=COMP[CIDX[p]];if(k>=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;}X.main=main;
|
||||
|
|
@ -123,8 +124,8 @@ function pieLoads(X,flows,used,term,bhG){const P=S.pie,cu={},crust=[],dish=[],lo
|
|||
// Backhaul booked its capacity from X.cr; count what it carried instead.
|
||||
const bx={};for(const e of X.bh){const id=e.bh.cr;bx[id]=(bx[id]||0)+Math.min(e.cap,e.ld||0)-e.cap;}
|
||||
for(const f of flows)if(f.k==='c'&&f.g>0){let r=f.g;const e=X.l2p[f.id].w.path.find(x=>x.sky==='las');for(const id of e?e.cs:[]){const t=Math.min(r,Math.max(0,X.cr[id]-(cu[id]||0)));cu[id]=(cu[id]||0)+t;r-=t;}}
|
||||
for(const id in CRUSTS){if(!(pieLive(id)>0))continue;const cv=pieCov(id),pot=CRUSTS[id].g*cv,hub=X.hubs.includes(id);
|
||||
crust.push({id,cov:cv,pot,cap:hub?pot:0,used:hub?Math.min(pot,pot-X.cr[id]+(cu[id]||0)+(bx[id]||0)):0,las:hub&&pieLased(id),st:hub?'ok':!pieBaked(id)?'half':P.safe?'safe':'down'});}
|
||||
for(const id in CRUSTS){if(!(pieLive(id)>0))continue;const cv=pieCov(id),hub=X.hubs.includes(id),pot=hub?pieCap(id):CRUSTS[id].g*cv;
|
||||
crust.push({id,cov:cv,pot,cap:hub?pot:0,used:hub?Math.min(pot,pot-X.cr[id]+(cu[id]||0)+(bx[id]||0)):0,las:hub&&pieLased(id),st:hub?(pieBaked(id)?'ok':'part'):!(pieCarry(id)>0)?'half':P.safe?'safe':'down'});}
|
||||
const ok=new Map(X.ds.map(d=>[d.city,d])),isl=new Set(X.isl),las=X.hubs.filter(pieLased),bh=new Set(X.bh.map(e=>e.a));
|
||||
for(const x of P.dishes){const c=x.city,d=ok.get(c),tm=d?term[c]:0,u0=d?used[c]:0,cap=d?d.g:0,cc=CITY[c].cc,l=P.lic[cc];let st;
|
||||
if(!S.pops[c])st='nopop';else if(x.down>S.day)st='down';else if(!d)st=l&&l.until>S.day&&l.state==='sus'?'spat':l&&l.until>S.day&&l.state==='refused'?'ref':'lic';
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
What an incident does is read back from S.inc, so nothing else has to be undone. A booster that tips over on the drone
|
||||
ship is in pieFly(); the astronomers ask a question, so they live with the spats (65-pie-spats.js). */
|
||||
const PIE_INC=['piedig','piefood','pielaser','pierain','piestorm'],PIE_TROPIC=23.5,PIE_ROOMBA=120e6,PIE_FOOD_MUL=0.25,PIE_INC_RATE=1/40,
|
||||
PIE_DIG_FIX=300000,PIE_RAIN=0.3,PIE_ASTRO_N=200;
|
||||
PIE_DIG_FIX=300000,PIE_RAIN=0.3,PIE_ASTRO_N=200,PIE_HIT=0.1;
|
||||
// PIE_HIT: the most of a crust one incident may take (a storm 2 to 10% over its week, a food fight 5 to 10%), so a bad
|
||||
// week hurts but never empties the sky.
|
||||
FOUNDER_POSTS.push(N_('pie.fp_3am'),N_('pie.fp_astro'),N_('pie.fp_debris'),N_('pie.fp_spat'),N_('pie.fp_storm'));
|
||||
// Chaos on, a company to annoy, and the 90 quiet days are over.
|
||||
function pieChaos(){const P=S&&S.pie;return !!P&&!!P.co&&chaosMul()>0&&S.day-P.born>=PIE_QUIET;}
|
||||
|
|
@ -21,11 +23,11 @@ function pieIncClear(i){if(i.type!=='piedig'||!S.pie)return;const x=S.pie.dishes
|
|||
// sanitize(): orbit incidents point at a crust or a city, and go when the company does.
|
||||
function pieIncFix(s){const ok=!!s.pie;s.inc=s.inc.filter(i=>{if(!PIE_INC.includes(i.type))return true;if(!ok)return false;
|
||||
if(['piefood','pielaser','piestorm'].includes(i.type)?!own(CRUSTS,i.ref):!isCity(i.ref))return false;
|
||||
i.start=int(i.start,0,s.day,s.day);i.until=int(i.until,0,s.day+400,s.day);if(i.type==='piestorm')i.f=clamp(num(i.f,0),0,0.4);return true;});}
|
||||
i.start=int(i.start,0,s.day,s.day);i.until=int(i.until,0,s.day+400,s.day);if(i.type==='piestorm')i.f=clamp(num(i.f,0),0,PIE_HIT);return true;});}
|
||||
// One day of a storm (its first is the day it starts; the day tick resolves it on its last).
|
||||
function pieStormBite(i){if(!own(CRUSTS,i.ref))return;const n=Math.max(1,i.until-i.start),q=(1-Math.pow(1-i.f,1/n))*(S.pie.safe?0.25:1);i.lost=(i.lost|0)+pieLose(i.ref,q);}
|
||||
// Pies lost from every cohort of a crust alike.
|
||||
function pieLose(cr,q){const c=S.pie.crusts[cr];let lost=0;for(const k of c.cohorts){const x=Math.min(k.n,Math.round(k.n*q));k.n-=x;lost+=x;}c.cohorts=c.cohorts.filter(k=>k.n>=1);return lost;}
|
||||
// Pies lost from every cohort of a crust alike (counted as they fly: a worn cohort loses its worn share).
|
||||
function pieLose(cr,q){const c=S.pie.crusts[cr],life=CRUSTS[cr].life;let lost=0;for(const k of c.cohorts){const x=Math.min(k.n,Math.round(k.n*q));lost+=x?pieAlive(k,life)*x/k.n:0;k.n-=x;}c.cohorts=c.cohorts.filter(k=>k.n>=1);return Math.round(lost);}
|
||||
function pieIncToast(i,press,acts=[]){toast(`<b>🛰️ ${pieIncTitle(i.type)}</b><br>${esc(i.msg)}<br><i>${esc(press)}</i>`,'bad',(i.cost?[{l:`${i.fix||tr('common.rush_repair')} ${fmt$(i.cost)}`,act:'fixInc',args:{id:i.id}}]:[]).concat(acts),incOpen(i));sfx('alert');}
|
||||
const pieAdd=o=>{addInc(o);return S.inc[S.inc.length-1];};
|
||||
function pieIncDay(d){
|
||||
|
|
@ -48,10 +50,10 @@ function pieIncOpts(){const P=S.pie,o=[],live=id=>pieLive(id),dish=x=>!!S.pops[x
|
|||
function pieIncFire(k){const P=S.pie;if(!P||!P.co)return false;const d=S.day;
|
||||
if(!k){const o=pieIncOpts();let r=Math.random()*o.reduce((a,x)=>a+x[1],0);k=o[o.length-1][0];for(const x of o){r-=x[1];if(r<=0){k=x[0];break;}}}
|
||||
const crs=f=>Object.keys(CRUSTS).filter(f);
|
||||
if(k==='storm'){const c=crs(id=>pieLive(id)>0&&!pieIncOf('piestorm',id));if(!c.length)return false;const cr=pick(c),f=+(0.05+Math.random()*0.35).toFixed(3);
|
||||
if(k==='storm'){const c=crs(id=>pieLive(id)>0&&!pieIncOf('piestorm',id));if(!c.length)return false;const cr=pick(c),f=+(PIE_HIT/5+Math.random()*PIE_HIT*4/5).toFixed(3);
|
||||
const i=pieAdd({type:'piestorm',ref:cr,until:d+7,f,lost:0,cost:0,msg:tr('pie_inc.storm_msg',{crust:tr(CRUSTS[cr].n),p:pct(f)})});pieFounder(N_('pie.fp_storm'),{c:cr});pieStormBite(i);
|
||||
pieIncToast(i,tr('pie_inc.storm_press'),P.safe?[]:[{l:tr('pie_inc.safe_now'),act:'pieSafe',args:{}}]);return true;}
|
||||
if(k==='food'){const c=crs(id=>pieLive(id)>=100&&!pieIncOf('piefood',id));if(!c.length)return false;const cr=pick(c),n=pieLose(cr,0.1+Math.random()*0.1);
|
||||
if(k==='food'){const c=crs(id=>pieLive(id)>=100&&!pieIncOf('piefood',id));if(!c.length)return false;const cr=pick(c),n=pieLose(cr,PIE_HIT/2+Math.random()*PIE_HIT/2);
|
||||
const i=pieAdd({type:'piefood',ref:cr,until:d+360,cost:piePrice(PIE_ROOMBA),fix:tr('pie_inc.food_fix'),msg:tr('pie_inc.food_msg',{crust:tr(CRUSTS[cr].n),n,p:pct(PIE_FOOD_MUL)})});
|
||||
pieFounder(N_('pie.fp_debris'),{c:cr});pieIncToast(i,tr('pie_inc.food_press'));compute();return true;}
|
||||
if(k==='rain'){const c=P.dishes.filter(x=>S.pops[x.city]&&Math.abs(CITY[x.city].lat)<=PIE_TROPIC&&!pieIncOf('pierain',x.city));if(!c.length)return false;const x=pick(c);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function dayPost(d){
|
|||
const ids=linkIds(),frr=(coreFrr()&&S.links.some(l=>l.cut)?.5:1)*(rule('moods')==='patient'?.5:1);const bhT=new Set(ddosAll().filter(a=>a.bh).map(a=>a.tgt));for(const b of S.biz.slice()){if(eventTick(b,d)||capPendTick(b,d))continue;b.pm=b.mood;if(bhT.has(b.id))continue;const sf=bizSf(b,ids),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99||scnRule('local'),scrubOk=b.type!=='scrub'||(hasScrub()&&!scrubFar(b.city)),divOk=reqOk(b);
|
||||
if(sf>=0.95&&reachOk&&scrubOk&&divOk)b.mood=Math.min(100,b.mood+2);
|
||||
else if(S.day-(b.since||0)<15){}
|
||||
else{b.mood-=frr*(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));
|
||||
else{const dm=frr*(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));b.mood-=BIZ_T[b.type].orbit?Math.min(dm,PIE_PATIENCE):dm;
|
||||
if(b.mood<=0){S.biz=S.biz.filter(x=>x!==b);toast(tr('day_tick.name_cancelled_too_many_outages_and',{name:esc(b.name),city:CITY[b.city].name}),'bad');sfx('err');}
|
||||
else if(b.mood<30&&!b.warned){b.warned=b.warn60=true;const why=bizWhy(b)[0],paused=pref('pauseFurious')&&autoPause();
|
||||
toast(tr('day_tick.name_is_furious_fix_service_in',{name:esc(b.name),city:CITY[b.city].name})+(why?`<br><i>${esc(why)}</i>`:'')+(paused?`<br><b>${tr('common.game_paused')}</b>`:''),'bad',[{l:tr('common.show_me'),act:'custGo',args:{id:b.id}}].concat(paused?[resumeAct()]:[]));sfx('err');}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ const pieBar=(u,cls)=>`<div class="bar ${cls}"><i style="width:${Math.round(clam
|
|||
function pieDishWhy(d){const cc=CITY[d.city].cc,l=S.pie.lic[cc];return {nopop:tr('pie_traffic.d_nopop'),down:tr('pie_traffic.d_down'),lic:tr('pie_traffic.d_lic',{country:esc(pieLicCountry(cc))}),
|
||||
ref:tr('pie_traffic.d_ref'),backhaul:tr('pie_traffic.d_backhaul'),spat:tr('pie_traffic.d_spat',{d:l?dateStr(l.until):''}),nocrust:tr('pie_traffic.d_nocrust'),isl:tr('pie_traffic.d_isl'),rain:tr('pie_traffic.d_rain'),
|
||||
jam:tr('pie_traffic.d_jam'),nolas:tr('pie_traffic.d_nolas'),idle:tr('pie_traffic.d_idle')}[d.st]||'';}
|
||||
function pieCrustWhy(c){return c.st==='half'?tr('pie_traffic.crust_half',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),min:pct(PIE_BAKED)}):c.st==='safe'?tr('pie_traffic.crust_safe'):c.st==='down'?tr('pie_traffic.crust_down'):'';}
|
||||
function pieCrustWhy(c){return c.st==='half'?tr('pie_traffic.crust_half',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),min:pct(PIE_RAW)}):c.st==='part'?tr('pie_traffic.crust_part',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),c:pct(pieCarry(c.id)),min:pct(PIE_BAKED)}):c.st==='safe'?tr('pie_traffic.crust_safe'):c.st==='down'?tr('pie_traffic.crust_down'):'';}
|
||||
// Why a cut-off POP gets no backhaul (R.pie.bh[].why from pieBhLand).
|
||||
function pieBhWhy(w){return {nocrust:tr('pie_traffic.bh_nocrust'),noland:tr('pie_traffic.bh_noland'),nolas:tr('pie_traffic.bh_nolas',{km:PIE_BENT.toLocaleString()}),spat:tr('pie_traffic.bh_spat'),full:tr('pie_traffic.bh_full_none')}[w]||tr('pie_traffic.bh_noland');}
|
||||
// The empty sky: every condition traffic needs, ticked or not, with a hint for the first thing to fix.
|
||||
function pieChecks(Q){const P=S.pie,cr=Q.crust,best=cr.slice().sort((a,b)=>b.cov-a.cov)[0],ds=Q.dish,isl=ds.find(d=>d.st==='isl'),bh=Q.bh||[],no=bh.find(b=>!(b.cap>0));
|
||||
const sold=S.biz.some(b=>BIZ_T[b.type].orbit||(BIZ_T[b.type].lat&&b.route==='fast'&&b.city2&&pieKm(b.city,b.city2)>=PIE_MIN_KM));
|
||||
return [
|
||||
{k:'baked',ok:Q.hubs.length>0,l:tr('pie_traffic.ck_baked',{min:pct(PIE_BAKED)}),h:!best?tr('pie_traffic.ck_baked_none'):pieCrustWhy(best)||tr('pie_traffic.ck_baked_none')},
|
||||
{k:'baked',ok:Q.hubs.length>0,l:tr('pie_traffic.ck_baked',{min:pct(PIE_RAW)}),h:!best?tr('pie_traffic.ck_baked_none'):pieCrustWhy(best)||tr('pie_traffic.ck_baked_none')},
|
||||
{k:'dish',ok:ds.some(d=>d.cap>0),l:tr('pie_traffic.ck_dish'),h:P.dishes.length?tr('pie_traffic.ck_dish_lic'):tr('pie_traffic.ck_dish_none')},
|
||||
{k:'backbone',ok:ds.some(d=>d.cap>0&&!Q.isl.includes(d.city)),l:tr('pie_traffic.ck_backbone'),h:Q.isl.length?tr('pie_traffic.ck_backbone_bh',{city:pieCn(isl?isl.city:Q.isl[0])}):tr('pie_traffic.ck_backbone_none')},
|
||||
...(Q.isl.length?[{k:'backhaul',ok:bh.some(b=>b.cap>0)&&!no,l:tr('pie_traffic.ck_backhaul'),h:no?tr('pie_traffic.ck_backhaul_h',{city:pieCn(no.city),why:pieBhWhy(no.why)}):''}]:[]),
|
||||
|
|
@ -43,8 +43,8 @@ function pieTrafficHtml(){const Q=R&&R.pie;if(!Q||!Q.flows)return `<p class="met
|
|||
let h=`<p class="pft-head">${trn('pie_traffic.headline',n,{g:fmtG(g),of:fmtG(pieMarket()),amt:fmt$(Q.rev)})}</p>`;
|
||||
if(!(g>0)&&!(bg>0))h+=`<div class="ops-o pft-why"><div class="nm">${tr('pie_traffic.empty_title')}</div><ul class="pft-ck">${pieChecks(Q).map(c=>`<li class="${c.ok?'on':'off'}" data-k="${c.k}"><span aria-hidden="true">${c.ok?'✅':'⬜'}</span><span><b>${c.l}</b>${c.ok?'':`<small>${c.h}</small>`}</span></li>`).join('')}</ul></div>`;
|
||||
h+=`<h3 class="pft-h">${tr('pie_traffic.crusts')}</h3>`+(Q.crust.length?Q.crust.map(c=>{const why=pieCrustWhy(c);
|
||||
return `<div class="pft-cr"><div class="kv"><span>${tr(CRUSTS[c.id].n)} ${pieTag(c.st==='half'?tr('pie.half_baked'):tr('pie.baked'),c.st!=='half')}</span><b>${c.cap>0?tr('pie_traffic.used_of',{u:fmtG(c.used),cap:fmtG(c.cap)}):pct(c.cov)}</b></div>
|
||||
${c.cap>0?pieBar(c.used/c.cap,pieLoadCls(c.used/c.cap)):pieBar(c.cov/PIE_BAKED,'warn')}${why?`<p class="meta">${why}</p>`:''}</div>`;}).join(''):`<p class="meta">${tr('pie_traffic.ck_baked_none')}</p>`);
|
||||
return `<div class="pft-cr"><div class="kv"><span>${tr(CRUSTS[c.id].n)} ${pieTag(c.st==='half'||c.st==='part'?tr('pie.half_baked'):tr('pie.baked'),c.st!=='half'&&c.st!=='part')}</span><b>${c.cap>0?tr('pie_traffic.used_of',{u:fmtG(c.used),cap:fmtG(c.cap)}):pct(c.cov)}</b></div>
|
||||
${c.cap>0?pieBar(c.used/c.cap,pieLoadCls(c.used/c.cap)):pieBar(c.cov/PIE_RAW,'warn')}${why?`<p class="meta">${why}</p>`:''}</div>`;}).join(''):`<p class="meta">${tr('pie_traffic.ck_baked_none')}</p>`);
|
||||
if(bh.length)h+=`<h3 class="pft-h">${tr('pie_traffic.backhaul')}</h3><p class="meta">${tr('pie_traffic.bh_hint')}</p>`+bh.slice().sort((a,b)=>b.g-a.g).map(pieBhRow).join('');
|
||||
if(fl.length){h+=`<h3 class="pft-h">${tr('pie_traffic.riding')}</h3><p class="meta">${tr('pie_traffic.tap_hint')}</p><div class="pft-list">${fl.slice(0,PIE_ROWS).map(f=>pieFlowRow(f,B)).join('')}</div>`;
|
||||
if(fl.length>PIE_ROWS)h+=`<p class="meta">${trn('pie_traffic.n_more',fl.length-PIE_ROWS)}</p>`;}
|
||||
|
|
|
|||
|
|
@ -3471,7 +3471,7 @@
|
|||
"pie.sandbox_note":"Sandbox: nothing here costs real money. You would have spent {amt} so far.",
|
||||
"pie.spent":"Spent so far",
|
||||
"pie.stock_line":"{n} pies ready at the factory.",
|
||||
"pie.t_baked":"{crust} is baked: enough pies to carry traffic.",
|
||||
"pie.t_baked_all":"{crust} is baked: enough pies to carry all its traffic.",
|
||||
"pie.t_booster":"The booster did not come back. A new one costs money.",
|
||||
"pie.t_dish":"Pie dish built in {city}.",
|
||||
"pie.t_factory":"The pie factory is open: {n} pies a month.",
|
||||
|
|
@ -3626,6 +3626,7 @@
|
|||
"pie_traffic.ck_lasers_h":"Without lasers, traffic only reaches a dish within 1,000 km and nothing crosses space. Launch pies with lasers.",
|
||||
"pie_traffic.crust_down":"Out of service for now (a solar storm).",
|
||||
"pie_traffic.crust_half":"{crust} is {p} baked; it carries traffic from {min}.",
|
||||
"pie_traffic.crust_part":"{crust} is {p} baked: half-baked, it carries {c} of its traffic, all of it from {min}.",
|
||||
"pie_traffic.crust_safe":"Safe mode is on: it carries nothing until you turn it off.",
|
||||
"pie_traffic.crusts":"Crusts",
|
||||
"pie_traffic.d_backhaul":"backhauls its own town through orbit",
|
||||
|
|
|
|||
|
|
@ -550,11 +550,17 @@ const orbit = (las = true, n = 'CRUSTS.short.full') => { const g = load();
|
|||
g.sky = (id) => g.ev(`Object.keys(R.ef).some(k=>k.startsWith('pie:')&&R.ef[k].eg['l2:${id}']>0)`);
|
||||
return g; };
|
||||
|
||||
test('O2: a half-baked crust carries nothing; orbit never carries more than the dishes', () => {
|
||||
const g = orbit(true, 'Math.floor(CRUSTS.short.full*0.59)');
|
||||
test('O2: a crust carries nothing under 40% and a growing share up to 60%; orbit never carries more than the dishes', () => {
|
||||
const g = orbit(true, 'Math.floor(CRUSTS.short.full*0.39)');
|
||||
g.c('h', 'lon', 'nyc'); g.c('p', 'pcn', null, 'pizza', 50);
|
||||
assert.equal(g.sky('h'), false, 'O2: a half-baked crust carried a circuit');
|
||||
assert.equal(g.ev('R.pie.sf.p'), 0, 'O2: a half-baked crust served a terminal');
|
||||
assert.equal(g.sky('h'), false, 'O2: a crust under 40% carried a circuit');
|
||||
assert.equal(g.ev('R.pie.sf.p'), 0, 'O2: a crust under 40% served a terminal');
|
||||
// from 40% to 60% the share it carries grows from nothing to all of its pies' capacity: a slope, not a cliff
|
||||
const cap = (p) => g.ev(`S.pie.crusts.short.cohorts=[{n:Math.round(CRUSTS.short.full*${p}),day:S.day,las:true}];compute();(R.pie.crust.find(c=>c.id==='short')||{cap:0}).cap`);
|
||||
const caps = [0.4, 0.45, 0.5, 0.55, 0.6, 0.8].map(cap), G = g.ev('CRUSTS.short.g');
|
||||
assert.ok(caps[0] < G * 0.01, `O2: at 40% it carries ${caps[0]} G`);
|
||||
for (let i = 1; i < caps.length; i++) assert.ok(caps[i] > caps[i - 1], `O2: more pies, more traffic (${caps.join(', ')})`);
|
||||
assert.ok(Math.abs(caps[4] - G * 0.6) < G * 0.01 && Math.abs(caps[5] - G * 0.8) < G * 0.01, 'O2: baked from 60%, all of its coverage carries');
|
||||
g.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:'b'+i,type:'boat',city:'pcn',city2:null,bw:800,rate:1,reqs:[],route:'normal',name:'b'+i,mood:100,since:0,sites:null});compute()");
|
||||
for (const d of JSON.parse(g.ev('JSON.stringify(pieDishes())'))) assert.ok(g.ev(`R.pie.used.${d.city}`) <= d.g + 1e-6, `O2: the ${d.city} dish carries ${g.ev(`R.pie.used.${d.city}`)} G on ${d.g} G of antennas`);
|
||||
assert.deepEqual(g.errors, []);
|
||||
|
|
|
|||
|
|
@ -144,12 +144,18 @@ test('O5: launches only fail with chaos on, and never in the first 90 days', ()
|
|||
assert.equal(ev("pieLive('short')"), 20, 'chaos none: nothing fails');
|
||||
});
|
||||
|
||||
test('cohorts decay past their life, and a crust is half-baked under 60%', () => {
|
||||
test('cohorts wear out over the end of their life, and a crust carries a share from 40%, all of it from 60%', () => {
|
||||
const { ev, errors } = load();
|
||||
won(ev);
|
||||
company(ev);
|
||||
ev("S.pie.crusts.short.cohorts.push({n:900,day:S.day,las:false})");
|
||||
ev("S.pie.crusts.short.cohorts.push({n:600,day:S.day,las:false})");
|
||||
assert.equal(ev("pieUp('short')"), false, `${ev("pct(pieCov('short'))")} carries nothing`);
|
||||
ev("S.pie.crusts.short.cohorts[0].n=Math.round(CRUSTS.short.full*0.5)");
|
||||
assert.equal(ev("pieBaked('short')"), false, `${ev("pct(pieCov('short'))")} is half-baked`);
|
||||
assert.equal(ev("pieUp('short')"), true, 'but over 40% it carries something');
|
||||
assert.ok(Math.abs(ev("pieCarry('short')") - 0.5) < 0.01, 'half way from 40% to 60%: half of it');
|
||||
assert.ok(Math.abs(ev("pieCap('short')") - ev('CRUSTS.short.g*0.25')) < ev('CRUSTS.short.g') * 0.01, 'half its capacity at half coverage');
|
||||
ev("S.pie.crusts.short.cohorts[0].n=900");
|
||||
ev("S.pie.crusts.short.cohorts.push({n:60,day:S.day,las:true})");
|
||||
assert.equal(ev("pieBaked('short')&&pieUp('short')"), true, '60% bakes it');
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify(pieHubs())')), ['short']);
|
||||
|
|
@ -161,7 +167,15 @@ test('cohorts decay past their life, and a crust is half-baked under 60%', () =>
|
|||
assert.equal(g.crusts.find((c) => c.id === 'short').n, 960);
|
||||
assert.equal(g.crusts.find((c) => c.id === 'short').las, 60);
|
||||
assert.equal(g.pads[0].city, 'sin');
|
||||
ev("S.day+=CRUSTS.short.life;pieDay(S.day)");
|
||||
// wear: in full until the last PIE_WEAR of their life, then a few fewer every day, gone at its end
|
||||
const life = ev('CRUSTS.short.life'), w = Math.round(life * ev('PIE_WEAR'));
|
||||
const at = (d) => ev(`S.day=S.pie.crusts.short.cohorts[0].day+${d};pieLive('short')`);
|
||||
assert.equal(at(life - w), 960, 'in full until they start to wear');
|
||||
const mid = at(life - w / 2), late = at(life - 10);
|
||||
assert.ok(Math.abs(mid - 480) <= 1, `half worn out half way (${mid})`);
|
||||
assert.ok(late > 0 && late < mid && late <= 960 * 10 / w + 1, `a few left near the end (${late})`);
|
||||
for (let d = life - w; d < life; d += 7) assert.ok(at(d) - at(d + 7) <= Math.ceil(960 * 7 / w) + 1, `no cliff at day ${d}`);
|
||||
ev("S.day=S.pie.crusts.short.cohorts[0].day+CRUSTS.short.life;pieDay(S.day)");
|
||||
assert.equal(ev("pieLive('short')"), 0, 'old pies deorbit');
|
||||
assert.equal(ev('S.pie.crusts.short.cohorts.length'), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ test('a seeded year in orbit is the same every time, and things do happen', () =
|
|||
assert.match(a, /pie/, 'a year of BGP at 3 a.m. brings something to orbit');
|
||||
});
|
||||
|
||||
test('solar storm: a crust loses 5 to 40% in a week, safe mode saves most of it', () => {
|
||||
test('solar storm: a crust loses 2 to 10% in a week, safe mode saves most of it', () => {
|
||||
const storm = (safe) => {
|
||||
const { ev, errors } = load();
|
||||
sky(ev);
|
||||
ev(`window.__n0={};for(const id in CRUSTS)__n0[id]=pieLive(id);S.pie.safe=${safe};Math.random=()=>0.99;pieIncFire('storm')`);
|
||||
const i = ev("JSON.stringify(S.inc.find(i=>i.type==='piestorm'))");
|
||||
const o = JSON.parse(i), cr = o.ref, n0 = ev(`__n0['${cr}']`);
|
||||
assert.ok(o.f >= 0.05 && o.f <= 0.4, `loss share ${o.f}`);
|
||||
assert.ok(o.f >= 0.02 && o.f <= 0.1, `loss share ${o.f}`);
|
||||
assert.equal(o.until - ev('S.day'), 7, 'a week');
|
||||
assert.ok(ev("S.log.some(e=>/press office/i.test(e.t))"), 'the press office has a line');
|
||||
ev('for(let d=0;d<7;d++){S.day++;pieIncDay(S.day)}');
|
||||
|
|
@ -178,7 +178,7 @@ test('sanitize drops orbit incidents that make no sense, and old saves are untou
|
|||
ev("S.inc.push({id:'x1',type:'piestorm',ref:'nope',until:S.day+3,msg:'',cost:0},{id:'x2',type:'pierain',ref:'atlantis',until:S.day+3,msg:'',cost:0},{id:'x3',type:'piestorm',ref:'short',start:-5,until:1e9,f:9,msg:'',cost:0})");
|
||||
ev('S=migrate(JSON.parse(JSON.stringify(S)));compute()');
|
||||
assert.equal(ev("S.inc.filter(i=>i.type.startsWith('pie')).length"), 3);
|
||||
assert.ok(ev("S.inc.filter(i=>i.type==='piestorm').every(i=>i.f<=0.4&&i.until<=S.day+400)"), 'clamped');
|
||||
assert.ok(ev("S.inc.filter(i=>i.type==='piestorm').every(i=>i.f<=0.1&&i.until<=S.day+400)"), 'clamped');
|
||||
// an old save: no pie, no orbit incidents survive
|
||||
ev("const o=JSON.parse(JSON.stringify(S));delete o.pieV;delete o.pie;S=migrate(o)");
|
||||
assert.equal(ev("S.inc.some(i=>i.type.startsWith('pie'))"), false);
|
||||
|
|
@ -186,3 +186,17 @@ test('sanitize drops orbit incidents that make no sense, and old saves are untou
|
|||
ev('for(let i=0;i<30;i++)dayTick()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('no single incident takes more than a tenth of a crust', () => {
|
||||
const { ev, errors } = load();
|
||||
sky(ev);
|
||||
ev("window.__n0={};for(const id in CRUSTS)__n0[id]=pieLive(id);Math.random=()=>0.9999;pieIncFire('food')");
|
||||
const i = JSON.parse(ev("JSON.stringify(S.inc.find(i=>i.type==='piefood'))")), n0 = ev(`__n0['${i.ref}']`), after = ev(`pieLive('${i.ref}')`);
|
||||
assert.ok(n0 - after > 0 && (n0 - after) / n0 <= ev('PIE_HIT') + 0.005, `a food fight took ${n0 - after} of ${n0}`);
|
||||
ev("S.inc=[];Math.random=()=>0.9999;pieIncFire('storm')");
|
||||
const s = JSON.parse(ev("JSON.stringify(S.inc.find(i=>i.type==='piestorm'))")), m0 = ev(`pieLive('${s.ref}')`);
|
||||
ev('for(let d=0;d<7;d++){S.day++;pieIncDay(S.day)}');
|
||||
const lost = 1 - ev(`pieLive('${s.ref}')`) / m0;
|
||||
assert.ok(s.f <= 0.1 && lost <= 0.1 + 0.005, `the worst storm took ${lost}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,15 +52,23 @@ test('O4: short routes never use orbit, and neither does bulk or plain IP traffi
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('O2: a half-baked crust carries nothing, and orbit never carries more than the dishes hold', () => {
|
||||
test('O2: a crust carries nothing under 40%, a share up to 60%, and orbit never carries more than the dishes hold', () => {
|
||||
const { ev, errors } = load();
|
||||
world(ev, { n: 'Math.floor(CRUSTS.short.full*0.59)' });
|
||||
world(ev, { n: 'Math.floor(CRUSTS.short.full*0.39)' });
|
||||
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);
|
||||
// half-baked at 50%: a quarter of the crust's Gbps (half its pies, half of those carrying) and a quarter of the market
|
||||
ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full/2,day:S.day,las:true}];compute()");
|
||||
assert.deepEqual(ev('JSON.stringify(pieHubs())'), '["short"]', 'over 40% it is a hub');
|
||||
assert.ok(ev('R.pie.sf.pz') > 0.9, 'and serves the home on Pitcairn');
|
||||
const c = JSON.parse(ev("JSON.stringify(R.pie.crust.find(c=>c.id==='short'))"));
|
||||
assert.equal(c.st, 'part');
|
||||
assert.ok(Math.abs(c.cap - ev('CRUSTS.short.g') / 4) < 1, `carries ${c.cap} of ${ev('CRUSTS.short.g')} G at 50%`);
|
||||
assert.ok(Math.abs(ev('pieMarket()') - ev('CRUSTS.short.g*PIE_SELL/4')) < 1, 'the market shrinks with it');
|
||||
// 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)');
|
||||
|
|
@ -171,3 +179,21 @@ test('orbit earnings go into the book, day by day', () => {
|
|||
assert.ok(Math.abs(ev('S.pie.book.earned') - mo) / mo < 0.05, `${ev('S.pie.book.earned')} ≈ ${mo}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('orbit customers sit out a bad month: at most PIE_PATIENCE happiness a day, then they cancel', () => {
|
||||
const { ev, errors } = load();
|
||||
world(ev);
|
||||
term(ev, 'pz', 'pcn');
|
||||
ev("S.biz.find(b=>b.id==='pz').since=-100");
|
||||
assert.ok(ev('R.pie.sf.pz') > 0.9, 'served');
|
||||
ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full*0.3,day:S.day,las:true}];compute()");
|
||||
assert.equal(ev('R.pie.sf.pz'), 0, 'the sky has a gap');
|
||||
ev('for(let i=0;i<10;i++)dayTick()');
|
||||
const m = ev("(S.biz.find(b=>b.id==='pz')||{mood:-1}).mood");
|
||||
assert.ok(m >= 100 - 10 * ev('PIE_PATIENCE') - 1e-9 && m < 100, `ten bad days: grumpy (${m}), not gone`);
|
||||
ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:true}];compute();for(let i=0;i<5;i++)dayTick()");
|
||||
assert.ok(ev("S.biz.find(b=>b.id==='pz').mood") > m, 'the sky back: happier again');
|
||||
ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full*0.3,day:S.day,las:true}];compute();for(let i=0;i<40;i++)dayTick()");
|
||||
assert.equal(ev("S.biz.some(b=>b.id==='pz')"), false, 'a month and more of nothing: cancelled');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -103,15 +103,19 @@ const checks = (dom) => Object.fromEntries([...doc(dom).querySelectorAll('#modal
|
|||
test('an empty sky says why: a half-baked crust', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
ev('window.innerWidth=360');
|
||||
world(ev, { n: 'Math.floor(CRUSTS.short.full*0.41)' });
|
||||
world(ev, { n: 'Math.floor(CRUSTS.short.full*0.39)' });
|
||||
term(ev, 'pz', 'dub');
|
||||
ev("ACT.pieTab({t:'traffic'})");
|
||||
const txt = doc(dom).querySelector('#modalCard').textContent;
|
||||
assert.match(txt, /Why is my sky empty\?/);
|
||||
assert.equal(checks(dom).baked, 'off');
|
||||
assert.match(txt, /Shortcrust \(550 km\) is 41% baked; it carries traffic from 60%/);
|
||||
assert.match(txt, /Shortcrust \(550 km\) is 39% baked; it carries traffic from 40%/);
|
||||
assert.equal(checks(dom).customers, 'on');
|
||||
ev('closeModal()');
|
||||
try {
|
||||
ev("S.pie.crusts.short.cohorts[0].n=CRUSTS.short.full/2;compute();ACT.pieTab({t:'traffic'})");
|
||||
assert.match(doc(dom).querySelector('#modalCard').textContent, /is 50% baked: half-baked, it carries 50% of its traffic, all of it from 60%/);
|
||||
} finally { ev('closeModal()'); }
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue