Exemplo n.º 1
0
        public double EvaluateIndividual(ArtificialAnt ant)
        {
            var mover = new AntMover(ant, AppleField);

            int apples = 0;
            int lastStep = 0;
            for (int i = 0; i < MaxStepsCount; ++i)
            {
                // Ate an apple
                if (mover.Move())
                {
                    apples++;
                    // In which steps ate, to determine the best in the case that both ate all the apples
                    lastStep = i;
                }
                if (apples == AppleField.FoodCount)
                    break;
            }

            return apples - 1.0 * lastStep / MaxStepsCount;
        }
        public double EvaluateIndividual(ArtificialAnt ant)
        {
            var mover = new AntMover(ant, AppleField);

            int apples   = 0;
            int lastStep = 0;

            for (int i = 0; i < MaxStepsCount; ++i)
            {
                // Ate an apple
                if (mover.Move())
                {
                    apples++;
                    // In which steps ate, to determine the best in the case that both ate all the apples
                    lastStep = i;
                }
                if (apples == AppleField.FoodCount)
                {
                    break;
                }
            }

            return(apples - 1.0 * lastStep / MaxStepsCount);
        }