Beispiel #1
0
        private void SetGenotypes()
        {
            string batteryChromosome = CompleteChromosome.Substring(0, Constants.ChromosomeSize);
            string cameraChromosome  =
                CompleteChromosome.Substring(Constants.ChromosomeSize, Constants.ChromosomeSize);
            string engineChromosome =
                CompleteChromosome.Substring(2 * Constants.ChromosomeSize, Constants.ChromosomeSize);

            BatteryGenotype = MathematicalOperations.ConvertBinaryStringToInt(batteryChromosome);
            CameraGenotype  = MathematicalOperations.ConvertBinaryStringToInt(cameraChromosome);
            EngineGenotype  = MathematicalOperations.ConvertBinaryStringToInt(engineChromosome);
        }
        private void SetGenotypes()
        {
            var moveTowardsEndChromosome =
                CompleteChromosome.Substring(0, Constants.ChromosomeSize);

            var moveToPassableTerrainChromosome =
                CompleteChromosome.Substring(1 * Constants.ChromosomeSize, Constants.ChromosomeSize);

            var spendTheLessEnergyChromosome =
                CompleteChromosome.Substring(2 * Constants.ChromosomeSize, Constants.ChromosomeSize);

            var spendNormalEnergyChromosome =
                CompleteChromosome.Substring(3 * Constants.ChromosomeSize, Constants.ChromosomeSize);

            MoveTowardsEnd           = MathematicalOperations.ConvertBinaryStringToInt(moveTowardsEndChromosome);
            MoveAwayFromEnd          = (Constants.GenotypeMaxValue - 1) - MoveTowardsEnd;
            MoveToPassableTerrain    = MathematicalOperations.ConvertBinaryStringToInt(moveToPassableTerrainChromosome);
            MoveToNonPassableTerrain = (Constants.GenotypeMaxValue - 1) - MoveToPassableTerrain;
            SpendTheLessEnergy       = MathematicalOperations.ConvertBinaryStringToInt(spendTheLessEnergyChromosome);
            SpendTheMostEnergy       = (Constants.GenotypeMaxValue - 1) - SpendTheLessEnergy;
            SpendNormalEnergy        = MathematicalOperations.ConvertBinaryStringToInt(spendNormalEnergyChromosome);
        }