Skip to content

Commit

Permalink
Use fallback method (O(n^2)) when keycount != 4 to address bug Quaver…
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamQiufeng committed Aug 18, 2024
1 parent 203bb4f commit d2e7241
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,19 +562,30 @@ private float CalculateOverallDifficulty()

var l = 0;
var r = 0;
var useFallback = Map.GetKeyCount() != 4;
while (l < StrainSolverData.Count && StrainSolverData[l].StartTime < mapStart)
l++;
for (var i = mapStart; i < mapEnd; i += binSize)
{
while (r < StrainSolverData.Count - 1 && StrainSolverData[r + 1].StartTime < i + binSize)
r++;
if (l >= StrainSolverData.Count)
List<StrainSolverData> valuesInBin;
if (useFallback)
{
bins.Add(0);
continue;
valuesInBin = StrainSolverData.Where(s => s.StartTime >= i && s.StartTime < i + binSize)
.ToList();
}
else
{
while (r < StrainSolverData.Count - 1 && StrainSolverData[r + 1].StartTime < i + binSize)
r++;
if (l >= StrainSolverData.Count)
{
bins.Add(0);
continue;
}

valuesInBin = StrainSolverData.GetRange(l, r - l + 1);
}

var valuesInBin = StrainSolverData.GetRange(l, r - l + 1);
var averageRating = valuesInBin.Count > 0 ? valuesInBin.Average(s => s.TotalStrainValue) : 0;

bins.Add(averageRating);
Expand Down

0 comments on commit d2e7241

Please sign in to comment.