mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 17:02:55 +08:00
Merge pull request #4279 from smoogipoo/new-diffcalc-catch
Migrate catch to use the new difficulty calculator structure
This commit is contained in:
commit
fd442372ce
@ -13,11 +13,11 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
|
protected override string ResourceAssembly => "osu.Game.Rulesets.Catch";
|
||||||
|
|
||||||
[TestCase(3.8664391043534758, "diffcalc-test")]
|
[TestCase(3.8701854263563118d, "diffcalc-test")]
|
||||||
public void Test(double expected, string name)
|
public void Test(double expected, string name)
|
||||||
=> base.Test(expected, name);
|
=> base.Test(expected, name);
|
||||||
|
|
||||||
protected override LegacyDifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchLegacyDifficultyCalculator(new CatchRuleset(), beatmap);
|
protected override LegacyDifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchDifficultyCalculator(new CatchRuleset(), beatmap);
|
||||||
|
|
||||||
protected override Ruleset CreateRuleset() => new CatchRuleset();
|
protected override Ruleset CreateRuleset() => new CatchRuleset();
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
|
|
||||||
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_fruits_o };
|
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_fruits_o };
|
||||||
|
|
||||||
public override LegacyDifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchLegacyDifficultyCalculator(this, beatmap);
|
public override LegacyDifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new CatchDifficultyCalculator(this, beatmap);
|
||||||
|
|
||||||
public override int? LegacyID => 2;
|
public override int? LegacyID => 2;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Difficulty
|
namespace osu.Game.Rulesets.Catch.Difficulty
|
||||||
{
|
{
|
||||||
@ -10,10 +9,5 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
{
|
{
|
||||||
public double ApproachRate;
|
public double ApproachRate;
|
||||||
public int MaxCombo;
|
public int MaxCombo;
|
||||||
|
|
||||||
public CatchDifficultyAttributes(Mod[] mods, double starRating)
|
|
||||||
: base(mods, starRating)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
// 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 System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
|
||||||
|
using osu.Game.Rulesets.Catch.Difficulty.Skills;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
|
using osu.Game.Rulesets.Difficulty.Skills;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Difficulty
|
||||||
|
{
|
||||||
|
public class CatchDifficultyCalculator : DifficultyCalculator
|
||||||
|
{
|
||||||
|
private const double star_scaling_factor = 0.145;
|
||||||
|
|
||||||
|
protected override int SectionLength => 750;
|
||||||
|
|
||||||
|
private readonly float halfCatchWidth;
|
||||||
|
|
||||||
|
public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
|
: base(ruleset, beatmap)
|
||||||
|
{
|
||||||
|
var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty);
|
||||||
|
halfCatchWidth = catcher.CatchWidth * 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beatmap, Mod[] mods, Skill[] skills, double clockRate)
|
||||||
|
{
|
||||||
|
if (beatmap.HitObjects.Count == 0)
|
||||||
|
return new CatchDifficultyAttributes { Mods = mods };
|
||||||
|
|
||||||
|
// this is the same as osu!, so there's potential to share the implementation... maybe
|
||||||
|
double preempt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
||||||
|
|
||||||
|
return new CatchDifficultyAttributes
|
||||||
|
{
|
||||||
|
StarRating = Math.Sqrt(skills[0].DifficultyValue()) * star_scaling_factor,
|
||||||
|
Mods = mods,
|
||||||
|
ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0,
|
||||||
|
MaxCombo = beatmap.HitObjects.Count(h => h is Fruit) + beatmap.HitObjects.OfType<JuiceStream>().SelectMany(j => j.NestedHitObjects).Count(h => !(h is TinyDroplet))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
||||||
|
{
|
||||||
|
CatchHitObject lastObject = null;
|
||||||
|
|
||||||
|
foreach (var hitObject in beatmap.HitObjects.OfType<CatchHitObject>())
|
||||||
|
{
|
||||||
|
if (lastObject == null)
|
||||||
|
{
|
||||||
|
lastObject = hitObject;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
// We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations.
|
||||||
|
case Fruit fruit:
|
||||||
|
yield return new CatchDifficultyHitObject(fruit, lastObject, clockRate, halfCatchWidth);
|
||||||
|
lastObject = hitObject;
|
||||||
|
break;
|
||||||
|
case JuiceStream _:
|
||||||
|
foreach (var nested in hitObject.NestedHitObjects.OfType<CatchHitObject>().Where(o => !(o is TinyDroplet)))
|
||||||
|
{
|
||||||
|
yield return new CatchDifficultyHitObject(nested, lastObject, clockRate, halfCatchWidth);
|
||||||
|
lastObject = nested;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[]
|
||||||
|
{
|
||||||
|
new Movement(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,130 +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.Catch.Objects;
|
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Difficulty
|
|
||||||
{
|
|
||||||
public class CatchDifficultyHitObject
|
|
||||||
{
|
|
||||||
internal static readonly double DECAY_BASE = 0.20;
|
|
||||||
private const float normalized_hitobject_radius = 41.0f;
|
|
||||||
private const float absolute_player_positioning_error = 16f;
|
|
||||||
private readonly float playerPositioningError;
|
|
||||||
|
|
||||||
internal CatchHitObject BaseHitObject;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Measures jump difficulty. CtB doesn't have something like button pressing speed or accuracy
|
|
||||||
/// </summary>
|
|
||||||
internal double Strain = 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is required to keep track of lazy player movement (always moving only as far as necessary)
|
|
||||||
/// Without this quick repeat sliders / weirdly shaped streams might become ridiculously overrated
|
|
||||||
/// </summary>
|
|
||||||
internal float PlayerPositionOffset;
|
|
||||||
internal float LastMovement;
|
|
||||||
|
|
||||||
internal float NormalizedPosition;
|
|
||||||
internal float ActualNormalizedPosition => NormalizedPosition + PlayerPositionOffset;
|
|
||||||
|
|
||||||
internal CatchDifficultyHitObject(CatchHitObject baseHitObject, float catcherWidthHalf)
|
|
||||||
{
|
|
||||||
BaseHitObject = baseHitObject;
|
|
||||||
|
|
||||||
// We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps.
|
|
||||||
float scalingFactor = normalized_hitobject_radius / catcherWidthHalf;
|
|
||||||
|
|
||||||
playerPositioningError = absolute_player_positioning_error; // * scalingFactor;
|
|
||||||
NormalizedPosition = baseHitObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private const double direction_change_bonus = 12.5;
|
|
||||||
internal void CalculateStrains(CatchDifficultyHitObject previousHitObject, double timeRate)
|
|
||||||
{
|
|
||||||
// Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make.
|
|
||||||
// See Taiko feedback thread.
|
|
||||||
double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate;
|
|
||||||
double decay = Math.Pow(DECAY_BASE, timeElapsed / 1000);
|
|
||||||
|
|
||||||
// Update new position with lazy movement.
|
|
||||||
PlayerPositionOffset =
|
|
||||||
MathHelper.Clamp(
|
|
||||||
previousHitObject.ActualNormalizedPosition,
|
|
||||||
NormalizedPosition - (normalized_hitobject_radius - playerPositioningError),
|
|
||||||
NormalizedPosition + (normalized_hitobject_radius - playerPositioningError)) // Obtain new lazy position, but be stricter by allowing for an error of a certain degree of the player.
|
|
||||||
- NormalizedPosition; // Subtract HitObject position to obtain offset
|
|
||||||
|
|
||||||
LastMovement = DistanceTo(previousHitObject);
|
|
||||||
double addition = spacingWeight(LastMovement);
|
|
||||||
|
|
||||||
if (NormalizedPosition < previousHitObject.NormalizedPosition)
|
|
||||||
{
|
|
||||||
LastMovement = -LastMovement;
|
|
||||||
}
|
|
||||||
|
|
||||||
CatchHitObject previousHitCircle = previousHitObject.BaseHitObject;
|
|
||||||
|
|
||||||
double additionBonus = 0;
|
|
||||||
double sqrtTime = Math.Sqrt(Math.Max(timeElapsed, 25));
|
|
||||||
|
|
||||||
// Direction changes give an extra point!
|
|
||||||
if (Math.Abs(LastMovement) > 0.1)
|
|
||||||
{
|
|
||||||
if (Math.Abs(previousHitObject.LastMovement) > 0.1 && Math.Sign(LastMovement) != Math.Sign(previousHitObject.LastMovement))
|
|
||||||
{
|
|
||||||
double bonus = direction_change_bonus / sqrtTime;
|
|
||||||
|
|
||||||
// Weight bonus by how
|
|
||||||
double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError;
|
|
||||||
|
|
||||||
// We want time to play a role twice here!
|
|
||||||
addition += bonus * bonusFactor;
|
|
||||||
|
|
||||||
// Bonus for tougher direction switches and "almost" hyperdashes at this point
|
|
||||||
if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH)
|
|
||||||
{
|
|
||||||
additionBonus += 0.3 * bonusFactor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Base bonus for every movement, giving some weight to streams.
|
|
||||||
addition += 7.5 * Math.Min(Math.Abs(LastMovement), normalized_hitobject_radius * 2) / (normalized_hitobject_radius * 6) / sqrtTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bonus for "almost" hyperdashes at corner points
|
|
||||||
if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH)
|
|
||||||
{
|
|
||||||
if (!previousHitCircle.HyperDash)
|
|
||||||
{
|
|
||||||
additionBonus += 1.0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// After a hyperdash we ARE in the correct position. Always!
|
|
||||||
PlayerPositionOffset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
addition *= 1.0 + additionBonus * ((10 - previousHitCircle.DistanceToHyperDash * CatchPlayfield.BASE_WIDTH) / 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
addition *= 850.0 / Math.Max(timeElapsed, 25);
|
|
||||||
|
|
||||||
Strain = previousHitObject.Strain * decay + addition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double spacingWeight(float distance)
|
|
||||||
{
|
|
||||||
return Math.Pow(distance, 1.3) / 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal float DistanceTo(CatchDifficultyHitObject other)
|
|
||||||
{
|
|
||||||
return Math.Abs(ActualNormalizedPosition - other.ActualNormalizedPosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,148 +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 System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Difficulty
|
|
||||||
{
|
|
||||||
public class CatchLegacyDifficultyCalculator : LegacyDifficultyCalculator
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP.
|
|
||||||
/// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain.
|
|
||||||
/// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage.
|
|
||||||
/// </summary>
|
|
||||||
private const double strain_step = 750;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The weighting of each strain value decays to this number * it's previous value
|
|
||||||
/// </summary>
|
|
||||||
private const double decay_weight = 0.94;
|
|
||||||
|
|
||||||
private const double star_scaling_factor = 0.145;
|
|
||||||
|
|
||||||
public CatchLegacyDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
|
||||||
: base(ruleset, beatmap)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double clockRate)
|
|
||||||
{
|
|
||||||
if (!beatmap.HitObjects.Any())
|
|
||||||
return new CatchDifficultyAttributes(mods, 0);
|
|
||||||
|
|
||||||
var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty);
|
|
||||||
float halfCatchWidth = catcher.CatchWidth * 0.5f;
|
|
||||||
|
|
||||||
var difficultyHitObjects = new List<CatchDifficultyHitObject>();
|
|
||||||
|
|
||||||
foreach (var hitObject in beatmap.HitObjects)
|
|
||||||
{
|
|
||||||
switch (hitObject)
|
|
||||||
{
|
|
||||||
// We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations.
|
|
||||||
case Fruit fruit:
|
|
||||||
difficultyHitObjects.Add(new CatchDifficultyHitObject(fruit, halfCatchWidth));
|
|
||||||
break;
|
|
||||||
case JuiceStream _:
|
|
||||||
difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType<CatchHitObject>().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime));
|
|
||||||
|
|
||||||
if (!calculateStrainValues(difficultyHitObjects, clockRate))
|
|
||||||
return new CatchDifficultyAttributes(mods, 0);
|
|
||||||
|
|
||||||
// this is the same as osu!, so there's potential to share the implementation... maybe
|
|
||||||
double preempt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
|
||||||
double starRating = Math.Sqrt(calculateDifficulty(difficultyHitObjects, clockRate)) * star_scaling_factor;
|
|
||||||
|
|
||||||
return new CatchDifficultyAttributes(mods, starRating)
|
|
||||||
{
|
|
||||||
ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0,
|
|
||||||
MaxCombo = difficultyHitObjects.Count
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool calculateStrainValues(List<CatchDifficultyHitObject> objects, double timeRate)
|
|
||||||
{
|
|
||||||
CatchDifficultyHitObject lastObject = null;
|
|
||||||
|
|
||||||
if (!objects.Any()) return false;
|
|
||||||
|
|
||||||
// Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment.
|
|
||||||
foreach (var currentObject in objects)
|
|
||||||
{
|
|
||||||
if (lastObject != null)
|
|
||||||
currentObject.CalculateStrains(lastObject, timeRate);
|
|
||||||
|
|
||||||
lastObject = currentObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateDifficulty(List<CatchDifficultyHitObject> objects, double timeRate)
|
|
||||||
{
|
|
||||||
// The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods
|
|
||||||
double actualStrainStep = strain_step * timeRate;
|
|
||||||
|
|
||||||
// Find the highest strain value within each strain step
|
|
||||||
var highestStrains = new List<double>();
|
|
||||||
double intervalEndTime = actualStrainStep;
|
|
||||||
double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval
|
|
||||||
|
|
||||||
CatchDifficultyHitObject previousHitObject = null;
|
|
||||||
foreach (CatchDifficultyHitObject hitObject in objects)
|
|
||||||
{
|
|
||||||
// While we are beyond the current interval push the currently available maximum to our strain list
|
|
||||||
while (hitObject.BaseHitObject.StartTime > intervalEndTime)
|
|
||||||
{
|
|
||||||
highestStrains.Add(maximumStrain);
|
|
||||||
|
|
||||||
// The maximum strain of the next interval is not zero by default! We need to take the last hitObject we encountered, take its strain and apply the decay
|
|
||||||
// until the beginning of the next interval.
|
|
||||||
if (previousHitObject == null)
|
|
||||||
{
|
|
||||||
maximumStrain = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
double decay = Math.Pow(CatchDifficultyHitObject.DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000);
|
|
||||||
maximumStrain = previousHitObject.Strain * decay;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Go to the next time interval
|
|
||||||
intervalEndTime += actualStrainStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain maximum strain
|
|
||||||
maximumStrain = Math.Max(hitObject.Strain, maximumStrain);
|
|
||||||
|
|
||||||
previousHitObject = hitObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the weighted sum over the highest strains for each interval
|
|
||||||
double difficulty = 0;
|
|
||||||
double weight = 1;
|
|
||||||
highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain.
|
|
||||||
|
|
||||||
foreach (double strain in highestStrains)
|
|
||||||
{
|
|
||||||
difficulty += weight * strain;
|
|
||||||
weight *= decay_weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
return difficulty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,39 @@
|
|||||||
|
// 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.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Difficulty.Preprocessing
|
||||||
|
{
|
||||||
|
public class CatchDifficultyHitObject : DifficultyHitObject
|
||||||
|
{
|
||||||
|
private const float normalized_hitobject_radius = 41.0f;
|
||||||
|
|
||||||
|
public new CatchHitObject BaseObject => (CatchHitObject)base.BaseObject;
|
||||||
|
|
||||||
|
public new CatchHitObject LastObject => (CatchHitObject)base.LastObject;
|
||||||
|
|
||||||
|
public readonly float NormalizedPosition;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Milliseconds elapsed since the start time of the previous <see cref="CatchDifficultyHitObject"/>, with a minimum of 25ms.
|
||||||
|
/// </summary>
|
||||||
|
public readonly double StrainTime;
|
||||||
|
|
||||||
|
public CatchDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, float halfCatcherWidth)
|
||||||
|
: base(hitObject, lastObject, clockRate)
|
||||||
|
{
|
||||||
|
// We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps.
|
||||||
|
var scalingFactor = normalized_hitobject_radius / halfCatcherWidth;
|
||||||
|
|
||||||
|
NormalizedPosition = BaseObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor;
|
||||||
|
|
||||||
|
// Every strain interval is hard capped at the equivalent of 600 BPM streaming speed as a safety measure
|
||||||
|
StrainTime = Math.Max(25, DeltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
82
osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
Normal file
82
osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
// 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.Catch.Difficulty.Preprocessing;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
|
using osu.Game.Rulesets.Difficulty.Skills;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Difficulty.Skills
|
||||||
|
{
|
||||||
|
public class Movement : Skill
|
||||||
|
{
|
||||||
|
private const float absolute_player_positioning_error = 16f;
|
||||||
|
private const float normalized_hitobject_radius = 41.0f;
|
||||||
|
private const double direction_change_bonus = 12.5;
|
||||||
|
|
||||||
|
protected override double SkillMultiplier => 850;
|
||||||
|
protected override double StrainDecayBase => 0.2;
|
||||||
|
|
||||||
|
protected override double DecayWeight => 0.94;
|
||||||
|
|
||||||
|
private float lastPlayerPosition;
|
||||||
|
private float lastDistanceMoved;
|
||||||
|
|
||||||
|
protected override double StrainValueOf(DifficultyHitObject current)
|
||||||
|
{
|
||||||
|
var catchCurrent = (CatchDifficultyHitObject)current;
|
||||||
|
|
||||||
|
float playerPosition = MathHelper.Clamp(
|
||||||
|
lastPlayerPosition,
|
||||||
|
catchCurrent.NormalizedPosition - (normalized_hitobject_radius - absolute_player_positioning_error),
|
||||||
|
catchCurrent.NormalizedPosition + (normalized_hitobject_radius - absolute_player_positioning_error)
|
||||||
|
);
|
||||||
|
|
||||||
|
float distanceMoved = playerPosition - lastPlayerPosition;
|
||||||
|
|
||||||
|
double distanceAddition = Math.Pow(Math.Abs(distanceMoved), 1.3) / 500;
|
||||||
|
double sqrtStrain = Math.Sqrt(catchCurrent.StrainTime);
|
||||||
|
|
||||||
|
double bonus = 0;
|
||||||
|
|
||||||
|
// Direction changes give an extra point!
|
||||||
|
if (Math.Abs(distanceMoved) > 0.1)
|
||||||
|
{
|
||||||
|
if (Math.Abs(lastDistanceMoved) > 0.1 && Math.Sign(distanceMoved) != Math.Sign(lastDistanceMoved))
|
||||||
|
{
|
||||||
|
double bonusFactor = Math.Min(absolute_player_positioning_error, Math.Abs(distanceMoved)) / absolute_player_positioning_error;
|
||||||
|
|
||||||
|
distanceAddition += direction_change_bonus / sqrtStrain * bonusFactor;
|
||||||
|
|
||||||
|
// Bonus for tougher direction switches and "almost" hyperdashes at this point
|
||||||
|
if (catchCurrent.LastObject.DistanceToHyperDash <= 10 / CatchPlayfield.BASE_WIDTH)
|
||||||
|
bonus = 0.3 * bonusFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Base bonus for every movement, giving some weight to streams.
|
||||||
|
distanceAddition += 7.5 * Math.Min(Math.Abs(distanceMoved), normalized_hitobject_radius * 2) / (normalized_hitobject_radius * 6) / sqrtStrain;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bonus for "almost" hyperdashes at corner points
|
||||||
|
if (catchCurrent.LastObject.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH)
|
||||||
|
{
|
||||||
|
if (!catchCurrent.LastObject.HyperDash)
|
||||||
|
bonus += 1.0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// After a hyperdash we ARE in the correct position. Always!
|
||||||
|
playerPosition = catchCurrent.NormalizedPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
distanceAddition *= 1.0 + bonus * ((10 - catchCurrent.LastObject.DistanceToHyperDash * CatchPlayfield.BASE_WIDTH) / 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastPlayerPosition = playerPosition;
|
||||||
|
lastDistanceMoved = distanceMoved;
|
||||||
|
|
||||||
|
return distanceAddition / catchCurrent.StrainTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user