F1: economia headless, dati validati, generatore di mappa e salvataggi
- Base deterministica: Money, id tipizzati, DMath, XxHash64, calendario - 12 file dati con schemi, validatore di schema interno, validazione semantica e hash dei dati; viaferrea-tools validate-data - Generatore di mappa (rilievo, mare, priority-flood, fiumi, laghi, copertura, giacimenti, città, hub, industrie) e viaferrea-tools genmap - Economia: città, industrie, hub, mercato con componente mondiale, prezzi locali, tariffe, lavoro in sede e a piedi, trasporto locale, registro a partita doppia, prestiti, rating, difficoltà - Salvataggi Brotli con rimappatura per id e hash di stato giornaliero - viaferrea-tools simulate con KPI CSV; 45 test verdi; ADR 0002-0006 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
113 files changed
+12553
-23
No files matched your search
@@ -0,0 +1,53 @@
|
||||
using System.Diagnostics;
|
||||
using ViaFerrea.Core.Simulation.Systems;
|
||||
|
||||
namespace ViaFerrea.Core.Simulation;
|
||||
|
||||
/// <summary>
|
||||
/// Sistemi nell'ordine fisso della guida (sezione 4). I sistemi delle fasi successive si
|
||||
/// inseriscono nella loro posizione quando vengono implementati:
|
||||
/// Clock → Commands → Construction → Trains → Signals → Stations (+ trasporto locale)
|
||||
/// → Maintenance → Demand → Commuting → Industries → IndustryMaintenance → Towns → Market
|
||||
/// → Finance → StockMarket → AiAgents → Events → Contracts → Hash.
|
||||
/// </summary>
|
||||
public sealed class SystemPipeline(IReadOnlyList<ISimSystem> systems)
|
||||
{
|
||||
public IReadOnlyList<ISimSystem> Systems { get; } = systems;
|
||||
|
||||
/// <summary>Se attivo, misura il tempo di ogni sistema (diagnostica e bench).</summary>
|
||||
public bool Profile { get; set; }
|
||||
|
||||
/// <summary>Tick totali (Stopwatch) spesi per sistema quando Profile è attivo.</summary>
|
||||
public long[] ElapsedTicks { get; } = new long[systems.Count];
|
||||
|
||||
public static SystemPipeline CreateDefault() => new(
|
||||
[
|
||||
new ClockSystem(),
|
||||
new CommandSystem(),
|
||||
new LocalTransportSystem(),
|
||||
new DemandSystem(),
|
||||
new EmploymentSystem(),
|
||||
new IndustrySystem(),
|
||||
new TownSystem(),
|
||||
new MarketSystem(),
|
||||
new FinanceSystem(),
|
||||
new HashSystem(),
|
||||
]);
|
||||
|
||||
public void Run(WorldContext ctx)
|
||||
{
|
||||
if (!Profile)
|
||||
{
|
||||
for (int i = 0; i < Systems.Count; i++) Systems[i].Step(ctx);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < Systems.Count; i++)
|
||||
{
|
||||
long start = Stopwatch.GetTimestamp();
|
||||
Systems[i].Step(ctx);
|
||||
ElapsedTicks[i] += Stopwatch.GetTimestamp() - start;
|
||||
}
|
||||
}
|
||||
|
||||
public T Get<T>() where T : ISimSystem => Systems.OfType<T>().First();
|
||||
}
|
||||
Reference in new issue
Block a user