public static double durationFactor;
private static void Main(string[] args)
Console.WriteLine("Ładowność:");
double totalCapacity = 2500;
double[] lootFactors = new double[] { .1, .25, .5 };
int calculations = 10000000;
durationFactor = Math.Pow(gameSpeed, -0.55);
Result[] bestResult = new Result[lootFactors.Length];
Result[] result = new Result[lootFactors.Length];
for (int i = 0; i < result.Length; i++)
bestResult[i] = new Result();
result[i] = new Result();
Random random = new Random();
int printEvery = calculations / 100;
for (int i = 0; i < calculations; i++)
double capacity = totalCapacity;
Array.Clear(result, 0, result.Length);
for (int j = 0; j < result.Length; j++)
if (j == result.Length - 1)
usedCapacity = capacity * random.NextDouble();
capacity -= usedCapacity;
result[j].capacity = usedCapacity;
result[j].time = CalculateScavengingTime(lootFactors[j], usedCapacity);
result[j].resources = lootFactors[j] * usedCapacity;
double maxTime = result.Max((x) => x.time);
for (int j = 0; j < result.Length; j++)
result[j].resourcesPerSecond = result[j].resources / maxTime;
if (result.Sum((x) => x.resourcesPerSecond) > bestResult.Sum((x) => x.resourcesPerSecond))
for (int j = 0; j < result.Length; j++)
bestResult[j] = result[j];
Console.WriteLine($"{i / printEvery + 1}%");
Console.WriteLine("-------------------------------------------------------------------------");
for (int i = 0; i < bestResult.Length; i++)
if (i == bestResult.Length - 1)
Console.WriteLine($"Reszta w {i + 1} opcję. ({Math.Round(bestResult[i].capacity / 25)} pikinierów)");
Console.WriteLine($"W {i + 1} opcję {Math.Round(bestResult[i].capacity / 25)} pikinierów.");
public double resourcesPerSecond;
public override string ToString()
return $"capacity: {Math.Round(capacity)}, time: {new TimeSpan(0, 0, 0, (int)Math.Round(time))}, resources: {Math.Round(resources)}, resourcesPerHour: {Math.Round(resourcesPerSecond * 60 * 60)}";
private static double CalculateScavengingTime(double lootFactor, double capacity)
return (Math.Pow(Math.Pow(capacity, 2) * 100 * Math.Pow(lootFactor, 2), 0.45) + 1800) * durationFactor;