Пример #1
0
        private void ComputeExternalTrade(ResourceType resourceType, ExternalMarket externalMarket)
        {
            var resourceRatio = ResourceData[resourceType.Id].ResourceRatio;

            if (resourceRatio > 1)
            {
                double externalPrice = externalMarket.GetBestCost(resourceType, out ExternalMarket destination);

                double priceRatio = externalPrice / ResourceData[resourceType.Id].ResourcesPrice;
                if (priceRatio > ExternalTradingThreshold)
                {
                    externalMarket.StartTrade(Supply[resourceType.Id].tradingResources, (resourceRatio - 1) / resourceRatio, destination);
                }
            }
        }
Пример #2
0
        public void ComputeNewStock(ExternalMarket externalMarket)
        {
            foreach (ResourceType resourceType in ResourceTypes.resourceTypes)
            {
                ComputeResourceRatio(resourceType, out double supplyAmount, out double demandAmount);
                ComputeExternalTrade(resourceType, externalMarket);
            }
            externalMarket.UpdateTrade(Supply);

            foreach (ResourceType resourceType in ResourceTypes.resourceTypes)
            {
                MergeDublicates(resourceType);

                ComputeResourceRatio(resourceType, out double supplyAmount, out double demandAmount);
            }
        }
Пример #3
0
        public void ComputeNewStock(ExternalMarket externalMarket)
        {
            foreach (ResourceTypes.ResourceType resourceType in ResourceTypes.GetIterator())
            {
                ComputeResourceRatio(resourceType);
                externalMarket.ComputeExternalTrade(GetExternalSupply(resourceType), Demand.GetAmount(resourceType), resourceType, GetSupplyToDemandRatio(resourceType).GetSupplyToDemandRatio(), this);
            }
            externalMarket.UpdateTrade(ExternalSupply);

            foreach (ResourceTypes.ResourceType resourceType in ResourceTypes.GetIterator())
            {
                MergeDublicates(GetSupply(resourceType));
                MergeDublicates(GetExternalSupply(resourceType));
                ComputeResourceRatio(resourceType);
            }
        }
Пример #4
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);
        }
Пример #5
0
 public void StartTrade(List <TradingResource> TradingResources, double ratio, ExternalMarket destination)
 {
     foreach (TradingResource tradingResounce in TradingResources)
     {
         if (tradingResounce.AffordTransport())
         {
             ExternatlTradingResources.Add(tradingResounce.SplitExternal(ratio, destination, Ownregion.GetTransportTime() / 2));
         }
     }
 }