Пример #1
0
    public void SpawnAgent(AgentEntity.EntityType type)
    {
        IncrementAgentType(type);
        switch (type)
        {
        case AgentEntity.EntityType.farmer:
            SpawnFarmer();
            break;

        case AgentEntity.EntityType.woodcutter:
            SpawnWoodcutter();
            break;

        case AgentEntity.EntityType.miner:
            SpawnMiner();
            break;

        case AgentEntity.EntityType.smelter:
            SpawnSmelter();
            break;

        case AgentEntity.EntityType.blacksmith:
            SpawnBlacksmith();
            break;
        }
        AgentEntity newAgent = Agents[Agents.Count - 1];

        AddAgentToGuild(newAgent);
    }
Пример #2
0
    private AgentEntity.EntityType MostProfitableAgentType()
    {
        float sumOfProfits            = 0;
        float meanProfit              = 0;
        float highestMeanProfit       = 0;
        List <AgentEntity> listOfType = new List <AgentEntity>();

        AgentEntity.EntityType mostProfitable = new AgentEntity.EntityType();

        foreach (AgentEntity.EntityType type in Enum.GetValues(typeof(AgentEntity.EntityType)))
        {
            listOfType = Agents.Where(x => x.Type == type).ToList();
            foreach (AgentEntity agent in listOfType)
            {
                sumOfProfits += agent.ProfitLedger.Skip(Math.Max(0, agent.ProfitLedger.Count() - 15)).ToList().Sum();
            }

            int numberOfType = Agents.Count(x => x.Type == type);

            if (numberOfType > 0)
            {
                meanProfit = sumOfProfits / Agents.Count(x => x.Type == type);
                if (meanProfit > highestMeanProfit)
                {
                    highestMeanProfit = meanProfit;
                    mostProfitable    = type;
                }
            }
        }

        return(mostProfitable);
    }
Пример #3
0
    public Resource(int id, string displayName, ResourceUtil.ResourceType type, float basePrice, AgentEntity.EntityType producedBy, ProductionDifficulty difficultyToProduce)
    {
        Id          = id;
        DisplayName = displayName;
        Type        = type;
        BasePrice   = basePrice;
        ProducedBy  = producedBy;

        ProductionDifficultyModifier = DifficultyToProduce(difficultyToProduce);
    }
Пример #4
0
 private void IncrementAgentType(AgentEntity.EntityType type)
 {
     if (AgentTypeCount.ContainsKey(type))
     {
         AgentTypeCount[type]++;
     }
     else
     {
         AgentTypeCount.Add(type, 1);
     }
 }
Пример #5
0
    private AgentEntity.EntityType MostDemandedAgentType()
    {
        float difference         = 0;
        float greatestDifference = 0;

        AgentEntity.EntityType mostDemandedAgentType = new AgentEntity.EntityType();

        foreach (KeyValuePair <ResourceUtil.ResourceType, Market> market in Markets)
        {
            difference = market.Value.RecentDemandAverage() - market.Value.RecentSupplyAverage();

            if (difference > 0 && difference > greatestDifference)
            {
                greatestDifference    = difference;
                mostDemandedAgentType = market.Value.Resource.ProducedBy;
            }
        }

        return(mostDemandedAgentType);
    }
Пример #6
0
 public List <TransactionRecord> GetAllTransactionsBySellerType(AgentEntity.EntityType type) //These can also be moved to Town class
 {
     return(TransactionHistory.Where(record => record.Seller.Type == type).ToList());
 }