public override StepRes execute(PlanetCondition conditions, Colony colony) { double requiredCO = colony.getRequiredCO(conditions.getTime()); double requiredWater = colony.getRequiredWater(conditions.getTime()); double requiredN = colony.getRequiedN(conditions.getTime()); double availableFreeWater = conditions.getAvailableFreeWater(requiredWater); double availableCO = BioFunc.funcs.getPlanetCO(conditions, colony, requiredCO); double availablePlanetWater = BioFunc.funcs.getPlanetWater(conditions, colony, requiredWater); double availableN = BioFunc.funcs.getPlanetN(conditions, colony, requiredN); double water = availableFreeWater; if (water < requiredWater) { water += Math.Min(availablePlanetWater, requiredWater - water); } Colony newColony = colony.consume(co: availableCO, water: water, n: availableN, time: conditions.getTime()); PlanetCondition newCondition = conditions .decCo(availableCO) .decWater(water) .decN(availableN); return(new StepRes { conditions = newCondition, colony = newColony }); }
public override float getRadiationDeathRate(PlanetCondition conditions, Colony colony) { double a = colony.getRadiationResistent(); double b = timeTick(conditions.getTime()); float res = (float)Math.Pow(a, b); if (res < 0.001) { float res2 = (float)Math.Pow(a, b); res = res2; } return(res); }
public override float getTemperatureDeathRate(PlanetCondition conditions, Colony colony) { double a = 0.999; double b = timeTick(conditions.getTime()); if (colony.getOptimalTemperature() > conditions.getTemperature()) { int delta = colony.getOptimalTemperature() - conditions.getTemperature(); a = Math.Max(1 - delta * 0.1f / 100f, 0); } float res = (float)Math.Pow(a, b); if (res < 0.001) { float res2 = (float)Math.Pow(a, b); res = res2; } return(res); }