Пример #1
0
        public void RecalculateNeuroevolution(newPool xPool)
        {
            //RECALCULATE NEUROEVOLUTION
            int spcies = xPool.species.Count;

            //PANEL
            PanelTop  = new float[] { Start, Panel.Height - Start * 1.8f, Panel.Height - Start * 1.2f };
            PanelLeft = new float[] { Start, Start * 1.5f, Start * 2f };
            PanelMax  = Panel.Width - (PanelLeft.Last() * 2 + Start);

            //CALCULATE LINE WIDTH
            float height = PanelTop[1] - PanelTop[0];

            PenPositive = new Pen(Colors.MainRecessive, height / spcies);
            PenNegative = new Pen(Colors.getLighter(Colors.MainRecessive, 0.5f), PenPositive.Width);
            PenText     = new Pen(Colors.getColor(COLOR.BLACK), PenPositive.Width);

            //GET HIGHSCORE
            HighScore = (float)xPool.maxFitness;
        }
Пример #2
0
        private void initializePool(bool xLoad = false)
        {
            //INITIALIZE POOL
            Pool = new newPool();

            //ABBRUCH
            if (xLoad)
            {
                return;
            }

            for (int i = 0; i < Population; i++)
            {
                newGenome basic = newGenome.basicGenome(this);
                addToSpecies(basic);
            }

            //INITIALIZE RUN
            initializeRun();
        }
Пример #3
0
        public void Plot(Graphics g)
        {
            Pool = Main.Mario.Pool;

            //ABBRUCH
            if (Pool == null)
            {
                return;
            }

            //RECALCULATE NEUROEVOLUTION
            RecalculateNeuroevolution(Pool);

            //GET SPCIES LIST
            List <newSpecies> spciesList = Pool.species;

            for (int i = 0; i < spciesList.Count; i++)
            {
                float width   = PanelLeft[2] + getScoreWidth(spciesList[i].topFitness);
                float average = PanelLeft[2] + getScoreWidth(spciesList[i].averageFitness);
                float height  = PanelTop[0] + i * PenPositive.Width;

                //DRAW NUMBER
                g.DrawString((i + 1) + ".", Mod_Convert.FontSize(Fonts.MainFont, PenText.Width), PenText.Brush, new PointF(PanelLeft[1], height - PenPositive.Width / 2));

                //DRAW SCORE
                if (Mod_Check.isEven(i))
                {
                    g.DrawLine(PenNegative, new PointF(PanelLeft[2], height), new PointF(width, height));
                }
                else
                {
                    g.DrawLine(PenPositive, new PointF(PanelLeft[2], height), new PointF(width, height));
                }

                //DRAW STALE
                for (int l = 0; l < Pool.species[i].staleness; l++)
                {
                    g.FillEllipse(new SolidBrush(Colors.MainLight), PanelLeft[2] + 1f + l * PenPositive.Width, height, PenPositive.Width / 2, PenPositive.Width / 2);
                }

                //DRAW AVERAGE
                g.DrawLine(new Pen(Colors.MainDominant, 1), new PointF(average, height), new PointF(average, height + PenPositive.Width / 2));
            }

            //INFORMATIONS
            newSpecies currSpecies = Pool.species[Pool.currentSpecies];             //GET CURRENT SPECIES
            newGenome  currGenome  = currSpecies.genomes[Pool.currentGenome];       //GET CURRENT GENOME

            float left     = PanelLeft[0];
            Font  infoFont = Mod_Convert.FontSize(Fonts.MainFont, 9);

            g.DrawString("Generation:", infoFont, PenNegative.Brush, new PointF(left, PanelTop[1]));
            g.DrawString(Pool.generation.ToString(), infoFont, PenText.Brush, new PointF(left, PanelTop[2]));

            left += PanelLeft[0] * 2.5f;
            g.DrawString("Species:", infoFont, PenNegative.Brush, new PointF(left, PanelTop[1]));
            g.DrawString((Pool.currentSpecies + 1) + "/" + Pool.species.Count, infoFont, PenText.Brush, new PointF(left, PanelTop[2]));

            left += PanelLeft[0] * 2.5f;
            g.DrawString("Genome:", infoFont, PenNegative.Brush, new PointF(left, PanelTop[1]));
            g.DrawString((Pool.currentGenome + 1) + "/" + currSpecies.genomes.Count, infoFont, PenText.Brush, new PointF(left, PanelTop[2]));

            left += PanelLeft[0] * 2.5f;
            g.DrawString("Stale:", infoFont, PenNegative.Brush, new PointF(left, PanelTop[1]));
            g.DrawString(currSpecies.staleness + "/" + (NetMario.StaleSpecies - 1), infoFont, PenText.Brush, new PointF(left, PanelTop[2]));

            left += PanelLeft[0] * 2.5f;
            g.DrawString("Fitness:", infoFont, PenNegative.Brush, new PointF(left, PanelTop[1]));
            g.DrawString(currGenome.fitness + " (" + Pool.maxFitness + ", " + currSpecies.averageFitness + ")", infoFont, PenText.Brush, new PointF(left, PanelTop[2]));

            left += PanelLeft[0] * 2.5f;
            g.DrawString("Measure:", infoFont, PenNegative.Brush, new PointF(left, PanelTop[1]));
            g.DrawString(Pool.measured + " %", infoFont, PenText.Brush, new PointF(left, PanelTop[2]));
        }
Пример #4
0
 public int newInnovation(newPool xPool)
 {
     //NEW INNOVATION
     xPool.innovation = xPool.innovation + 1;
     return(xPool.innovation);
 }