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 void start(int ticks) { if (!ticksFinished()) { return; } // if (totalTicks % 8 == 0) // { // _conditions = _conditions.withTempearture(-60); // } _simTread = new Thread(() => { model.PlanetCondition conditions = _conditions; model.Colony colony = _currentColony; for (int i = 0; i < ticks; ++i) { if (colony.isDead()) { break; } SimTick tick = new SimTick(); SimStep.StepRes res = tick.execute(conditions, colony); conditions = res.conditions; colony = res.colony; ++totalTicks; } _conditions = conditions.withTempearture(defaultTemp); _currentColony = colony; //TODO mutate }); _simTread.Start(); }
public SimulationController() { model.PlanetCondition.PlanetConditionState state = new model.PlanetCondition.PlanetConditionState { freeWater = 0, organic = 0, co = 23830000000000000, n = 675000000000000, oxigen = 32500000000000, //TODO temperature temperature = -40 }; model.ColonyStats stats = new model.ColonyStats { num = 10, mass = 10 }; model.ColonyParams par = ParamsController.colonyParams; model.PlanetCondition contitions = new model.PlanetCondition(state, ParamsController.growthSpeed); model.Colony colony = new model.Colony(stats, par); _currentColony = colony; _conditions = contitions; defaultTemp = _conditions.getTemperature(); }
public override StepRes execute(PlanetCondition conditions, Colony colony) { return(new StepRes { conditions = conditions, colony = colony.div() }); }
public override StepRes execute(PlanetCondition conditions, Colony colony) { //TODO implement return(new StepRes { conditions = conditions, colony = colony }); }
public override double getPlanetN(PlanetCondition contitions, Colony colony, double requiredN) { float coe = 0.3f + getPlanetCoe(colony.getMass()); if (coe > 1) { coe = 1; } return(requiredN * coe); }
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 StepRes execute(PlanetCondition conditions, Colony colony) { ColonyProduction prod = colony.getProduction(); PlanetCondition newCond = conditions .incOxygen(prod.oxygen) .incSurfaceN(prod.surfaceN); Colony newCol = colony.massGrow(); return(new StepRes { conditions = newCond, colony = newCol }); }
public override StepRes execute(PlanetCondition conditions, Colony colony) { float radiationDeathRate = BioFunc.funcs.getRadiationDeathRate(conditions, colony); float tempDeathRate = BioFunc.funcs.getTemperatureDeathRate(conditions, colony); float avarageDeathRate = BioFunc.funcs.getAvarageDeathRate(radiationDeathRate, tempDeathRate); Colony newColony = colony.die(avarageDeathRate); PlanetCondition newPlanetCondition = conditions .incFreeWater(colony.getFreeWater(avarageDeathRate)) .incOrganic(colony.getOrganic(avarageDeathRate)); return(new StepRes { conditions = newPlanetCondition, colony = newColony }); }
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); }
public override StepRes execute(PlanetCondition contitions, Colony colony) { var currentCond = contitions; var currentColony = colony; var mutations = new List <Colony>(); foreach (SimStep step in allSteps) { var res = step.execute(currentCond, currentColony); currentColony = res.colony; currentCond = res.conditions; if (res.mutations != null) { mutations.AddRange(res.mutations); } } return(new StepRes { conditions = currentCond, colony = currentColony, mutations = mutations }); }
public override float getTemperatureDeathRate(PlanetCondition contitions, Colony colony) { return(0.6f); }
public override float getRadiationDeathRate(PlanetCondition contitions, Colony colony) { return(0.9f); }
public abstract StepRes execute(PlanetCondition conditions, Colony colony);
public abstract float getRadiationDeathRate(PlanetCondition contitions, Colony colony);
public abstract float getTemperatureDeathRate(PlanetCondition contitions, Colony colony);
public abstract double getPlanetWater(PlanetCondition contitions, Colony colony, double requiredWater);
public override double getPlanetWater(PlanetCondition conditions, Colony colony, double requiredWater) { return(requiredWater * getPlanetCoe(colony.getMass())); }
public override double getPlanetN(PlanetCondition contitions, Colony colony, double requiredN) { throw new NotImplementedException(); }
public abstract double getPlanetN(PlanetCondition contitions, Colony colony, double requiredN);