private void Equal_Button_Clicked(object sender, EventArgs e)
 {
     if (currentOperatorSelected == "Divide")
     {
         MathematicalOperations mathOperations = new MathematicalOperations();
         finalResult = mathOperations.Divide(listOfNumbers);
         OperationValueSetter("Final Result : " + finalResult, true);
     }
     else if (currentOperatorSelected == "Multiply")
     {
         MathematicalOperations mathOperations = new MathematicalOperations();
         finalResult = mathOperations.Multiply(listOfNumbers);
         OperationValueSetter("Final Result : " + finalResult, true);
     }
     else if (currentOperatorSelected == "Addition")
     {
         MathematicalOperations mathOperations = new MathematicalOperations();
         finalResult = mathOperations.Addition(listOfNumbers);
         OperationValueSetter("Final Result : " + finalResult, true);
     }
     isOperatorSelected      = false;
     isDecimalClicked        = false;
     currentOperatorSelected = null;
     decimalValues           = null;
     listOfNumbers.Clear();
 }
        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;
        }
Ejemplo n.º 3
0
 void Awake()
 {
     //Init Game
     Debug.LogError("Change this Script for your own Script");
     if (instance == null)
     {
         instance = this;
     }
 }
Ejemplo n.º 4
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 static HardwareModel GenerateHardwareModel(Hardware pHardware)
        {
            HardwareModel model = new HardwareModel
            {
                CameraRange       = pHardware.Camera.Range,
                CameraGenotype    = pHardware.CameraGenotype,
                CameraChromosome  = MathematicalOperations.ConvertIntToBinaryString(pHardware.CameraGenotype),
                EngineCapacity    = pHardware.Engine.MaxTerrainDifficulty,
                EngineGenotype    = pHardware.EngineGenotype,
                EngineChromosome  = MathematicalOperations.ConvertIntToBinaryString(pHardware.EngineGenotype),
                BatteryEnergy     = pHardware.Battery.Energy,
                BatteryGenotype   = pHardware.BatteryGenotype,
                BatteryChromosome = MathematicalOperations.ConvertIntToBinaryString(pHardware.BatteryGenotype)
            };

            return(model);
        }
Ejemplo n.º 6
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();
        }
        private static SoftwareModel GenerateSoftwareModel(Software pSoftware)
        {
            SoftwareModel model = new SoftwareModel
            {
                MoveTowardsEnd                     = pSoftware.MoveTowardsEnd,
                MoveAwayFromEnd                    = pSoftware.MoveAwayFromEnd,
                MoveToPassableTerrain              = pSoftware.MoveToPassableTerrain,
                MoveToNonPassableTerrain           = pSoftware.MoveToNonPassableTerrain,
                SpendTheLessEnergy                 = pSoftware.SpendTheLessEnergy,
                SpendTheMostEnergy                 = pSoftware.SpendTheMostEnergy,
                SpendNormalEnergy                  = pSoftware.SpendNormalEnergy,
                MoveTowardsEndChromosome           = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveTowardsEnd),
                MoveAwayFromEndChromosome          = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveAwayFromEnd),
                MoveToPassableTerrainChromosome    = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveToPassableTerrain),
                MoveToNonPassableTerrainChromosome = MathematicalOperations.ConvertIntToBinaryString(pSoftware.MoveToNonPassableTerrain),
                SpendTheLessEnergyChromosome       = MathematicalOperations.ConvertIntToBinaryString(pSoftware.SpendTheLessEnergy),
                SpendTheMostEnergyChromosome       = MathematicalOperations.ConvertIntToBinaryString(pSoftware.SpendTheMostEnergy),
                SpendNormalEnergyChromosome        = MathematicalOperations.ConvertIntToBinaryString(pSoftware.SpendNormalEnergy)
            };

            return(model);
        }
        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);
        }
Ejemplo n.º 9
0
        public int Subtract(int num1, int num2)
        {
            var result = MathematicalOperations.Subtract(num1, num2);

            return(result);
        }
Ejemplo n.º 10
0
        public int Multiplication(int num1, int num2)
        {
            var result = MathematicalOperations.Multiply(num1, num2);

            return(result);
        }
Ejemplo n.º 11
0
        public double Division(int num1, int num2)
        {
            var result = MathematicalOperations.Divide(num1, num2);

            return(result);
        }
Ejemplo n.º 12
0
        public int Addition(int num1, int num2)
        {
            var result = MathematicalOperations.Add(num1, num2);

            return(result);
        }