예제 #1
0
        protected float runOrganismo(float error, bool checkTick, IOrganismo o)
        {
            //  if (o.id==1)
            //      ALifeIO.saveToFile(o);
            if (isRunnable(o))
            {
                o.run();

                int memorySize = o.getMemorySize();
                totalMemory += memorySize;
                if (memorySize > maxMemory)
                {
                    maxMemory = (int)memorySize;
                }
                if (memorySize < minMemory || minMemory == 0)
                {
                    minMemory = (int)memorySize;
                }

                error += o.getError();
                if (checkTick)
                {
                    o.checkTick();
                }
            }
            else
            {
                if (o.parent == null || o.parent.isAlive() == false)
                {
                    dealloc(o);
                }
            }
            return(error);
        }
예제 #2
0
        // chamado quando o erro do organismo excedeu o limite definido
        public void errorLimitAction(IOrganismo o)
        {
            double rnd            = Utils.RandomDouble();
            float  error          = o.getError();
            float  ratio          = error / settings.getErrorLimit;
            float  mutationChance = calcMutationChance(settings.errorKillChance
                                                       * ratio, o);

            if (rnd < mutationChance)
            {
                o.fatalError();
            }
        }
예제 #3
0
 public void UpdateRows()
 {
     if (Rows == null)
     {
         Rows = GetRows("dataGridOrgs");
     }
     for (int rowLine = 0; rowLine < Rows.Count; rowLine++)
     {
         IOrganismo o = Rows[rowLine].Cells[0].Value as IOrganismo;
         if (o != null)
         {
             int colIndex = 1;
             Rows[rowLine].Cells[colIndex++].Value = o.oid;
             Rows[rowLine].Cells[colIndex++].Value = o.hash();
             Rows[rowLine].Cells[colIndex++].Value = o.getMemorySize();
             Rows[rowLine].Cells[colIndex++].Value = o.getError();
             Rows[rowLine].Cells[colIndex++].Value = o.sp();
         }
     }
 }