2022-07-15 19:07:01 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-06 12:42:49 +08:00
|
|
|
using System;
|
2022-07-21 19:15:22 +08:00
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
2022-06-06 12:42:49 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
2022-07-05 14:41:40 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour;
|
2022-07-15 19:07:01 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data;
|
2022-06-06 12:42:49 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
|
|
|
|
{
|
|
|
|
public class ColourEvaluator
|
|
|
|
{
|
2022-07-20 21:33:38 +08:00
|
|
|
/// <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>
|
2022-07-21 19:15:22 +08:00
|
|
|
private static double sigmoid(double val, double center, double width, double middle, double height)
|
2022-07-01 14:27:23 +08:00
|
|
|
{
|
2022-07-20 21:33:38 +08:00
|
|
|
double sigmoid = Math.Tanh(Math.E * -(val - center) / width);
|
|
|
|
return sigmoid * (height / 2) + middle;
|
2022-07-01 14:27:23 +08:00
|
|
|
}
|
|
|
|
|
2022-07-05 14:41:40 +08:00
|
|
|
/// <summary>
|
2022-08-19 15:31:03 +08:00
|
|
|
/// Evaluate the difficulty of the first note of a <see cref="MonoStreak"/>.
|
2022-07-05 14:41:40 +08:00
|
|
|
/// </summary>
|
2022-08-19 15:45:43 +08:00
|
|
|
public static double EvaluateDifficultyOf(MonoStreak monoStreak)
|
2022-06-06 12:42:49 +08:00
|
|
|
{
|
2022-08-24 08:57:13 +08:00
|
|
|
return sigmoid(monoStreak.Index, 2, 2, 0.5, 1) * EvaluateDifficultyOf(monoStreak.Parent) * 0.5;
|
2022-07-05 14:41:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2022-08-19 15:31:03 +08:00
|
|
|
/// Evaluate the difficulty of the first note of a <see cref="AlternatingMonoPattern"/>.
|
2022-07-05 14:41:40 +08:00
|
|
|
/// </summary>
|
2022-08-19 15:45:43 +08:00
|
|
|
public static double EvaluateDifficultyOf(AlternatingMonoPattern alternatingMonoPattern)
|
2022-07-05 14:41:40 +08:00
|
|
|
{
|
2022-08-24 08:57:13 +08:00
|
|
|
return sigmoid(alternatingMonoPattern.Index, 2, 2, 0.5, 1) * EvaluateDifficultyOf(alternatingMonoPattern.Parent);
|
2022-07-05 14:41:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2022-08-19 15:31:03 +08:00
|
|
|
/// Evaluate the difficulty of the first note of a <see cref="RepeatingHitPatterns"/>.
|
2022-07-05 14:41:40 +08:00
|
|
|
/// </summary>
|
2022-08-19 15:45:43 +08:00
|
|
|
public static double EvaluateDifficultyOf(RepeatingHitPatterns repeatingHitPattern)
|
2022-07-21 19:15:22 +08:00
|
|
|
{
|
2022-08-19 15:45:43 +08:00
|
|
|
return 2 * (1 - sigmoid(repeatingHitPattern.RepetitionInterval, 2, 2, 0.5, 1));
|
2022-07-21 19:15:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static double EvaluateDifficultyOf(DifficultyHitObject hitObject)
|
2022-07-05 14:41:40 +08:00
|
|
|
{
|
2022-07-21 19:15:22 +08:00
|
|
|
TaikoDifficultyHitObjectColour colour = ((TaikoDifficultyHitObject)hitObject).Colour;
|
|
|
|
double difficulty = 0.0d;
|
2022-07-15 19:07:01 +08:00
|
|
|
|
2022-08-19 15:45:43 +08:00
|
|
|
if (colour.MonoStreak != null) // Difficulty for MonoStreak
|
|
|
|
difficulty += EvaluateDifficultyOf(colour.MonoStreak);
|
|
|
|
if (colour.AlternatingMonoPattern != null) // Difficulty for AlternatingMonoPattern
|
|
|
|
difficulty += EvaluateDifficultyOf(colour.AlternatingMonoPattern);
|
2022-08-19 16:13:36 +08:00
|
|
|
if (colour.RepeatingHitPattern != null) // Difficulty for RepeatingHitPattern
|
|
|
|
difficulty += EvaluateDifficultyOf(colour.RepeatingHitPattern);
|
2022-07-15 19:07:01 +08:00
|
|
|
|
2022-07-21 19:15:22 +08:00
|
|
|
return difficulty;
|
2022-06-06 12:42:49 +08:00
|
|
|
}
|
|
|
|
}
|
2022-06-09 17:22:55 +08:00
|
|
|
}
|