F2: soddisfazione cittadina corretta con domande frazionarie
Con consumi di poche unità al giorno il rapporto giornaliero troncato a 1 sottostimava la soddisfazione: ora conta la quota della richiesta coperta dalla scorta. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
1 file changed
+6
-2
@@ -47,14 +47,18 @@ public sealed class TownSystem : ISimSystem
|
||||
continue;
|
||||
}
|
||||
int cat = (int)data.Goods[g].Town!.Category;
|
||||
int stockBefore = town.Stock[g];
|
||||
town.DemandAccumulator[g] += demand;
|
||||
int want = (int)Math.Floor(town.DemandAccumulator[g]);
|
||||
int used = Math.Min(want, town.Stock[g]);
|
||||
int used = Math.Min(want, stockBefore);
|
||||
town.Stock[g] -= used;
|
||||
w.Goods.Consumed[g] += used;
|
||||
town.DemandAccumulator[g] -= want; // la domanda non servita non si accumula
|
||||
// quota servita: con domande frazionarie il consumo è a scatti, quindi conta se la
|
||||
// scorta copriva la richiesta del giorno, non il rapporto tra unità intere e decimali
|
||||
double served = want > 0 ? (double)used / want : stockBefore > 0 ? 1.0 : 0.0;
|
||||
_catDemand[cat] += demand;
|
||||
_catConsumed[cat] += used;
|
||||
_catConsumed[cat] += demand * served;
|
||||
}
|
||||
for (int c = 0; c < Town.CategoryCount; c++)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user