コード例 #1
0
        private double CalculateDifficulty(int nobjects)
        {
            double actualStrainStep = c_strainStep * ModsUtils.GetTimeRate(_mods);

            List <double> highestStrains  = new List <double>();
            double        intervalEndTime = actualStrainStep;
            double        maximumStrain   = 0;

            ManiaBeatmapObject prev = null;

            for (int i = 0; i < nobjects; i++)
            {
                ManiaBeatmapObject note = Beatmap.Objects[i] as ManiaBeatmapObject;

                Debug.Assert(note != null, nameof(note) + " != null");
                while (note.StartTime > intervalEndTime)
                {
                    highestStrains.Add(maximumStrain);

                    if (prev == null)
                    {
                        maximumStrain = 0;
                    }
                    else
                    {
                        double individualDecay = Math.Pow(ManiaBeatmapObject.INDIVIDUAL_DECAY_BASE, (intervalEndTime - prev.StartTime) / 1000.0);
                        double overallDecay    = Math.Pow(ManiaBeatmapObject.OVERALL_DECAY_BASE, (intervalEndTime - prev.StartTime) / 1000.0);
                        maximumStrain = prev.IndividualStrain * individualDecay + prev.OverallStrain * overallDecay;
                    }

                    intervalEndTime += actualStrainStep;
                }

                double strain = note.IndividualStrain + note.OverallStrain;
                if (strain > maximumStrain)
                {
                    maximumStrain = strain;
                }

                prev = note;
            }

            double diff   = 0;
            double weigth = 1;

            highestStrains.Sort((a, b) => b.CompareTo(a));

            foreach (var strain in highestStrains)
            {
                diff   += strain * weigth;
                weigth *= c_decayWeight;
            }

            return(diff);
        }
コード例 #2
0
        private void CalculateStrainValues(int nobjects)
        {
            var prevObject = Beatmap.Objects[0] as ManiaBeatmapObject;

            for (int i = 1; i < nobjects; i++)
            {
                var curObject = Beatmap.Objects[i] as ManiaBeatmapObject;
                Debug.Assert(curObject != null, nameof(curObject) + " != null");
                curObject.ManiaCalculateStrains(prevObject, ModsUtils.GetTimeRate(_mods));
                prevObject = curObject;
            }
        }