Fixing code style

This commit is contained in:
frankhjwx 2018-05-21 10:12:18 +08:00
parent 44fd4b95bd
commit 0405383e4e
4 changed files with 23 additions and 27 deletions

View File

@ -31,7 +31,6 @@ public CatchDifficultyCalculator(IBeatmap beatmap, Mod[] mods)
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
difficultyHitObjects.Clear();
float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize;
@ -83,7 +82,6 @@ protected bool CalculateStrainValues()
// Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment.
using (List<CatchDifficultyHitObject>.Enumerator hitObjectsEnumerator = difficultyHitObjects.GetEnumerator())
{
if (!hitObjectsEnumerator.MoveNext()) return false;
CatchDifficultyHitObject currentHitObject = hitObjectsEnumerator.Current;
@ -106,17 +104,17 @@ protected bool CalculateStrainValues()
/// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain.
/// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage.
/// </summary>
protected const double STRAIN_STEP = 750;
protected const double strain_step = 750;
/// <summary>
/// The weighting of each strain value decays to this number * it's previous value
/// </summary>
protected const double DECAY_WEIGHT = 0.94;
protected const double decay_weight = 0.94;
protected double CalculateDifficulty()
{
// The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods
double actualStrainStep = STRAIN_STEP * TimeRate;
double actualStrainStep = strain_step * TimeRate;
// Find the highest strain value within each strain step
List<double> highestStrains = new List<double>();
@ -153,17 +151,8 @@ protected double CalculateDifficulty()
previousHitObject = hitObject;
}
// Build the weighted sum over the highest strains for each interval
double difficulty = 0;
double weight = 1;
highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain.
foreach (double strain in highestStrains)
{
difficulty += weight * strain;
weight *= DECAY_WEIGHT;
}
// calculate maximun strain difficulty
double difficulty = StrainCalculator(highestStrains, decay_weight);
return difficulty;
}

View File

@ -36,7 +36,7 @@ internal CatchDifficultyHitObject(CatchHitObject baseHitObject, float catcherWid
// We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps.
float scalingFactor = NORMALIZED_HITOBJECT_RADIUS / catcherWidthHalf;
playerPositioningError = ABSOLUTE_PLAYER_POSITIONING_ERROR;// * scalingFactor;
playerPositioningError = ABSOLUTE_PLAYER_POSITIONING_ERROR; // * scalingFactor;
NormalizedPosition = baseHitObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor;
}

View File

@ -122,16 +122,8 @@ private double calculateDifficulty()
previousHitObject = hitObject;
}
// Build the weighted sum over the highest strains for each interval
double difficulty = 0;
double weight = 1;
highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain.
foreach (double strain in highestStrains)
{
difficulty += weight * strain;
weight *= decay_weight;
}
// calculate maximun strain difficulty
double difficulty = StrainCalculator(highestStrains, decay_weight);
return difficulty;
}

View File

@ -37,5 +37,20 @@ protected virtual void PreprocessHitObjects()
}
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
protected double StrainCalculator(List<double> highestStrains, double decayWeight)
{
// Build the weighted sum over the highest strains for each interval
double difficulty = 0;
double weight = 1;
highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain.
foreach (double strain in highestStrains)
{
difficulty += weight * strain;
weight *= decayWeight;
}
return difficulty;
}
}
}