protected override void Start() { base.Start(); GetAllCapturePoints(); // Utility AI setup // ****** VALUES ****** UAIV_AgentHealth agentHealth = new UAIV_AgentHealth(this, _AgentController._AgentStats.HealthPoints); UAIV_SoldierFriendlyCount friendlySoldierCount = new UAIV_SoldierFriendlyCount(this, 4); UAIV_SoldierEnemyCount enemySoldierCount = new UAIV_SoldierEnemyCount(this, 3); UAIV_DistanceToEnemy distanceToEnemy = new UAIV_DistanceToEnemy(this, _AgentController._Senses._ViewRange); UAIV_DistanceToFriendlyFlag distanceToFriendlyFlag = new UAIV_DistanceToFriendlyFlag(this, _AgentController._Senses._ViewRange); UAIV_FriendlyFlagsCount friendlyFlagsCount = new UAIV_FriendlyFlagsCount(this, 5); UAIV_AllFriendlySoldiersCount allFriendlySoldiersCount = new UAIV_AllFriendlySoldiersCount(this, _AgentController._PlayerOwner._MaxSoldiers); // ****** SCORERS ****** UtilityScorer scorer_agentHealth = new UtilityScorer(agentHealth, _HealthCurve); UtilityScorer scorer_friendlyCount = new UtilityScorer(friendlySoldierCount, _FriendlyAgentsCurve); UtilityScorer scorer_enemyCount = new UtilityScorer(enemySoldierCount, _EnemyAgentsCurve); UtilityScorer scorer_distanceToEnemy = new UtilityScorer(distanceToEnemy, _AttackDesireCurve); UtilityScorer scorer_distanceToEnemyFlee = new UtilityScorer(distanceToEnemy, _FleeDesireCurve); UtilityScorer scorer_distanceToFriendlyFlag = new UtilityScorer(distanceToFriendlyFlag, _FriendlyFlagDistanceCurve); UtilityScorer scorer_friendlyFlagsCount = new UtilityScorer(friendlyFlagsCount, _FriendlyFlagsForHQAttackCurve); UtilityScorer scorer_allFriendlySoldiersCount = new UtilityScorer(allFriendlySoldiersCount, _AllFriendlyAgentsCountCurve); // ****** ACTIONS ****** CaptureFlags captureFlagsAction = new CaptureFlags(capturePointsInScene, this, 0.5f); AttackEnemy attackEnemyAction = new AttackEnemy(this, 0.0f); attackEnemyAction.AddScorer(scorer_distanceToEnemy); Flee fleeAction = new Flee(this, 0.0f); fleeAction.AddScorer(scorer_agentHealth); fleeAction.AddScorer(scorer_enemyCount); fleeAction.AddScorer(scorer_friendlyCount); //fleeAction.AddScorer(scorer_distanceToEnemyFlee); HealAtFlag healAtFlagAction = new HealAtFlag(this, 0.0f); healAtFlagAction.AddScorer(scorer_agentHealth); healAtFlagAction.AddScorer(scorer_distanceToFriendlyFlag); healAtFlagAction.AddScorer(scorer_distanceToEnemyFlee); AttackHQ attackHQAction = new AttackHQ(_AgentController._PlayerOwner._EnemyPlayer, this, 0.0f); attackHQAction.AddScorer(scorer_friendlyFlagsCount); attackHQAction.AddScorer(scorer_allFriendlySoldiersCount); // ****** REGISTER ACTIONS ****** _AgentActions.Add(captureFlagsAction); _AgentActions.Add(attackEnemyAction); _AgentActions.Add(fleeAction); _AgentActions.Add(healAtFlagAction); _AgentActions.Add(attackHQAction); }
protected override void Start() { base.Start(); // Utility AI setup // ****** VALUES ****** UAIV_AgentHealth agentHealth = new UAIV_AgentHealth(this, _AgentController._AgentStats.HealthPoints); UAIV_AgentFood agentFood = new UAIV_AgentFood(this, _AgentController._AgentStats.FoodPoints); UAIV_AgentEnergy agentEnergy = new UAIV_AgentEnergy(this, _AgentController._AgentStats.EnergyPoints); UAIV_MinePlaced minePlaced = new UAIV_MinePlaced(this, 1); UAIV_ResourceCount oreCount = new UAIV_ResourceCount(GameCache._Cache.GetData("Ore").tag, this, 1); UAIV_InventorySize inventorySize = new UAIV_InventorySize(this, _AgentController._Inventory._MaxInventorySize); UAIV_SoldierEnemyCount enemySoldierCount = new UAIV_SoldierEnemyCount(this, 3.0f); // ****** SCORERS ****** UtilityScorer scorer_AgentHealth = new UtilityScorer(agentHealth, _HealthCurve); UtilityScorer scorer_AgentFood = new UtilityScorer(agentFood, _FoodCurve); UtilityScorer scorer_AgentEnergy = new UtilityScorer(agentEnergy, _EnergyCurve); UtilityScorer scorer_OreBoolCheck = new UtilityScorer(minePlaced, _MinePlacedCurve); UtilityScorer scorer_OreCount = new UtilityScorer(oreCount, _OreCountCurve); UtilityScorer scorer_InventorySize = new UtilityScorer(inventorySize, _InventorySizeCurve); UtilityScorer scorer_enemySoldierThreatLevel = new UtilityScorer(enemySoldierCount, _EnemySoldierThreatCurve); // ****** ACTIONS ****** RoamAround roamAction_SearchOres = new RoamAround(this, 1.0f); roamAction_SearchOres.AddScorer(scorer_OreCount); roamAction_SearchOres.AddScorer(scorer_OreBoolCheck); MineOre mineOreAction = new MineOre(this, 0.5f); DeliverResources deliverResourceAction = new DeliverResources(GameCache._Cache.GetData("Mine").tag, this, 0.0f); deliverResourceAction.AddScorer(scorer_InventorySize); EatFood eatFoodAction = new EatFood(this, 0.0f); eatFoodAction.AddScorer(scorer_AgentFood); eatFoodAction.SetWeight(2); SleepAndRest sleepRestAction = new SleepAndRest("Mine", this, 0.0f); sleepRestAction.AddScorer(scorer_AgentEnergy); Hide hideAction = new Hide("Headquarters", this, 0.0f); hideAction.AddScorer(scorer_enemySoldierThreatLevel); hideAction.SetWeight(3); // ****** REGISTER ACTIONS ****** _AgentActions.Add(roamAction_SearchOres); _AgentActions.Add(mineOreAction); _AgentActions.Add(deliverResourceAction); _AgentActions.Add(eatFoodAction); _AgentActions.Add(sleepRestAction); _AgentActions.Add(hideAction); }
protected override void Start() { base.Start(); // Utility AI setup // ****** VALUES ****** UAIV_AgentHealth agentHealth = new UAIV_AgentHealth(this, _AgentController._AgentStats.HealthPoints); UAIV_AgentFood agentFood = new UAIV_AgentFood(this, _AgentController._AgentStats.FoodPoints); UAIV_AgentEnergy agentEnergy = new UAIV_AgentEnergy(this, _AgentController._AgentStats.EnergyPoints); UAIV_FarmPlaced farmPlaced = new UAIV_FarmPlaced(this, 1); UAIV_DistanceTo distanceToHQ = new UAIV_DistanceTo(_AgentController._PlayerOwner.GetBuilding_ByTag(GameCache._Cache.GetData("Headquarters").tag), this, 20); UAIV_InventorySize inventorySize = new UAIV_InventorySize(this, _AgentController._Inventory._MaxInventorySize); UAIV_SoldierEnemyCount enemySoldierCount = new UAIV_SoldierEnemyCount(this, 3.0f); // ****** SCORERS ****** UtilityScorer scorer_AgentHealth = new UtilityScorer(agentHealth, _HealthCurve); UtilityScorer scorer_AgentFood = new UtilityScorer(agentFood, _FoodCurve); UtilityScorer scorer_AgentEnergy = new UtilityScorer(agentEnergy, _EnergyCurve); UtilityScorer scorer_FarmBoolCheck = new UtilityScorer(farmPlaced, _FarmPlacedCurve); UtilityScorer scorer_DistanceToHQ = new UtilityScorer(distanceToHQ, _DistanceToHQCurve); UtilityScorer scorer_InventorySize = new UtilityScorer(inventorySize, _InventorySizeCurve); UtilityScorer scorer_enemySoldierThreatLevel = new UtilityScorer(enemySoldierCount, _EnemySoldierThreatCurve); // ****** ACTIONS ****** RoamAround roamAction_SearchFarmSpot = new RoamAround(this, 0.0f); roamAction_SearchFarmSpot.AddScorer(scorer_DistanceToHQ); roamAction_SearchFarmSpot.AddScorer(scorer_FarmBoolCheck); FarmField farmFieldAction = new FarmField(this, 0.5f); DeliverResources deliverResourceAction = new DeliverResources(GameCache._Cache.GetData("Headquarters").tag, this, 0.0f); deliverResourceAction.AddScorer(scorer_InventorySize); EatFood eatFoodAction = new EatFood(this, 0.0f); eatFoodAction.AddScorer(scorer_AgentFood); eatFoodAction.SetWeight(2); SleepAndRest sleepRestAction = new SleepAndRest("Field", this, 0.0f); sleepRestAction.AddScorer(scorer_AgentEnergy); Hide hideAction = new Hide("Headquarters", this, 0.0f); hideAction.AddScorer(scorer_enemySoldierThreatLevel); hideAction.SetWeight(3); // ****** REGISTER ACTIONS ****** _AgentActions.Add(roamAction_SearchFarmSpot); _AgentActions.Add(farmFieldAction); _AgentActions.Add(deliverResourceAction); _AgentActions.Add(eatFoodAction); _AgentActions.Add(sleepRestAction); _AgentActions.Add(hideAction); }
public void AddCurve() { UtilityScorer scorer = new UtilityScorer(false); this.scorers.Add(scorer); }
/* --------------------------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------------------------*/ /* ----------------------------------- INSPECTOR FUNCTIONS ------------------------------------*/ /* --------------------------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------------------------*/ public void AddCondition() { UtilityScorer scorer = new UtilityScorer(true); this.scorers.Add(scorer); }
// Add scorer to this action public void AddScorer(UtilityScorer scorer) { _scorers.Add(scorer); }