Infrastruttura: nome «Rail Enterprise», CI e rilasci su Gitea, documentazione
Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6c2a17b4d
commit
c1a0049bcf
300 files changed
+1602
-1045
No files matched your search
@@ -0,0 +1,91 @@
|
||||
using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Core.Data;
|
||||
using RailEnterprise.Core.Economy;
|
||||
|
||||
namespace RailEnterprise.Core.Simulation;
|
||||
|
||||
/// <summary>
|
||||
/// Stimatori economici condivisi da IA e tooltip «perché» (12.1): ricavi per unità e per viaggio,
|
||||
/// tempi di giro, costi di costruzione ed esercizio. Leggono solo informazioni pubbliche.
|
||||
/// </summary>
|
||||
public static class Estimators
|
||||
{
|
||||
/// <summary>Ricavo per unità di merce su <paramref name="km"/> al prezzo globale corrente (centesimi).</summary>
|
||||
public static double FreightPerUnit(World w, int good, double km)
|
||||
{
|
||||
var t = w.Data.Balance.Tariffs;
|
||||
double priceFactor = t.FreightFixedWeight + t.FreightPriceWeight * w.Market.GlobalPrice[good] / w.Data.Goods[good].BasePrice;
|
||||
return t.FreightBaseRate * priceFactor * DMath.Pow(Math.Max(km, 0.1), t.FreightKmExponent) * w.Difficulty.TariffMultiplier;
|
||||
}
|
||||
|
||||
/// <summary>Ricavo per passeggero su <paramref name="km"/> nella classe indicata (centesimi).</summary>
|
||||
public static double PassengerPerTrip(World w, PaxClass cls, double km)
|
||||
{
|
||||
var t = w.Data.Balance.Tariffs;
|
||||
double mult = t.ClassMultipliers[cls == PaxClass.Staff ? "staff" : "worker"];
|
||||
return t.PaxBaseFare * DMath.Pow(Math.Max(km, 0.1), t.PaxKmExponent) * mult * w.Difficulty.TariffMultiplier;
|
||||
}
|
||||
|
||||
/// <summary>Durata di un giro completo (andata e ritorno con le soste) in giorni di calendario.</summary>
|
||||
public static double RoundTripDays(World w, double km, double maxSpeedKmh)
|
||||
{
|
||||
var p = w.Data.Ai.Planning;
|
||||
double minutes = 2 * km / Math.Max(1, maxSpeedKmh * p.SpeedFactor) * 60 + 2 * p.DwellMinutes;
|
||||
return w.Calendar.TrainMinutesToDays(minutes);
|
||||
}
|
||||
|
||||
/// <summary>Costo d'esercizio annuo di un treno con la manutenzione stimata.</summary>
|
||||
public static double TrainCostPerYear(World w, VehicleDef loco, VehicleDef car, int cars) =>
|
||||
(loco.RunningCostPerYear + car.RunningCostPerYear * cars) * (1 + w.Data.Ai.Planning.MaintenanceCostShare);
|
||||
|
||||
public static long TrainPrice(VehicleDef loco, VehicleDef car, int cars) => loco.Price + car.Price * cars;
|
||||
|
||||
/// <summary>Costo di una stazione con i binari indicati per la compagnia.</summary>
|
||||
public static long StationCost(World w, Company c, int platforms) =>
|
||||
(long)((w.Data.Construction.Costs.StationBase + w.Data.Construction.Costs.StationPerPlatform * platforms) * RailCommandHandlers.CostMultiplier(w, c));
|
||||
|
||||
public static long DepotCost(World w, Company c, string size) =>
|
||||
(long)(w.Data.Construction.Costs.DepotBySize[size] * RailCommandHandlers.CostMultiplier(w, c));
|
||||
|
||||
/// <summary>Costo di massima di un binario in linea d'aria (senza opere), per ordinare i candidati.</summary>
|
||||
public static long RoughTrackCost(World w, Company c, double km) =>
|
||||
(long)(w.Data.Construction.Costs.BasePerMeter * 1000 * km * RailCommandHandlers.CostMultiplier(w, c));
|
||||
|
||||
/// <summary>Locomotiva più recente non elettrica disponibile nell'anno.</summary>
|
||||
public static VehicleDef? BestLocomotive(World w, int year)
|
||||
{
|
||||
VehicleDef? best = null;
|
||||
foreach (var v in w.Data.Vehicles)
|
||||
{
|
||||
if (v.Kind != VehicleKind.Locomotive || v.EraFrom > year || (v.EraTo is { } to && year > to)) continue;
|
||||
if (v.Traction is Traction.Electric or Traction.HighSpeed) continue;
|
||||
if (best is null || v.EraFrom > best.EraFrom) best = v;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/// <summary>Carro più economico che trasporta il bene nell'anno.</summary>
|
||||
public static VehicleDef? WagonFor(World w, int good, int year)
|
||||
{
|
||||
VehicleDef? best = null;
|
||||
foreach (var v in w.Data.Vehicles)
|
||||
{
|
||||
if (v.Kind != VehicleKind.Wagon || v.EraFrom > year || (v.EraTo is { } to && year > to)) continue;
|
||||
if (Array.IndexOf(v.GoodIndices, good) < 0) continue;
|
||||
if (best is null || v.Price < best.Price) best = v;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/// <summary>Carrozza della classe indicata disponibile nell'anno.</summary>
|
||||
public static VehicleDef? CoachFor(World w, PaxClass cls, int year)
|
||||
{
|
||||
VehicleDef? best = null;
|
||||
foreach (var v in w.Data.Vehicles)
|
||||
{
|
||||
if (v.Kind != VehicleKind.Coach || v.Class != cls || v.EraFrom > year || (v.EraTo is { } to && year > to)) continue;
|
||||
if (best is null || v.Price < best.Price) best = v;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user