private void CalculateTakeOverValue(BotBonus bonus, BotMap mapToWriteIn) { var armiesReward = bonus.Amount; var opponentTerritories = bonus.GetOpponentTerritories(); var amountOpponentTerritories = opponentTerritories.Count; var opponentArmies = 0; foreach (var opponentTerritory in opponentTerritories) { opponentArmies += opponentTerritory.Armies.DefensePower; } var possibleAttackTerritories = new HashSet <BotTerritory>(); foreach (var opponentTerritory_1 in opponentTerritories) { possibleAttackTerritories.AddRange(opponentTerritory_1.GetOwnedNeighbors()); } var ownArmies = 0; foreach (var possibleAttackTerritory in possibleAttackTerritories) { ownArmies += possibleAttackTerritory.GetIdleArmies().AttackPower; } var amountTerritories = bonus.Territories.Count; var opponentNeighbors = bonus.GetOpponentNeighbors().Count; var takeOverValue = 0; takeOverValue += armiesReward * 10000; takeOverValue += opponentArmies * -10; takeOverValue += ownArmies * 10; takeOverValue += opponentNeighbors * -1; takeOverValue += amountOpponentTerritories * -1000; takeOverValue += amountTerritories * -1; takeOverValue *= BonusTakeOverFactor; mapToWriteIn.Bonuses[bonus.ID].TakeOverValue = takeOverValue; }