1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

initial rhythm calc testing

This commit is contained in:
Xexxar 2021-08-17 13:39:18 +00:00
parent d8e9845d00
commit c99a96a8c8
3 changed files with 151 additions and 14 deletions

View File

@ -22,17 +22,19 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
}
protected override double SkillMultiplier => 26.25;
protected override double StrainDecayBase => 0.15;
private double currentStrain = 1;
protected override double StrainValueOf(DifficultyHitObject current)
private double skillMultiplier => 26.25;
private double strainDecayBase => 0.15;
private double aimStrainOf(DifficultyHitObject current)
{
if (current.BaseObject is Spinner)
return 0;
var osuCurrent = (OsuDifficultyHitObject)current;
double result = 0;
double aimStrain = 0;
if (Previous.Count > 0)
{
@ -46,7 +48,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
Math.Max(osuPrevious.JumpDistance - scale, 0)
* Math.Pow(Math.Sin(osuCurrent.Angle.Value - angle_bonus_begin), 2)
* Math.Max(osuCurrent.JumpDistance - scale, 0));
result = 1.4 * applyDiminishingExp(Math.Max(0, angleBonus)) / Math.Max(timing_threshold, osuPrevious.StrainTime);
aimStrain = 1.4 * applyDiminishingExp(Math.Max(0, angleBonus)) / Math.Max(timing_threshold, osuPrevious.StrainTime);
}
}
@ -54,11 +56,27 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
double travelDistanceExp = applyDiminishingExp(osuCurrent.TravelDistance);
return Math.Max(
result + (jumpDistanceExp + travelDistanceExp + Math.Sqrt(travelDistanceExp * jumpDistanceExp)) / Math.Max(osuCurrent.StrainTime, timing_threshold),
aimStrain + (jumpDistanceExp + travelDistanceExp + Math.Sqrt(travelDistanceExp * jumpDistanceExp)) / Math.Max(osuCurrent.StrainTime, timing_threshold),
(Math.Sqrt(travelDistanceExp * jumpDistanceExp) + jumpDistanceExp + travelDistanceExp) / osuCurrent.StrainTime
);
}
private double applyDiminishingExp(double val) => Math.Pow(val, 0.99);
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
protected override double CalculateInitialStrain(double time) => currentStrain * strainDecay(time - Previous[0].StartTime);
protected override double StrainValueAt(DifficultyHitObject current)
{
double aimStrain = aimStrainOf(current);
currentStrain *= strainDecay(current.DeltaTime);
currentStrain += aimStrain * skillMultiplier;
// Console.WriteLine(currentStrain);
return currentStrain;
}
}
}

View File

