예제 #1
0
        public double GetBestCost(ResourceTypes.ResourceType resourceType, out TradeRegion bestRegion, out TradeRegion worstRegion)
        {
            double bestCost  = 0;
            double worstCost = double.MaxValue;

            bestRegion  = null;
            worstRegion = null;
            double regionalTransportCost = Ownregion.GetTransportCost();

            foreach (TradeRegion tradeRegion in TradeRegions)
            {
                double externalTransportCost = tradeRegion.GetTransportCost();
                double totalTransportCost    = (regionalTransportCost + externalTransportCost) / 2;
                double resourceCost          = tradeRegion.GetResorceCost(resourceType);
                double salesCost             = resourceCost - totalTransportCost;
                if (salesCost > bestCost)
                {
                    bestCost   = salesCost;
                    bestRegion = tradeRegion;
                }
                if (tradeRegion.GetTransportAmount(resourceType) > 0 && salesCost < worstCost)
                {
                    worstCost   = salesCost;
                    worstRegion = tradeRegion;
                }
            }
            return(bestCost);
        }
예제 #2
0
        public double GetBestCost(ResourceType resourceType, out ExternalMarket bestRegion)
        {
            double bestCost = 0;

            bestRegion = null;
            double regionalTransportCost = Ownregion.GetTransportCost() / 2;

            foreach (Region region in BorderRegions)
            {
                double externalTransportCost = region.GetTransportCost() / 2;
                double totalTransportCost    = regionalTransportCost + externalTransportCost;
                double resourceCost          = region.GetResorceCost(resourceType);
                double salesCost             = resourceCost - totalTransportCost;
                if (salesCost > bestCost)
                {
                    bestCost   = salesCost;
                    bestRegion = region.GetExternalMarket();
                }
            }

            return(bestCost);
        }