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

Partial Review changes

This commit is contained in:
Jay L 2022-07-20 23:33:38 +10:00
parent 9e299bb88b
commit cb63ec282e
5 changed files with 21 additions and 18 deletions

View File

@ -10,14 +10,18 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
{ {
public class ColourEvaluator public class ColourEvaluator
{ {
private static double sigmoid(double val, double center, double width) /// <summary>
/// A sigmoid function. It gives a value between (middle - height/2) and (middle + height/2).
/// </summary>
/// <param name="val">The input value.</param>
/// <param name="center">The center of the sigmoid, where the largest gradient occurs and value is equal to middle.</param>
/// <param name="width">The radius of the sigmoid, outside of which values are near the minimum/maximum.</param>
/// <param name="middle">The middle of the sigmoid output.</param>
/// <param name="height">The height of the sigmoid output. This will be equal to max value - min value.</param>
public static double Sigmoid(double val, double center, double width, double middle, double height)
{ {
return Math.Tanh(Math.E * -(val - center) / width); double sigmoid = Math.Tanh(Math.E * -(val - center) / width);
} return sigmoid * (height / 2) + middle;
private static double sigmoid(double val, double center, double width, double middle, double height)
{
return sigmoid(val, center, width) * (height / 2) + middle;
} }
/// <summary> /// <summary>
@ -27,7 +31,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
/// </summary> /// </summary>
public static double EvaluateDifficultyOf(MonoEncoding encoding, int i) public static double EvaluateDifficultyOf(MonoEncoding encoding, int i)
{ {
return sigmoid(i, 2, 2, 0.5, 1); return Sigmoid(i, 2, 2, 0.5, 1);
} }
/// <summary> /// <summary>
@ -37,7 +41,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
/// <param name="i">The index of the colour encoding within it's parent <see cref="CoupledColourEncoding"/>.</param> /// <param name="i">The index of the colour encoding within it's parent <see cref="CoupledColourEncoding"/>.</param>
public static double EvaluateDifficultyOf(ColourEncoding encoding, int i) public static double EvaluateDifficultyOf(ColourEncoding encoding, int i)
{ {
return sigmoid(i, 2, 2, 0.5, 1); return Sigmoid(i, 2, 2, 0.5, 1);
} }
/// <summary> /// <summary>
@ -45,7 +49,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
/// </summary> /// </summary>
public static double EvaluateDifficultyOf(CoupledColourEncoding encoding) public static double EvaluateDifficultyOf(CoupledColourEncoding encoding)
{ {
return 1 - sigmoid(encoding.RepetitionInterval, 2, 2, 0.5, 1); return 1 - Sigmoid(encoding.RepetitionInterval, 2, 2, 0.5, 1);
} }
/// <summary> /// <summary>

View File

@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
/// <summary> /// <summary>
/// Evaluates the minimum mechanical stamina required to play the current object. This is calculated using the /// 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. /// maximum possible interval between two hits using the same key, by alternating 2 keys for each colour.
/// </summary> /// </summary>
public static double EvaluateDifficultyOf(DifficultyHitObject current) public static double EvaluateDifficultyOf(DifficultyHitObject current)
{ {

View File

@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
public int RepetitionInterval { get; private set; } = max_repetition_interval + 1; public int RepetitionInterval { get; private set; } = max_repetition_interval + 1;
/// <summary> /// <summary>
/// Returns true if other is considered a repetition of this encoding. This is true if other's first two payload /// Returns true if other is considered a repetition of this encoding. This is true if other's first two payloads
/// identical mono lengths. /// have identical mono lengths.
/// </summary> /// </summary>
private bool isRepetitionOf(CoupledColourEncoding other) private bool isRepetitionOf(CoupledColourEncoding other)
{ {

View File

@ -16,7 +16,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
/// <summary> /// <summary>
/// List of <see cref="DifficultyHitObject"/>s that are encoded within this <see cref="MonoEncoding"/>. /// List of <see cref="DifficultyHitObject"/>s that are encoded within this <see cref="MonoEncoding"/>.
/// This is not declared as <see cref="TaikoDifficultyHitObject"/> to avoid circular dependencies. /// This is not declared as <see cref="TaikoDifficultyHitObject"/> to avoid circular dependencies.
/// TODO: Review this, are circular dependencies within data-only classes are acceptable?
/// </summary> /// </summary>
public List<TaikoDifficultyHitObject> EncodedData { get; private set; } = new List<TaikoDifficultyHitObject>(); public List<TaikoDifficultyHitObject> EncodedData { get; private set; } = new List<TaikoDifficultyHitObject>();

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
{ {
private readonly IReadOnlyList<TaikoDifficultyHitObject>? monoDifficultyHitObjects; private readonly IReadOnlyList<TaikoDifficultyHitObject>? monoDifficultyHitObjects;
public readonly int MonoIndex; public readonly int MonoIndex;
private readonly IReadOnlyList<TaikoDifficultyHitObject> noteObjects; private readonly IReadOnlyList<TaikoDifficultyHitObject> noteDifficultyHitObjects;
public readonly int NoteIndex; public readonly int NoteIndex;
/// <summary> /// <summary>
@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
: base(hitObject, lastObject, clockRate, objects, index) : base(hitObject, lastObject, clockRate, objects, index)
{ {
var currentHit = hitObject as Hit; var currentHit = hitObject as Hit;
this.noteObjects = noteObjects; noteDifficultyHitObjects = noteObjects;
Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate); Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate);
HitType? hitType = currentHit?.Type; HitType? hitType = currentHit?.Type;
@ -120,8 +120,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
public TaikoDifficultyHitObject? NextMono(int forwardsIndex) => monoDifficultyHitObjects?.ElementAtOrDefault(MonoIndex + (forwardsIndex + 1)); public TaikoDifficultyHitObject? NextMono(int forwardsIndex) => monoDifficultyHitObjects?.ElementAtOrDefault(MonoIndex + (forwardsIndex + 1));
public TaikoDifficultyHitObject? PreviousNote(int backwardsIndex) => noteObjects.ElementAtOrDefault(NoteIndex - (backwardsIndex + 1)); public TaikoDifficultyHitObject? PreviousNote(int backwardsIndex) => noteDifficultyHitObjects.ElementAtOrDefault(NoteIndex - (backwardsIndex + 1));
public TaikoDifficultyHitObject? NextNote(int forwardsIndex) => noteObjects.ElementAtOrDefault(NoteIndex + (forwardsIndex + 1)); public TaikoDifficultyHitObject? NextNote(int forwardsIndex) => noteDifficultyHitObjects.ElementAtOrDefault(NoteIndex + (forwardsIndex + 1));
} }
} }