@ -10,7 +10,7 @@ using osu.Framework.Utils;
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
public abstract class OsuStrainSkill : StrainDecaySkill
public abstract class OsuStrainSkill : StrainSkill
{
/// <summary>
/// The number of sections with the highest strains, which the peak strain reductions will apply to.

View File

@ -20,24 +20,121 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
private const double pi_over_4 = Math.PI / 4;
private const double pi_over_2 = Math.PI / 2;
protected override double SkillMultiplier => 1400;
protected override double StrainDecayBase => 0.3;
private const double rhythmMultiplier = 1.5;
private double skillMultiplier => 1400;
private double strainDecayBase => 0.3;
private double difficultyMultiplier => 1.04;
private double currentTapStrain = 1;
private double currentMovementStrain = 1;
protected override int ReducedSectionCount => 5;
protected override double DifficultyMultiplier => 1.04;
private const double min_speed_bonus = 75; // ~200BPM
private const double max_speed_bonus = 45; // ~330BPM
private const double speed_balancing_factor = 40;
protected override int HistoryLength => 32;
private const int HistoryTimeMax = 3000; // 4 seconds of calculatingRhythmBonus max.
public Speed(Mod[] mods)
: base(mods)
{
}
protected override double StrainValueOf(DifficultyHitObject current)
private bool isRatioEqual(double ratio, double a, double b)
{
if (current.BaseObject is Spinner)
return 0;
return a + 15 > ratio * b && a - 15 < ratio * b;
}
/// <summary>
/// Calculates a rhythm multiplier for the difficulty of the tap associated with historic data of the current <see cref="OsuDifficultyHitObject"/>.
/// </summary>
private double calculateRhythmBonus(double startTime)
{
// {doubles, triplets, quads, quints, 6-tuplets, 7 Tuplets, greater}
int previousIslandSize = -1;
double[] islandTimes = {0, 0, 0, 0, 0, 0, 0};
int islandSize = 0;
bool firstDeltaSwitch = false;
for (int i = Previous.Count - 1; i > 0; i--)
{
double currDelta = ((OsuDifficultyHitObject)Previous[i - 1]).StrainTime;
double prevDelta = ((OsuDifficultyHitObject)Previous[i]).StrainTime;
double effectiveRatio = Math.Min(prevDelta, currDelta) / Math.Max(prevDelta, currDelta);
effectiveRatio *= Math.Sqrt(100 / ((currDelta + prevDelta) / 2)); // scale with bpm.
if (effectiveRatio > 0.5)
effectiveRatio = 0.5 + (effectiveRatio - 0.5) * 5; // extra buff for 1/3 -> 1/4 etc transitions.
double currHistoricalDecay = Math.Max(0, (HistoryTimeMax - (startTime - Previous[i - 1].StartTime))) / HistoryTimeMax;
if (firstDeltaSwitch)
{
if (isRatioEqual(1.0, prevDelta, currDelta))
{
islandSize++; // island is still progressing, count size.
}
else
{
if (islandSize > 6)
islandSize = 6;
if (Previous[i - 1].BaseObject is Slider) // bpm change is into slider, this is easy acc window
effectiveRatio *= 0.5;
if (Previous[i].BaseObject is Slider) // bpm change was from a slider, this is easier typically than circle -> circle
effectiveRatio *= 0.75;
if (previousIslandSize == islandSize) // repeated island size (ex: triplet -> triplet)
effectiveRatio *= 0.5;
islandTimes[islandSize] = islandTimes[islandSize] + effectiveRatio * currHistoricalDecay;
previousIslandSize = islandSize; // log the last island size.
if (prevDelta * 1.25 < currDelta) // we're slowing down, stop counting
firstDeltaSwitch = false; // if we're speeding up, this stays true and we keep counting island size.
islandSize = 0;
}
}
else if (prevDelta > 1.25 * currDelta) // we want to be speeding up.
{
// Begin counting island until we change speed again.
firstDeltaSwitch = true;
islandSize = 0;
}
}
double rhythmComplexitySum = 0.0;
for (int i = 0; i < islandTimes.Length; i++)
{
rhythmComplexitySum += islandTimes[i]; // sum the total amount of rhythm variance
}
// Console.WriteLine(Math.Sqrt(4 + rhythmComplexitySum * rhythmMultiplier) / 2);
return Math.Sqrt(4 + rhythmComplexitySum * rhythmMultiplier) / 2;
}
private void setStrainValues(DifficultyHitObject current)
{
// if (current.BaseObject is Spinner)
// {
// currentTapStrain *= strainDecay(current.DeltaTime);
//
// currentMovementStrain *= strainDecay(current.DeltaTime);
//
// return;
// }
var osuCurrent = (OsuDifficultyHitObject)current;
@ -64,7 +161,29 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
}
}
return (1 + (speedBonus - 1) * 0.75) * angleBonus * (0.95 + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / osuCurrent.StrainTime;
// return (1 + (speedBonus - 1) * 0.75) * angleBonus * (0.95 + speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / osuCurrent.StrainTime;
double tapStrain = ((1 + (speedBonus - 1) * 0.75) * 0.95) / osuCurrent.StrainTime;
double movementStrain = ((1 + (speedBonus - 1) * 0.75) * angleBonus * speedBonus * Math.Pow(distance / single_spacing_threshold, 3.5)) / osuCurrent.StrainTime;
currentTapStrain *= strainDecay(current.DeltaTime);
currentTapStrain += tapStrain * skillMultiplier;
currentMovementStrain *= strainDecay(current.DeltaTime);
currentMovementStrain += movementStrain * skillMultiplier;
}
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
protected override double CalculateInitialStrain(double time) => (currentMovementStrain + currentTapStrain) * strainDecay(time - Previous[0].StartTime);
protected override double StrainValueAt(DifficultyHitObject current)
{
setStrainValues(current);
// Console.WriteLine(currentMovementStrain + currentTapStrain);
return currentMovementStrain + currentTapStrain * calculateRhythmBonus(current.StartTime);
}
}
}