Ejemplo n.º 1
0
        private void StartEvolution()
        {
            splitSourceImage();
            if (currentDrawing == null)
            {
                currentDrawing = GetNewInitializedDrawing();
            }
            lastSelected = 0;

            int i = 0;

            while (isRunning)
            {
                MyDnaDrawing newDrawing;
                lock (currentDrawing)
                {
                    newDrawing = currentDrawing.reproduction();
                }
                newDrawing.mutation();

                if (newDrawing.isDefected)
                {
                    generation++;

                    double newErrorLevel = FitnessFunction.getDrawingFitness(newDrawing, sourceColors);

                    if (newErrorLevel <= errorLevel)
                    {
                        selected++;
                        lock (currentDrawing)
                        {
                            currentDrawing = newDrawing;
                        }
                        errorLevel = newErrorLevel;
                    }
                }
            }
        }