コード例 #1
0
        public void SimulateTimePassed(int totalTimePassed, List <int> timeLine)
        {
            BoonStack  b = new BoonStackIntensity(_capacity);
            List <int> s = new List <int>(_stack);

            b.Stack = s;

            if (s.Count > 0)
            {
                int tt  = 0;
                int min = s.Min();

                for (int i = 1; i < totalTimePassed; i++)
                {
                    if ((i - tt) >= min)
                    {
                        b.Update(i - tt);
                        if (s.Count > 0)
                        {
                            min = s.Min();
                        }
                        tt = i;
                    }
                    timeLine.Add(b.CalculateValue());
                }
            }
            else
            {
                for (int i = 1; i < totalTimePassed; i++)
                {
                    timeLine.Add(0);
                }
            }
        }
コード例 #2
0
ファイル: Converter.cs プロジェクト: phoenix-oosd/EVTC-2-CSV
        private double BoonIntensityStacks(Boon b, List <BoonEvent> boonEvents)
        {
            if (boonEvents.Count == 0)
            {
                return(0.0);
            }
            int        prev = 0;
            int        curr = 0;
            List <int> s    = new List <int> {
                0
            };

            BoonStackIntensity bs = new BoonStackIntensity(b.Capacity);

            foreach (BoonEvent be in boonEvents)
            {
                curr = be.Time;
                bs.SimulateTimePassed(curr - prev, s);
                bs.Update(curr - prev);
                bs.Add(be.Duration);
                if (prev != curr)
                {
                    s.Add(bs.CalculateValue());
                }
                else
                {
                    s[s.Count - 1] = bs.CalculateValue();
                }
                prev = curr;
            }
            bs.SimulateTimePassed(_time - prev, s);
            bs.Update(1);
            s.Add(bs.CalculateValue());
            //Console.WriteLine();
            //Console.WriteLine(s.Sum() + "|" +_time);
            //using (StreamWriter f = new StreamWriter("stacks.txt"))
            //{
            //    foreach (int k in s)
            //    {
            //        f.WriteLine(k.ToString());
            //    }
            //}
            //Console.Read();

            return(s.Average());
        }