Пример #1
0
        public static int fitness(Individual indi)
        {
            RunReturn ret = indi.RReturn;

            int value = 1;
            if (ret.statut.Equals("SUCCESS."))
                value += 1000;
            else if (ret.statut.Equals("TIME OUT BABY"))
                value += 15;
            else if (ret.statut.Equals("Out of colored cells."))
                value += 5;
            else if (ret.statut.Equals("NO MORE INSTRUCTIONS."))
                value += 7;
            else
            if (ret.statut.Equals("INFINITE_LOOP."))
                value = 0;

            ///if (ret.nbMov < ((ret.maxStars - ret.nbStars) * 3))
            //{
                value += ((ret.maxStars - ret.nbStars) * 10);
                if (ret.nbMov * 2 <= ((ret.maxStars - ret.nbStars)))
                    value += (ret.nbMov * 1);
                else
                    value += ((ret.maxStars - ret.nbStars) * 2);
            //}
            //else
            //{
              //  value += ((ret.maxStars - ret.nbStars) * (5+2));
            //}

                if (indi.sequence.nbLoaded > 10)
                {
                    value -= 5;// indi.sequence.nbLoaded;
                }

                if (indi.RReturn.stuck > 0)
                {
                    value -= 5;// indi.sequence.nbLoaded;
                }

                foreach (List<Instruction> l in indi.sequence.Source_code)
                {
                    if (l.Contains(new Instruction(Color.RED, Action.PAINT_R)))
                    {
                        value -= 5;
                    }
                    if (l.Contains(new Instruction(Color.GREEN, Action.PAINT_G)))
                    {
                        value -= 5;
                    }
                    if (l.Contains(new Instruction(Color.BLUE, Action.PAINT_B)))
                    {
                        value -= 5;
                    }
                }

                if (value < 0)
                    value = 0;

            return value;
        }
 public Individual reproduction(Individual other, Random r)
 {
     return(new Individual(this.sequence.reproduction(other.sequence, r)));
 }
 public Individual reproduction(Individual other, Random r)
 {
     return new Individual(this.sequence.reproduction(other.sequence, r));
 }
        public int CompareTo(object obj)
        {
            Individual other = (Individual)(obj);

            return(fitnessValue.CompareTo(other.fitnessValue));
        }