Пример #1
0
        public UnitAgent(Unit myUnit, UnitAgentOptimizedProperties opProp)
        {
            MyUnit = myUnit;
            OptimizedProperties = opProp;
            LeadingStatus = LeadingStatusEnum.None;
            EmotionalMode = EmotionalModeEnum.None;

            HealthLevelOk = 60; //Health + armor

            UnitAgentTypeName = "Unit_Agent";
        }
		public void ConvertAndAddOptimizedValuesToUnitAgentChromosome(UnitAgentOptimizedProperties opProp)//String unitTypeName)//ref UnitAgent unitAgent)
		{
			if (Gene == null)
				Gene = new List<float>();
			else if (Gene.Count > 0)
			{
				Logger.Logger.AddAndPrint("WARNING: There was already values in the UnitAgentChromosome, when it was initialized. They have been deleted");
				Gene = new List<float>();
			}

			Fitness = opProp.Fitness;
			
			//Force
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float) opProp.ForceOwnUnitsRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceOwnUnitsRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceEnemyUnitsRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceEnemyUnitsRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceMSD, OptimizedPropertiesMultiplyers.Instance.ForceMSDMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceSquadAttraction, OptimizedPropertiesMultiplyers.Instance.ForceSquadAttractionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceMapCenterAttraction, OptimizedPropertiesMultiplyers.Instance.ForceMapCenterAttractionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceMapEdgeRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceMapEdgeRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceWeaponCoolDownRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceWeaponCoolDownRepulsionMultiplyer));

			//ForceStep
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepOwnUnitsRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceStepOwnUnitsRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepEnemyUnitsRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceStepEnemyUnitsRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepMSD, OptimizedPropertiesMultiplyers.Instance.ForceStepMSDMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepSquadAttraction, OptimizedPropertiesMultiplyers.Instance.ForceStepSquadAttractionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepMapCenterAttraction, OptimizedPropertiesMultiplyers.Instance.ForceStepMapCenterAttractionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepMapEdgeRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceStepMapEdgeRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome((float)opProp.ForceStepWeaponCoolDownRepulsion, OptimizedPropertiesMultiplyers.Instance.ForceStepWeaponCoolDownRepulsionMultiplyer));

			//Range
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome(opProp.RangeOwnUnitsRepulsion, OptimizedPropertiesMultiplyers.Instance.RangeOwnUnitsRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome(opProp.RangePercentageSquadAttraction, OptimizedPropertiesMultiplyers.Instance.RangePercentageSquadAttractionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome(opProp.RangePecentageMapCenterAttraction, OptimizedPropertiesMultiplyers.Instance.RangePecentageMapCenterAttractionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome(opProp.RangeMapEdgeRepulsion, OptimizedPropertiesMultiplyers.Instance.RangeMapEdgeRepulsionMultiplyer));
			Gene.Add(ConvertOptimizedValueToUnitAgentChromosome(opProp.RangeWeaponCooldownRepulsion, OptimizedPropertiesMultiplyers.Instance.RangeWeaponCooldownRepulsionMultiplyer));
		}
 public Terran_Marine_Agent(Unit myUnit, UnitAgentOptimizedProperties opProp)
     : base(myUnit, opProp)
 {
     UnitAgentTypeName = "Terran_Marine_Agent";
     //SightRange = 7; //http://wiki.teamliquid.net/starcraft/Marine
 }
 public Terran_Medic_Agent(Unit myUnit, UnitAgentOptimizedProperties opProp)
     : base(myUnit, opProp)
 {
     UnitAgentTypeName = "Terran_Medic_Agent";
     //SightRange = 9;
 }
Пример #5
0
        /// <summary>
        /// TEST METHOD for running with predefined unit agent optimized properties.
        /// </summary>
        /// <param name="unitTypeName"></param>
        /// <returns></returns>
        public static UnitAgentOptimizedProperties GetOptimizedValuesToUnitAgent(String unitTypeName)//ref UnitAgent unitAgent)
        {
            var opProp = new UnitAgentOptimizedProperties();
            opProp.UnitTypeName = unitTypeName;

            //Force
            opProp.ForceOwnUnitsRepulsion = 100;
            opProp.ForceEnemyUnitsRepulsion = 200;
            opProp.ForceMSD = 240;
            opProp.ForceSquadAttraction = 10;
            opProp.ForceMapCenterAttraction = 20;
            opProp.ForceMapEdgeRepulsion = 50;
            opProp.ForceWeaponCoolDownRepulsion = 800;

            //ForceStep
            opProp.ForceStepOwnUnitsRepulsion = 0.6;
            opProp.ForceStepEnemyUnitsRepulsion = 1.2;
            opProp.ForceStepMSD = 0.24;
            opProp.ForceStepSquadAttraction = 0.1;
            opProp.ForceStepMapCenterAttraction = 0.09;
            opProp.ForceStepMapEdgeRepulsion = 0.3;
            opProp.ForceStepWeaponCoolDownRepulsion = 6.4;

            //Range
            opProp.RangeOwnUnitsRepulsion = 8;
            opProp.RangePercentageSquadAttraction = 5;
            opProp.RangePecentageMapCenterAttraction = 5;
            opProp.RangeMapEdgeRepulsion = 96;
            opProp.RangeWeaponCooldownRepulsion = 160;

            return opProp;
        }
		public UnitAgentOptimizedProperties ConvertUnitAgentChromosomeToOptimizedValues()
		{
			if (Gene != null && Gene.Count > 0 && Gene.Count == NumberOfUnitAgentOptimizedProperties)
			{
				var opProp = new UnitAgentOptimizedProperties();

				//Force
				opProp.ForceOwnUnitsRepulsion = Gene[0] * OptimizedPropertiesMultiplyers.Instance.ForceOwnUnitsRepulsionMultiplyer;
				opProp.ForceEnemyUnitsRepulsion = Gene[1] * OptimizedPropertiesMultiplyers.Instance.ForceEnemyUnitsRepulsionMultiplyer;
				opProp.ForceMSD = Gene[2] * OptimizedPropertiesMultiplyers.Instance.ForceMSDMultiplyer;
				opProp.ForceSquadAttraction = Gene[3] * OptimizedPropertiesMultiplyers.Instance.ForceSquadAttractionMultiplyer;
				opProp.ForceMapCenterAttraction = Gene[4] * OptimizedPropertiesMultiplyers.Instance.ForceMapCenterAttractionMultiplyer;
				opProp.ForceMapEdgeRepulsion = Gene[5] * OptimizedPropertiesMultiplyers.Instance.ForceMapEdgeRepulsionMultiplyer;
				opProp.ForceWeaponCoolDownRepulsion = Gene[6] * OptimizedPropertiesMultiplyers.Instance.ForceWeaponCoolDownRepulsionMultiplyer;
				
				//ForceStep
				opProp.ForceStepOwnUnitsRepulsion = Gene[7] * OptimizedPropertiesMultiplyers.Instance.ForceStepOwnUnitsRepulsionMultiplyer;
				opProp.ForceStepEnemyUnitsRepulsion = Gene[8] * OptimizedPropertiesMultiplyers.Instance.ForceStepEnemyUnitsRepulsionMultiplyer;
				opProp.ForceStepMSD = Gene[9] * OptimizedPropertiesMultiplyers.Instance.ForceStepMSDMultiplyer;
				opProp.ForceStepSquadAttraction = Gene[10] * OptimizedPropertiesMultiplyers.Instance.ForceStepSquadAttractionMultiplyer;
				opProp.ForceStepMapCenterAttraction = Gene[11] * OptimizedPropertiesMultiplyers.Instance.ForceStepMapCenterAttractionMultiplyer;
				opProp.ForceStepMapEdgeRepulsion = Gene[12] * OptimizedPropertiesMultiplyers.Instance.ForceStepMapEdgeRepulsionMultiplyer;
				opProp.ForceStepWeaponCoolDownRepulsion = Gene[13] * OptimizedPropertiesMultiplyers.Instance.ForceStepWeaponCoolDownRepulsionMultiplyer;

				//Range
				opProp.RangeOwnUnitsRepulsion = Convert.ToInt32(Gene[14] * OptimizedPropertiesMultiplyers.Instance.RangeOwnUnitsRepulsionMultiplyer);
				opProp.RangePercentageSquadAttraction = Convert.ToInt32(Gene[15] * OptimizedPropertiesMultiplyers.Instance.RangePercentageSquadAttractionMultiplyer);
				opProp.RangePecentageMapCenterAttraction = Convert.ToInt32(Gene[16] * OptimizedPropertiesMultiplyers.Instance.RangePecentageMapCenterAttractionMultiplyer);
				opProp.RangeMapEdgeRepulsion = Convert.ToInt32(Gene[17] * OptimizedPropertiesMultiplyers.Instance.RangeMapEdgeRepulsionMultiplyer);
				opProp.RangeWeaponCooldownRepulsion = Convert.ToInt32(Gene[18] * OptimizedPropertiesMultiplyers.Instance.RangeWeaponCooldownRepulsionMultiplyer);

				return opProp;
			}
			Logger.Logger.AddAndPrint("ERROR: In Method AddOptimizedValuesToUnitAgentChromosome in UnitAgentChromosome, the Gene was null or had none elements.");
			throw new Exception("ERROR: In Method AddOptimizedValuesToUnitAgentChromosome in UnitAgentChromosome, the Gene was null or had none elements.");
		}
 public Terran_SiegeTank_Agent(Unit myUnit, UnitAgentOptimizedProperties opProp)
     : base(myUnit, opProp)
 {
     UnitAgentTypeName = "Terran_SiegeTank_Agent";
    // SightRange = 10;
 }