Exemplo n.º 1
0
        /// <summary>Calculates the expansion territory value for a territory.</summary>
        /// <remarks>Calculates the expansion territory value for a territory.</remarks>
        /// <param name="territory">the territory which can be part of an arbitrary map</param>
        /// <param name="mapToWriteIn">the map in which the calculated territory value is to be inserted
        /// </param>
        private void CalculateExpansionTerritoryValue(BotTerritory territory, BotMap mapToWriteIn)
        {
            var currentValue         = 0;
            var neighborsWithinBonus = territory.GetNeighborsWithinSameBonus();

            // Add 1000 for each unknown neighbor within the same Bonus
            foreach (var neighbor in neighborsWithinBonus)
            {
                if (neighbor.OwnerPlayerID == TerritoryStanding.NeutralPlayerID && neighbor.GetOwnedNeighbors().Count == 0)
                {
                    currentValue += 1000;
                }
            }
            // Add 100 for each neighbor within the same Bonus
            foreach (var neighbor_1 in neighborsWithinBonus)
            {
                if (neighbor_1.OwnerPlayerID == TerritoryStanding.NeutralPlayerID)
                {
                    currentValue += 100;
                }
            }
            // Add 10 for each opponent neighbor
            currentValue += 10 * territory.GetOpponentNeighbors().Count;

            // Add 1 for each neutral neighbor in another Bonus
            foreach (var neighbor_2 in territory.Neighbors)
            {
                if (neighbor_2.OwnerPlayerID == TerritoryStanding.NeutralPlayerID && !neighborsWithinBonus.Contains(neighbor_2))
                {
                    currentValue += 1;
                }
            }

            mapToWriteIn.Territories[territory.ID].ExpansionTerritoryValue = currentValue;
        }