adding classification and division yard updates, train collisions, engine and car updates, turnout improvements.

This commit is contained in:
Jesse
2026-08-04 21:03:17 -04:00
parent 4bba991f41
commit 821d3cdffa
26 changed files with 6876 additions and 2638 deletions
+19 -5
View File
@@ -113,6 +113,10 @@ export function summarize(
const reason = e.reason;
if (reason.startsWith('collision')) rev.collisionLoss += -e.delta;
else if (reason === 'freightLoad') rev.freightLoad += e.delta;
// `freightUnload` is its own reason on its own event (apply.ts). It used to be counted from
// `unloadBegan` instead — unloads STARTED, not Revenue EARNED — and the two differ by every
// unload that never finished.
else if (reason === 'freightUnload') rev.freightUnload += e.delta;
else if (reason === 'boarding') rev.passengerBoard += e.delta;
else if (reason === 'detraining') rev.passengerDetrain += e.delta;
}
@@ -129,12 +133,21 @@ export function summarize(
for (const i of intents) inc(intentCounts, i);
// An unload scores through the same event as a load completion in the reducer, so count the
// distinct operations directly.
rev.freightUnload = eventCounts['unloadBegan'] ?? 0;
rev.net = final.players.reduce((n, p) => n + p.revenue, 0);
const grossFreight = rev.freightLoad;
/**
* FREIGHT IS BOTH HALVES.
*
* A completed load and a completed unload each earn a point, on two distinct `revenueChanged`
* reasons — and this counted only the first, so `freightShare` reported roughly 60% of the
* freight actually earned. That is the number the "freight is only 13-18% of gross" finding was
* read from, and it drove the Gap 12 industry-density change.
*
* The comment that stood here claimed "an unload scores through the same event as a load
* completion in the reducer", which is not true: `apply.ts` emits `freightUnload` separately. It
* was a comment asserting a fact about code a few lines away, and it was wrong.
*/
const grossFreight = rev.freightLoad + rev.freightUnload;
const grossPassenger = rev.passengerBoard + rev.passengerDetrain;
const gross = grossFreight + grossPassenger;
@@ -347,7 +360,7 @@ export type StrategyBucket = {
* consistently outscore passenger specialists (or vice versa), it shows up here.
*/
export function strategyBuckets(all: GameStats[]): StrategyBucket[] {
const scored = all.filter((g) => g.revenue.freightLoad + g.revenue.passengerBoard + g.revenue.passengerDetrain > 0);
const scored = all.filter((g) => g.revenue.freightLoad + g.revenue.freightUnload + g.revenue.passengerBoard + g.revenue.passengerDetrain > 0);
const buckets: { label: string; test: (g: GameStats) => boolean }[] = [
{ label: 'passenger-only (freight 0%)', test: (g) => g.freightShare === 0 },
@@ -408,6 +421,7 @@ export function formatAggregate(all: GameStats[]): string {
out.push(' REVENUE (mean per game)');
out.push(` net ${num(meanOf(all, (g) => g.revenue.net))}`);
out.push(` from freight loads ${num(meanOf(all, (g) => g.revenue.freightLoad))}`);
out.push(` from freight unloads ${num(meanOf(all, (g) => g.revenue.freightUnload))}`);
out.push(` from passengers on ${num(meanOf(all, (g) => g.revenue.passengerBoard))}`);
out.push(` from passengers off ${num(meanOf(all, (g) => g.revenue.passengerDetrain))}`);
out.push(` lost to collisions ${num(-meanOf(all, (g) => g.revenue.collisionLoss))}`);