1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:02:54 +08:00

Share sigmoid, Fix Preprocessor XML

This commit is contained in:
Jay L 2022-07-21 10:52:41 +10:00
parent 08dd9c79db
commit b7567f7db2
2 changed files with 13 additions and 24 deletions

View File

@ -25,21 +25,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
} }
/// <summary> /// <summary>
/// Evaluate the difficulty of the first note of a <see cref="MonoEncoding"/>. /// Evaluate the difficulty of the first note of a <see cref="MonoEncoding"/> or a <see cref="ColourEncoding"/>.
/// <param name="encoding">The encoding to evaluate.</param> /// <param name="i">The index of either encoding within it's respective parent.</param>
/// <param name="i">The index of the mono encoding within it's parent <see cref="ColourEncoding"/>.</param>
/// </summary> /// </summary>
public static double EvaluateDifficultyOf(MonoEncoding encoding, int i) public static double EvaluateDifficultyOf(int i)
{
return Sigmoid(i, 2, 2, 0.5, 1);
}
/// <summary>
/// Evaluate the difficulty of the first note of a <see cref="ColourEncoding"/>.
/// </summary>
/// <param name="encoding">The encoding to evaluate.</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)
{ {
return Sigmoid(i, 2, 2, 0.5, 1); return Sigmoid(i, 2, 2, 0.5, 1);
} }
@ -65,13 +54,13 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
for (int i = 0; i < encoding.Payload.Count; i++) for (int i = 0; i < encoding.Payload.Count; i++)
{ {
ColourEncoding colourEncoding = encoding.Payload[i]; ColourEncoding colourEncoding = encoding.Payload[i];
double colourEncodingDifficulty = EvaluateDifficultyOf(colourEncoding, i) * coupledEncodingDifficulty; double colourEncodingDifficulty = EvaluateDifficultyOf(i) * coupledEncodingDifficulty;
colourEncoding.Payload[0].EncodedData[0].Colour!.EvaluatedDifficulty += colourEncodingDifficulty; colourEncoding.Payload[0].EncodedData[0].Colour!.EvaluatedDifficulty += colourEncodingDifficulty;
for (int j = 0; j < colourEncoding.Payload.Count; j++) for (int j = 0; j < colourEncoding.Payload.Count; j++)
{ {
MonoEncoding monoEncoding = colourEncoding.Payload[j]; MonoEncoding monoEncoding = colourEncoding.Payload[j];
monoEncoding.EncodedData[0].Colour!.EvaluatedDifficulty += EvaluateDifficultyOf(monoEncoding, j) * colourEncodingDifficulty * 0.5; monoEncoding.EncodedData[0].Colour!.EvaluatedDifficulty += EvaluateDifficultyOf(j) * colourEncodingDifficulty * 0.5;
} }
} }
} }

View File

@ -16,9 +16,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
public class TaikoColourDifficultyPreprocessor public class TaikoColourDifficultyPreprocessor
{ {
/// <summary> /// <summary>
/// Process and encode a list of <see cref="TaikoDifficultyHitObject"/>s into a list of <see cref="TaikoDifficultyHitObjectColour"/>s, /// Processes and encodes a list of <see cref="TaikoDifficultyHitObject"/>s into a list of <see cref="TaikoDifficultyHitObjectColour"/>s,
/// assign the appropriate <see cref="TaikoDifficultyHitObjectColour"/>s to each <see cref="TaikoDifficultyHitObject"/>, /// assigning the appropriate <see cref="TaikoDifficultyHitObjectColour"/>s to each <see cref="TaikoDifficultyHitObject"/>,
/// and preevaluate colour difficulty of each <see cref="TaikoDifficultyHitObject"/>. /// and pre-evaluating colour difficulty of each <see cref="TaikoDifficultyHitObject"/>.
/// </summary> /// </summary>
public static List<TaikoDifficultyHitObjectColour> ProcessAndAssign(List<DifficultyHitObject> hitObjects) public static List<TaikoDifficultyHitObjectColour> ProcessAndAssign(List<DifficultyHitObject> hitObjects)
{ {
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
}); });
}); });
// Preevaluate and assign difficulty values // Pre-evaluate and assign difficulty values
ColourEvaluator.PreEvaluateDifficulties(coupledEncoding); ColourEvaluator.PreEvaluateDifficulties(coupledEncoding);
}); });
@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
// This ignores all non-note objects, which may or may not be the desired behaviour // This ignores all non-note objects, which may or may not be the desired behaviour
TaikoDifficultyHitObject? previousObject = taikoObject.PreviousNote(0); TaikoDifficultyHitObject? previousObject = taikoObject.PreviousNote(0);
// If the colour changed, or if this is the first object in the run, create a new mono encoding // If the colour changed or if this is the first object in the run, create a new mono encoding
if if
( (
previousObject == null || // First object in the list previousObject == null || // First object in the list
@ -75,8 +75,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
continue; continue;
} }
// If we're here, we're in the same encoding as the previous object, thus lastEncoded is not null. Add // If we're here, we're in the same encoding as the previous object, thus lastEncoded is not null.
// the current object to the encoded payload. // Add the current object to the encoded payload.
lastEncoded!.EncodedData.Add(taikoObject); lastEncoded!.EncodedData.Add(taikoObject);
} }
@ -159,7 +159,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
isCoupled = i < data.Count - 2 && data[i].IsRepetitionOf(data[i + 2]); isCoupled = i < data.Count - 2 && data[i].IsRepetitionOf(data[i + 2]);
} }
// Skip over peeked data and add the rest to the payload // Skip over viewed data and add the rest to the payload
lastEncoded.Payload.Add(data[i]); lastEncoded.Payload.Add(data[i]);
lastEncoded.Payload.Add(data[i + 1]); lastEncoded.Payload.Add(data[i + 1]);
i++; i++;