F2: pianificatore dei binari, profilo altimetrico e scenario Valdoria

- TrackGeometry: polilinea raccordata con il raggio della classe
- TrackPlanner: campioni ogni 25 m, due passate di pendenza, smussatura,
  franchi sui fiumi, classificazione delle opere, costi, giorni, vincoli
  per era (campate per classe di fiume, lunghezza delle gallerie)
- Scenari a mano (ScenarioLoader) e tests/scenarios/valdoria.json
- viaferrea-tools profile; industrie al prezzo globale; servizi di base

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
Claude committed 2026-10-01 22:54:57 +00:00
1 parent 7cb98fa206
commit 259e6ab65f
21 files changed
+1558 -16

No files matched your search

@@ -7,7 +7,7 @@ namespace ViaFerrea.Core.Simulation.Systems;
/// <summary>
/// Trasporto locale su strada (carrettieri, ADR 0004): piccole quantità tra produttori, consumatori
/// e hub vicinissimi, senza vettore. Tiene vivo il territorio senza rendere superflua la ferrovia.
/// Vendite e acquisti avvengono ai prezzi locali; le merci passano solo da un magazzino all'altro.
/// Vendite e acquisti avvengono al prezzo globale; le merci passano solo da un magazzino all'altro.
/// </summary>
public sealed class LocalTransportSystem : ISimSystem
{
@@ -36,7 +36,6 @@ public sealed class LocalTransportSystem : ISimSystem
}
}
var lp = w.Data.Balance.LocalPrice;
int dpm = w.Calendar.DaysPerMonth;
foreach (var producer in w.Industries)
{
@@ -47,7 +46,8 @@ public sealed class LocalTransportSystem : ISimSystem
int good = outputs[o].GoodIndex;
int available = Math.Min(lt.MaxUnitsPerDay, (int)Math.Ceiling(producer.OutputStock[o] * lt.DailyShare));
if (available <= 0) continue;
double sellPrice = Market.LocalPrice(w.Market.GlobalPrice[good], 0, producer.OutputStock[o], lp);
// le industrie comprano e vendono al prezzo globale (ADR 0004)
double sellPrice = w.Market.GlobalPrice[good];
foreach (var (ci, _) in _nearIndustries[producer.Id.Value])
{
@@ -58,7 +58,7 @@ public sealed class LocalTransportSystem : ISimSystem
int free = IndustryMath.InputCapacity(consumer, i, dpm) - consumer.InputStock[i];
int units = Math.Min(available, free);
if (units <= 0) continue;
double buyPrice = Market.LocalPrice(w.Market.GlobalPrice[good], consumer.InputDemandToday[i] * consumer.Def.StorageDays, consumer.InputStock[i], lp);
double buyPrice = w.Market.GlobalPrice[good];
producer.OutputStock[o] -= units;
consumer.InputStock[i] += units;
available -= units;
@@ -69,7 +69,7 @@ public sealed class TownSystem : ISimSystem
private static void Grow(WorldContext ctx, Town town)
{
var tb = ctx.Data.Balance.Town;
int services = 0;
int services = town.Population / Math.Max(1, tb.BaseServicesPerPopulation);
for (int c = 0; c < Town.CategoryCount; c++)
{
if (town.CategoryActive[c] && town.Satisfaction[c] >= tb.ServicesSatisfactionThreshold) services++;