1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:23:22 +08:00

Merge branch 'taiko-evaluators' into colour-rework

This commit is contained in:
vun 2022-06-06 12:45:48 +08:00
commit bfada36554
4 changed files with 72 additions and 101 deletions

View File

@ -0,0 +1,46 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
{
public class StaminaEvaluator
{
/// <summary>
/// Applies a speed bonus dependent on the time since the last hit performed using this key.
/// </summary>
/// <param name="notePairDuration">The duration between the current and previous note hit using the same key.</param>
private static double speedBonus(double notePairDuration)
{
return 175 / (notePairDuration + 100);
}
/// <summary>
/// Evaluates the minimum mechanical stamina required to play the current object. This is calculated using the
/// maximum possible interval between two hits using the same key, by alternating 2 keys for each colour.
/// </summary>
public static double EvaluateDifficultyOf(DifficultyHitObject current)
{
if (!(current.BaseObject is Hit))
{
return 0.0;
}
// Find the previous hit object hit by the current key, which is two notes of the same colour prior.
TaikoDifficultyHitObject taikoCurrent = (TaikoDifficultyHitObject)current;
TaikoDifficultyHitObject keyPrevious = taikoCurrent.PreviousMono(1);
if (keyPrevious == null)
{
// There is no previous hit object hit by the current key
return 0.0;
}
double objectStrain = 0.5;
objectStrain += speedBonus(taikoCurrent.StartTime - keyPrevious.StartTime);
return objectStrain;
}
}
}

View File

@ -15,6 +15,14 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// </summary>
public class TaikoDifficultyHitObject : DifficultyHitObject
{
// TODO: Review this - these was originally handled in TaikodifficultyCalculator.CreateDifficultyHitObjects, but
// it might be a good idea to encapsulate as much detail within the class as possible.
private static List<TaikoDifficultyHitObject> centreHitObjects = new List<TaikoDifficultyHitObject>();
private static List<TaikoDifficultyHitObject> rimHitObjects = new List<TaikoDifficultyHitObject>();
private readonly IReadOnlyList<TaikoDifficultyHitObject> monoDifficultyHitObjects;
public readonly int MonoPosition;
/// <summary>
/// The rhythm required to hit this hit object.
/// </summary>
@ -62,6 +70,18 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
Colour = TaikoDifficultyHitObjectColour.GetInstanceFor(this);
}
if (HitType == Objects.HitType.Centre)
{
MonoPosition = centreHitObjects.Count();
centreHitObjects.Add(this);
monoDifficultyHitObjects = centreHitObjects;
}
else if (HitType == Objects.HitType.Rim)
{
MonoPosition = rimHitObjects.Count();
rimHitObjects.Add(this);
monoDifficultyHitObjects = rimHitObjects;
}
}
/// <summary>
@ -100,5 +120,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
return common_rhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First();
}
public TaikoDifficultyHitObject PreviousMono(int backwardsIndex) => monoDifficultyHitObjects.ElementAtOrDefault(MonoPosition - (backwardsIndex + 1));
public TaikoDifficultyHitObject NextMono(int forwardsIndex) => monoDifficultyHitObjects.ElementAtOrDefault(MonoPosition + (forwardsIndex + 1));
}
}

View File

@ -1,52 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Taiko.Difficulty.Evaluators;
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
{
/// <summary>
/// Stamina of a single key, calculated based on repetition speed.
/// </summary>
public class SingleKeyStamina
{
private const double StrainDecayBase = 0.4;
private double CurrentStrain = 0;
private double? previousHitTime;
/// <summary>
/// Similar to <see cref="StrainDecaySkill.StrainValueOf"/>
/// </summary>
public double StrainValueOf(DifficultyHitObject current)
{
if (previousHitTime == null)
{
previousHitTime = current.StartTime;
return 0;
}
// CurrentStrain += strainDecay(current.StartTime - current.Previous(0).StartTime);
// CurrentStrain += 0.5 + 0.5 * strainDecay(current.StartTime - current.Previous(0).StartTime);
CurrentStrain += 1;
CurrentStrain *= ColourEvaluator.EvaluateDifficultyOf(current) * 0.1 + 0.9;
CurrentStrain *= strainDecay(current.StartTime - previousHitTime.Value);
previousHitTime = current.StartTime;
return CurrentStrain;
}
/// <summary>
/// Applies a speed bonus dependent on the time since the last hit performed using this key.
/// </summary>
/// <param name="notePairDuration">The duration between the current and previous note hit using the same key.</param>
private double strainDecay(double notePairDuration)
{
return Math.Pow(StrainDecayBase, notePairDuration / 1000);
// return 175 / (notePairDuration + 100);
}
}
}

View File

@ -4,8 +4,8 @@
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Difficulty.Evaluators;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
@ -21,28 +21,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
protected override double SkillMultiplier => 3.6;
protected override double StrainDecayBase => 0;
private readonly SingleKeyStamina[] centreKeyStamina =
{
new SingleKeyStamina(),
new SingleKeyStamina()
};
private readonly SingleKeyStamina[] rimKeyStamina =
{
new SingleKeyStamina(),
new SingleKeyStamina()
};
/// <summary>
/// Current index into <see cref="centreKeyStamina" /> for a centre hit.
/// </summary>
private int centreKeyIndex;
/// <summary>
/// Current index into <see cref="rimKeyStamina" /> for a rim hit.
/// </summary>
private int rimKeyIndex;
/// <summary>
/// Creates a <see cref="Stamina"/> skill.
/// </summary>
@ -52,34 +30,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
{
}
/// <summary>
/// Get the next <see cref="SingleKeyStamina"/> to use for the given <see cref="TaikoDifficultyHitObject"/>.
/// </summary>
/// <param name="current">The current <see cref="TaikoDifficultyHitObject"/>.</param>
private SingleKeyStamina getNextSingleKeyStamina(TaikoDifficultyHitObject current)
{
// Alternate key for the same color.
if (current.HitType == HitType.Centre)
{
centreKeyIndex = (centreKeyIndex + 1) % 2;
return centreKeyStamina[centreKeyIndex];
}
rimKeyIndex = (rimKeyIndex + 1) % 2;
return rimKeyStamina[rimKeyIndex];
}
protected override double StrainValueOf(DifficultyHitObject current)
{
if (!(current.BaseObject is Hit))
{
return 0.0;
}
TaikoDifficultyHitObject hitObject = (TaikoDifficultyHitObject)current;
double objectStrain = getNextSingleKeyStamina(hitObject).StrainValueOf(hitObject);
// objectStrain *= ColourEvaluator.EvaluateDifficultyOf(current) * 0.3 + 0.7;
return objectStrain;
return StaminaEvaluator.EvaluateDifficultyOf(current);
}
}
}