1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Make categoryDifficulties return doubles to improve decimal accuracy

This commit is contained in:
smoogipoo 2017-11-21 19:54:53 +09:00
parent decee415dd
commit f9ad4b6acb
8 changed files with 22 additions and 21 deletions

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Catch
{
}
public override double Calculate(Dictionary<string, string> categoryDifficulty = null) => 0;
public override double Calculate(Dictionary<string, double> categoryDifficulty = null) => 0;
protected override BeatmapConverter<CatchBaseHit> CreateBeatmapConverter(Beatmap beatmap) => new CatchBeatmapConverter();
}

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania
{
}
public override double Calculate(Dictionary<string, string> categoryDifficulty = null) => 0;
public override double Calculate(Dictionary<string, double> categoryDifficulty = null) => 0;
protected override BeatmapConverter<ManiaHitObject> CreateBeatmapConverter(Beatmap beatmap) => new ManiaBeatmapConverter(true, (int)Math.Max(1, Math.Round(beatmap.BeatmapInfo.BaseDifficulty.CircleSize)));
}

View File

@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty
(h as Slider)?.Curve?.Calculate();
}
public override double Calculate(Dictionary<string, string> categoryDifficulty = null)
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
OsuDifficultyBeatmap beatmap = new OsuDifficultyBeatmap(Beatmap.HitObjects, TimeRate);
Skill[] skills =
@ -67,8 +67,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty
if (categoryDifficulty != null)
{
categoryDifficulty.Add("Aim", aimRating.ToString("0.00"));
categoryDifficulty.Add("Speed", speedRating.ToString("0.00"));
categoryDifficulty.Add("Aim", aimRating);
categoryDifficulty.Add("Speed", speedRating);
}
return starRating;

View File

@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
private readonly int beatmapMaxCombo;
private Mod[] mods;
private double realApproachRate;
private double accuracy;
private int scoreMaxCombo;
private int count300;
@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.RepeatCount + s.Ticks.Count());
}
public override double Calculate(Dictionary<string, string> categoryRatings = null)
public override double Calculate(Dictionary<string, double> categoryRatings = null)
{
mods = Score.Mods;
accuracy = Score.Accuracy;
@ -81,9 +82,9 @@ namespace osu.Game.Rulesets.Osu.Scoring
if (categoryRatings != null)
{
categoryRatings.Add("Aim", aimValue.ToString("0.00"));
categoryRatings.Add("Speed", speedValue.ToString("0.00"));
categoryRatings.Add("Accuracy", accuracyValue.ToString("0.00"));
categoryRatings.Add("Aim", aimValue);
categoryRatings.Add("Speed", speedValue);
categoryRatings.Add("Accuracy", accuracyValue);
}
return totalValue;
@ -91,7 +92,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
private double computeAimValue()
{
double aimValue = Math.Pow(5.0f * Math.Max(1.0f, double.Parse(Attributes["Aim"]) / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
double aimValue = Math.Pow(5.0f * Math.Max(1.0f, Attributes["Aim"] / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
// Longer maps are worth more
double lengthBonus = 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +
@ -139,7 +140,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
private double computeSpeedValue()
{
double speedValue = Math.Pow(5.0f * Math.Max(1.0f, double.Parse(Attributes["Speed"]) / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
double speedValue = Math.Pow(5.0f * Math.Max(1.0f, Attributes["Speed"] / 0.0675f) - 4.0f, 3.0f) / 100000.0f;
// Longer maps are worth more
speedValue *= 0.95f + 0.4f * Math.Min(1.0f, totalHits / 2000.0f) +

View File

@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Taiko
{
}
public override double Calculate(Dictionary<string, string> categoryDifficulty = null)
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
// Fill our custom DifficultyHitObject class, that carries additional information
difficultyHitObjects.Clear();
@ -53,8 +53,8 @@ namespace osu.Game.Rulesets.Taiko
if (categoryDifficulty != null)
{
categoryDifficulty.Add("Strain", starRating.ToString("0.00", CultureInfo.InvariantCulture));
categoryDifficulty.Add("Hit window 300", (35 /*HitObjectManager.HitWindow300*/ / TimeRate).ToString("0.00", CultureInfo.InvariantCulture));
categoryDifficulty.Add("Strain", starRating);
categoryDifficulty.Add("Hit window 300", (35 /*HitObjectManager.HitWindow300*/ / TimeRate));
}
return starRating;

View File

@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps
{
protected double TimeRate = 1;
public abstract double Calculate(Dictionary<string, string> categoryDifficulty = null);
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
}
public abstract class DifficultyCalculator<T> : DifficultyCalculator where T : HitObject

View File

@ -9,14 +9,14 @@ namespace osu.Game.Rulesets.Scoring
{
public abstract class PerformanceCalculator
{
public abstract double Calculate(Dictionary<string, string> categoryDifficulty = null);
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
}
public abstract class PerformanceCalculator<TObject> : PerformanceCalculator
where TObject : HitObject
{
private readonly Dictionary<string, string> attributes = new Dictionary<string, string>();
protected IDictionary<string, string> Attributes => attributes;
private readonly Dictionary<string, double> attributes = new Dictionary<string, double>();
protected IDictionary<string, double> Attributes => attributes;
protected readonly Beatmap<TObject> Beatmap;
protected readonly Score Score;

View File

@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual
if (calculator == null)
return;
var attributes = new Dictionary<string, string>();
var attributes = new Dictionary<string, double>();
double performance = calculator.Calculate(attributes);
text.Text = $"{score.User.Username} -> online: {score.PP:n2}pp | local: {performance:n2}pp";
@ -364,12 +364,12 @@ namespace osu.Game.Tests.Visual
var diffCalc = ruleset.CreateDifficultyCalculator(beatmap.Beatmap, activeMods);
if (diffCalc != null)
{
var categories = new Dictionary<string, string>();
var categories = new Dictionary<string, double>();
double totalSr = diffCalc.Calculate(categories);
totalText.Text = $"Star rating: {totalSr:n2}";
foreach (var kvp in categories)
categoryTexts.Add(new OsuSpriteText { Text = $"{kvp.Key}: {kvp.Value}" });
categoryTexts.Add(new OsuSpriteText { Text = $"{kvp.Key}: {kvp.Value:n2}" });
}
informationCache.Validate();