Beispiel #1
0
        public double GetExpansionValue(BotBonus bonus, Boolean useNeighborBonusFactor)
        {
            double expansionValue = 0.0;

            if (IsExpansionWorthless(bonus))
            {
                return(expansionValue);
            }

            expansionValue = GetIncomeCostsRatio(bonus);

            var    neutralArmies       = bonus.NeutralArmies.DefensePower;
            double neutralArmiesFactor = GetNeutralArmiesFactor(neutralArmies);

            int    allTerritories  = bonus.Territories.Count;
            double territoryFactor = GetTerritoryFactor(allTerritories);


            int    immediatelyCounteredTerritories       = bonus.GetOwnedTerritoriesBorderingOpponent().Count;
            double immediatelyCounteredTerritoriesFactor = GetImmediatelyCounteredTerritoryFactor(immediatelyCounteredTerritories);

            var    allCounteredTerritories       = GetCounteredTerritories(bonus, BotState.Me.ID);
            double allCounteredTerritoriesFactor = GetAllCounteredTerritoryFactor(allCounteredTerritories);

            int amountNeighborBonusesWithOpponent = 0;
            var neighborBonuses = bonus.GetNeighborBonuses();

            foreach (var neighborBonus in neighborBonuses)
            {
                if (neighborBonus.ContainsOpponentPresence())
                {
                    amountNeighborBonusesWithOpponent++;
                }
            }
            double opponentNeighborBonusFactor = GetOpponentInNeighborBonusFactor(amountNeighborBonusesWithOpponent);
            double borderTerritoriesFactor     = getBorderTerritoriesFactor(bonus);

            double completeFactor = neutralArmiesFactor + territoryFactor + immediatelyCounteredTerritoriesFactor + allCounteredTerritoriesFactor + opponentNeighborBonusFactor + borderTerritoriesFactor;

            if (useNeighborBonusFactor)
            {
                completeFactor += GetNeighborBonusesFactor(bonus);
            }
            completeFactor = Math.Min(completeFactor, 0.8);

            expansionValue = expansionValue - (expansionValue * completeFactor);

            return(expansionValue);
        }