Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

fix(sim): an office with no budget line has a neutral budget factor (M2)

eyalgolanb5af38583ba8
diff --git a/sim/Statecraft.Sim.Tests/RealContentTests.cs b/sim/Statecraft.Sim.Tests/RealContentTests.cs
index 10709dd5f..98fc6f75d 100644
--- a/sim/Statecraft.Sim.Tests/RealContentTests.cs
+++ b/sim/Statecraft.Sim.Tests/RealContentTests.cs
@@ -89,4 +89,12 @@ public class RealContentTests
Assert.Equal(1.0, e.Options.Single(o => o.Id == "impose").SetPolicy["rationing"]);
Assert.Empty(e.Options.Single(o => o.Id == "decline").SetPolicy);
}
+
+ [Fact]
+ public void OfficeWithoutABudgetLineHasANeutralBudgetFactor()
+ {
+ Assert.DoesNotContain("rationing_minister", C.Rules.BudgetStart.Keys);
+ var s = Simulation.NewGame(C, 1, Mode.Historical);
+ Assert.Equal(1.0, EffectsSystem.BudgetFactor(s, "rationing_minister"));
+ }
}
diff --git a/sim/Statecraft.Sim/EffectsSystem.cs b/sim/Statecraft.Sim/EffectsSystem.cs
index 7994731ea..c95ac7062 100644
--- a/sim/Statecraft.Sim/EffectsSystem.cs
+++ b/sim/Statecraft.Sim/EffectsSystem.cs
@@ -22,11 +22,12 @@ namespace Statecraft.Sim
return competence * BudgetFactor(s, office);
}
- /// <summary>An equal split of the budget is neutral (1.0); a ministry's factor runs from 0.5 (no money) to 1.5.</summary>
+ /// <summary>An equal split of the budget is neutral (1.0); a ministry's factor runs from 0.5 (no money) to 1.5.
+ /// An office with no budget line (not in budget_start, so the player can never fund it) is neutral too:
+ /// treating it as unfunded would halve its effects permanently with no way to fix it.</summary>
public static double BudgetFactor(GameState s, string office)
{
- if (s.Budget.Count == 0) return 1.0;
- var share = s.Budget.TryGetValue(office, out var v) ? v : 0.0;
+ if (!s.Budget.TryGetValue(office, out var share)) return 1.0;
return Math.Min(1.5, 0.5 + share * s.Budget.Count / 2.0);
}