protected override void Execute(List <GameEntity> entities) { GameEntity[] niches = Markets.GetNiches(gameContext); foreach (var niche in niches) { Markets.FillMarket(niche, gameContext); } }
void MockySimulation(int skipDays, GameContext GameContext) { var markets = Markets.GetNiches(GameContext); var skipMonths = skipDays / 30; var date = ScheduleUtils.GetCurrentDate(GameContext); List <NicheType> activatedMarkets = new List <NicheType>(); // simulate market development foreach (var m in markets) { var spawnTime = m.nicheLifecycle.OpenDate; var monthsOfWork = (date - spawnTime) / 30; var accumulator = monthsOfWork; // niche state promotion while (accumulator > 0) { Markets.PromoteNicheState(m); accumulator -= Markets.GetNicheDuration(m); } // filling with companies var amountOfCompanies = UnityEngine.Random.Range(0, monthsOfWork / 12); for (var i = 0; i < amountOfCompanies; i++) { Markets.FillMarket(m, GameContext); } var costs = m.nicheCosts; var isMockup = costs.AcquisitionCost == 1 && costs.Audience == 1 && costs.BaseIncome == 1 && costs.TechCost == 1; if (!isMockup) { activatedMarkets.Add(m.niche.NicheType); } } Debug.Log("Mocky simulation: simulated markets"); // simulate products var products = Companies.GetProductCompanies(GameContext); foreach (var p in products) { var niche = Markets.Get(GameContext, p.product.Niche); var spawnTime = niche.nicheLifecycle.OpenDate; var monthsOfWork = (date - spawnTime) / 30; //Debug.Log($"Market={p.product.Niche} Date: " + date + " openDate " + spawnTime + " monthsOfWork = " + monthsOfWork); if (monthsOfWork < 0) { monthsOfWork = 0; } } Debug.Log("Mocky simulation: simulated product"); //PrintMarketData(markets, activatedMarkets); }
void MockySimulation(int skipDays) { var markets = Markets.GetNiches(GameContext); var skipMonths = skipDays / 30; var date = ScheduleUtils.GetCurrentDate(GameContext); List <NicheType> activatedMarkets = new List <NicheType>(); Debug.Log("Mocky simulation: simulate market development"); // simulate market development foreach (var m in markets) { var spawnTime = m.nicheLifecycle.OpenDate; var monthsOfWork = (date - spawnTime) / 30; var accumulator = monthsOfWork; // niche state promotion var profile = m.nicheBaseProfile.Profile; while (accumulator > 0) { Debug.Log("while"); Markets.PromoteNicheState(m); accumulator -= Markets.GetNicheDuration(m); } // filling with companies var amountOfCompanies = UnityEngine.Random.Range(0, monthsOfWork / 12); for (var i = 0; i < amountOfCompanies; i++) { Markets.FillMarket(m, GameContext); } var costs = m.nicheCosts; var isMockup = costs.AcquisitionCost == 1 && costs.Audience == 1 && costs.BaseIncome == 1 && costs.TechCost == 1; if (!isMockup) { activatedMarkets.Add(m.niche.NicheType); } } Debug.Log("Mocky simulation: simulate product development"); // simulate products var products = Companies.GetProductCompanies(GameContext); foreach (var p in products) { var niche = Markets.GetNiche(GameContext, p.product.Niche); var spawnTime = niche.nicheLifecycle.OpenDate; var monthsOfWork = (date - spawnTime) / 30; //Debug.Log($"Market={p.product.Niche} Date: " + date + " openDate " + spawnTime + " monthsOfWork = " + monthsOfWork); if (monthsOfWork < 0) { monthsOfWork = 0; } // set concepts var iterationTime = Products.GetBaseIterationTime(niche); var concept = monthsOfWork * 30 / iterationTime; var randConcept = 1 + UnityEngine.Random.Range(0, concept); //for (var i = 0; i < randConcept; i++) // Products.UpdgradeProduct(p, GameContext, true); // set brands // commented, because UpgradeProduct already adds brand powers //var brand = Mathf.Clamp(UnityEngine.Random.Range(0, monthsOfWork / 2), 0, 35); //MarketingUtils.AddBrandPower(p, brand); // set clients //var flow = (float) MarketingUtils.GetClientFlow(GameContext, p.product.Niche); ////var clients = monthsOfWork * flow * UnityEngine.Random.Range(0.5f, 1.5f); //var growth = 1.03f; //var clients = MarketingUtils.GetClients(p) * Mathf.Pow(growth, monthsOfWork); //MarketingUtils.AddClients(p, (long)clients); } Dictionary <int, int> years = new Dictionary <int, int>(); foreach (var m in markets) { var openDate = ScheduleUtils.GetYearOf(m.nicheLifecycle.OpenDate); if (years.ContainsKey(openDate)) { years[openDate]++; } else { years[openDate] = 1; } } var pre2000markets = 0; var post2000markets = 0; foreach (var m in years.OrderBy(p => p.Key)) { var year = m.Key; var amount = m.Value; if (year < 2000) { pre2000markets += amount; } else { post2000markets += amount; } Debug.Log($"Year {m.Key}: {m.Value} markets"); } Debug.Log("Pre 2000 markets: " + pre2000markets); Debug.Log("Post 2000 markets: " + post2000markets); List <NicheType> list = new List <NicheType>(); List <NicheType> notActivated = new List <NicheType>(); foreach (NicheType n in (NicheType[])Enum.GetValues(typeof(NicheType))) { if (Enums.GetFormattedNicheName(n) == n.ToString()) { list.Add(n); } if (!activatedMarkets.Contains(n)) { notActivated.Add(n); } } if (list.Count != 0) { Debug.Log(list.Count + " markets need to be described: " + string.Join(",", list)); } if (notActivated.Count != 0) { Debug.Log(notActivated.Count + " markets need to be activated: " + string.Join(",", notActivated)); } }