Exemplo n.º 1
0
        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
            });
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
 public override StepRes execute(PlanetCondition conditions, Colony colony)
 {
     return(new StepRes
     {
         conditions = conditions,
         colony = colony.div()
     });
 }
Exemplo n.º 5
0
 public override StepRes execute(PlanetCondition conditions, Colony colony)
 {
     //TODO implement
     return(new StepRes
     {
         conditions = conditions,
         colony = colony
     });
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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
            });
        }
Exemplo n.º 9
0
        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
            });
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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
            });
        }
Exemplo n.º 12
0
 public override float getTemperatureDeathRate(PlanetCondition contitions, Colony colony)
 {
     return(0.6f);
 }
Exemplo n.º 13
0
 public override float getRadiationDeathRate(PlanetCondition contitions, Colony colony)
 {
     return(0.9f);
 }
Exemplo n.º 14
0
 public abstract StepRes execute(PlanetCondition conditions, Colony colony);
Exemplo n.º 15
0
 public abstract float getRadiationDeathRate(PlanetCondition contitions, Colony colony);
Exemplo n.º 16
0
 public abstract float getTemperatureDeathRate(PlanetCondition contitions, Colony colony);
Exemplo n.º 17
0
 public abstract double getPlanetWater(PlanetCondition contitions, Colony colony, double requiredWater);
Exemplo n.º 18
0
 public override double getPlanetWater(PlanetCondition conditions, Colony colony, double requiredWater)
 {
     return(requiredWater * getPlanetCoe(colony.getMass()));
 }
Exemplo n.º 19
0
 public override double getPlanetN(PlanetCondition contitions, Colony colony, double requiredN)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 public abstract double getPlanetN(PlanetCondition contitions, Colony colony, double requiredN);