public override double getIncome()
        {
            double pos = 0.01 * Math.Pow(popularity + members.Count, 2);
            TriangularDistribution t = new TriangularDistribution(-0.5, 3, 1);

            pos *= t.Sample(rand);
            return(pos * 2.5);
        }
Beispiel #2
0
        public int MineralConcentration(int highConcBias = 0)
        {
            var lowChance = 30 - (highConcBias * 5);

            if (this.Next(100) < lowChance)
            {
                return(this.Next(1, 31));
            }

            return((int)TriangularDistribution.Sample(this.rng, 31, 75, 120));
        }
Beispiel #3
0
        /// <summary>
        /// Calculates the income of this company, updates popularity based on astroturfs, and removes sold stock
        /// </summary>
        /// <returns>the amount of money the company earned in this turn</returns>
        public double getIncome()
        {
            TriangularDistribution t = new TriangularDistribution(0.5, 2, 1.2);
            double sellRate          = popularityToModifier(popularity * t.Sample());
            double output            = 0;

            foreach (string key in productStock.Keys.ToList())
            {
                int sold = (int)(productStock[key] * sellRate);
                productStock[key] -= sold;
                output            += products[key] * sold;
            }

            //Dividends
            output -= getDividendCost(output, true);

            //Update popularity
            if (astroturfs < 1)
            {
                astroturfs = 1;
            }
            popularity *= (1 + (astroturfs)) / (2 + (astroturfs));
            if (astroturfs > 1)
            {
                astroturfs--;
            }

            //Update stock history
            stock_history.Add(stock_price);

            foreach (string p in automation)
            {
                if (productStock.ContainsKey(p))
                {
                    productStock[p]++;
                }
                else
                {
                    //Remove discontinued/errored products
                    //automation.Remove(p);
                    //Never mind, it doesn't like when you delete stuff in its own foreach loop
                }
            }

            //Update owner
            updateOwner();
            return(output);
        }