mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 14:13:18 +08:00
Attempt to implement Catch performance calculator
This commit is contained in:
parent
e4ff36a5bc
commit
f83163e78e
@ -16,6 +16,7 @@ using osu.Game.Beatmaps.Legacy;
|
|||||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Difficulty;
|
using osu.Game.Rulesets.Catch.Difficulty;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch
|
namespace osu.Game.Rulesets.Catch
|
||||||
{
|
{
|
||||||
@ -112,6 +113,8 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
|
|
||||||
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchDifficultyCalculator(this, beatmap);
|
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchDifficultyCalculator(this, beatmap);
|
||||||
|
|
||||||
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new CatchPerformanceCalculator(this, beatmap, score);
|
||||||
|
|
||||||
public override int? LegacyID => 2;
|
public override int? LegacyID => 2;
|
||||||
|
|
||||||
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame();
|
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame();
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright (c) 2007-2019 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Difficulty
|
||||||
|
{
|
||||||
|
public class CatchPerformanceCalculator : PerformanceCalculator
|
||||||
|
{
|
||||||
|
protected new CatchDifficultyAttributes Attributes => (CatchDifficultyAttributes)base.Attributes;
|
||||||
|
|
||||||
|
private Mod[] mods;
|
||||||
|
private int countGreat;
|
||||||
|
private int countGood;
|
||||||
|
private int countMeh;
|
||||||
|
private int countMiss;
|
||||||
|
private int countKatu;
|
||||||
|
|
||||||
|
public CatchPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
|
||||||
|
: base(ruleset, beatmap, score) { }
|
||||||
|
|
||||||
|
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
|
||||||
|
{
|
||||||
|
mods = Score.Mods;
|
||||||
|
countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
|
||||||
|
countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
|
||||||
|
countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
|
||||||
|
countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);
|
||||||
|
countKatu = Convert.ToInt32(Score.Statistics[HitResult.Ok]); // TODO: check
|
||||||
|
|
||||||
|
// Don't count scores made with supposedly unranked mods
|
||||||
|
if (mods.Any(m => !m.Ranked))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// We are heavily relying on aim in catch the beat
|
||||||
|
// TODO: replaced Aim with StarRating, not sure if this is correct!
|
||||||
|
double value = Math.Pow(5.0f * Math.Max(1.0f, Attributes.StarRating / 0.0049f) - 4.0f, 2.0f) / 100000.0f;
|
||||||
|
|
||||||
|
// Longer maps are worth more. "Longer" means how many hits there are which can contribute to combo
|
||||||
|
int numTotalHits = totalComboHits();
|
||||||
|
|
||||||
|
// Longer maps are worth more
|
||||||
|
float lengthBonus =
|
||||||
|
0.95f + 0.4f * Math.Min(1.0f, numTotalHits / 3000.0f) +
|
||||||
|
(numTotalHits > 3000 ? (float)Math.Log10(numTotalHits / 3000.0f) * 0.5f : 0.0f);
|
||||||
|
|
||||||
|
// Longer maps are worth more
|
||||||
|
value *= lengthBonus;
|
||||||
|
|
||||||
|
// Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
|
||||||
|
value *= Math.Pow(0.97f, countMiss);
|
||||||
|
|
||||||
|
// Combo scaling
|
||||||
|
float beatmapMaxCombo = Attributes.MaxCombo;
|
||||||
|
if (beatmapMaxCombo > 0)
|
||||||
|
value *= Math.Min(Math.Pow(Attributes.MaxCombo, 0.8f) / Math.Pow(beatmapMaxCombo, 0.8f), 1.0f);
|
||||||
|
|
||||||
|
float approachRate = (float)Attributes.ApproachRate;
|
||||||
|
float approachRateFactor = 1.0f;
|
||||||
|
if (approachRate > 9.0f)
|
||||||
|
approachRateFactor += 0.1f * (approachRate - 9.0f); // 10% for each AR above 9
|
||||||
|
else if (approachRate < 8.0f)
|
||||||
|
approachRateFactor += 0.025f * (8.0f - approachRate); // 2.5% for each AR below 8
|
||||||
|
|
||||||
|
value *= approachRateFactor;
|
||||||
|
|
||||||
|
if (mods.Any(m => m is ModHidden))
|
||||||
|
// Hiddens gives nothing on max approach rate, and more the lower it is
|
||||||
|
value *= 1.05f + 0.075f * (10.0f - Math.Min(10.0f, approachRate)); // 7.5% for each AR below 10
|
||||||
|
|
||||||
|
if (mods.Any(m => m is ModFlashlight))
|
||||||
|
// Apply length bonus again if flashlight is on simply because it becomes a lot harder on longer maps.
|
||||||
|
value *= 1.35f * lengthBonus;
|
||||||
|
|
||||||
|
// Scale the aim value with accuracy _slightly_
|
||||||
|
value *= Math.Pow(accuracy(), 5.5f);
|
||||||
|
|
||||||
|
// Custom multipliers for NoFail. SpunOut is not applicable.
|
||||||
|
if (mods.Any(m => m is ModNoFail))
|
||||||
|
value *= 0.90f;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float accuracy() => totalHits() == 0 ? 0 : MathHelper.Clamp((float)totalSuccessfulHits() / totalHits(), 0f, 1f);
|
||||||
|
private int totalHits() => countMeh + countGood + countGreat + countMiss + countKatu;
|
||||||
|
private int totalSuccessfulHits() => countMeh + countGood + countGreat;
|
||||||
|
private int totalComboHits() => countMeh + countGood + countGreat;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user