public Software()
        {
            /*
             * Initializes a software system with random values.
             * The order of the CompleteChromosome matters.
             * It is the following:
             * 1) MoveTowardsEnd chromosome
             * 2) MoveAwayFromEnd chromosome
             * 3) MoveToPassableTerrain chromosome
             * 4) MoveToNonPassableTerrain chromosome
             * 5) SpendTheLessEnergy chromosome
             * 6) SpendTheMostEnergy chromosome
             * 7) SpendNormalEnergy chromosome
             */
            var minValue = Constants.GenotypeMinvalue;
            var maxValue = Constants.GenotypeMaxValue;

            MoveTowardsEnd = MathematicalOperations.RandomIntegerInRange(minValue, maxValue);
            var moveTowardsEndChromosome = MathematicalOperations.ConvertIntToBinaryString(MoveTowardsEnd);

            MoveAwayFromEnd       = (Constants.GenotypeMaxValue - 1) - MoveTowardsEnd;
            MoveToPassableTerrain = MathematicalOperations.RandomIntegerInRange(minValue, maxValue);
            var moveToPassableTerrainChromosome = MathematicalOperations.ConvertIntToBinaryString(MoveToPassableTerrain);

            MoveToNonPassableTerrain = (Constants.GenotypeMaxValue - 1) - MoveToPassableTerrain;
            SpendTheLessEnergy       = MathematicalOperations.RandomIntegerInRange(minValue, maxValue);
            var spendTheLessEnergyChromosome = MathematicalOperations.ConvertIntToBinaryString(SpendTheLessEnergy);

            SpendTheMostEnergy = (Constants.GenotypeMaxValue - 1) - SpendTheLessEnergy;
            SpendNormalEnergy  = MathematicalOperations.RandomIntegerInRange(minValue, maxValue);
            var spendNormalEnergyChromosome = MathematicalOperations.ConvertIntToBinaryString(SpendNormalEnergy);

            CompleteChromosome = moveTowardsEndChromosome + moveToPassableTerrainChromosome + spendTheLessEnergyChromosome + spendNormalEnergyChromosome;
        }
Esempio n. 2
0
        public Hardware()
        {
            /*
             * Initializes a hardware system with random initial values.
             */

            CameraGenotype  = MathematicalOperations.RandomIntegerInRange(Constants.GenotypeMinvalue, Constants.GenotypeMaxValue);
            BatteryGenotype = MathematicalOperations.RandomIntegerInRange(Constants.GenotypeMinvalue, Constants.GenotypeMaxValue);;
            EngineGenotype  = MathematicalOperations.RandomIntegerInRange(Constants.GenotypeMinvalue, Constants.GenotypeMaxValue);;

            string batteryChromosome = MathematicalOperations.ConvertIntToBinaryString(BatteryGenotype);
            string cameraChromosome  = MathematicalOperations.ConvertIntToBinaryString(CameraGenotype);
            string engineChromosome  = MathematicalOperations.ConvertIntToBinaryString(EngineGenotype);

            // IMPORTANT: The order of the chromosomes in the complete chromosome must stay the same !!!
            CompleteChromosome = batteryChromosome + cameraChromosome + engineChromosome;

            InitializeFields();
        }