// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing; using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour; using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data; namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators { public class ColourEvaluator { /// /// A sigmoid function. It gives a value between (middle - height/2) and (middle + height/2). /// /// The input value. /// The center of the sigmoid, where the largest gradient occurs and value is equal to middle. /// The radius of the sigmoid, outside of which values are near the minimum/maximum. /// The middle of the sigmoid output. /// The height of the sigmoid output. This will be equal to max value - min value. public static double Sigmoid(double val, double center, double width, double middle, double height) { double sigmoid = Math.Tanh(Math.E * -(val - center) / width); return sigmoid * (height / 2) + middle; } /// /// Evaluate the difficulty of the first note of a . /// The encoding to evaluate. /// The index of the mono encoding within it's parent . /// public static double EvaluateDifficultyOf(MonoEncoding encoding, int i) { return Sigmoid(i, 2, 2, 0.5, 1); } /// /// Evaluate the difficulty of the first note of a . /// /// The encoding to evaluate. /// The index of the colour encoding within it's parent . public static double EvaluateDifficultyOf(ColourEncoding encoding, int i) { return Sigmoid(i, 2, 2, 0.5, 1); } /// /// Evaluate the difficulty of the first note of a . /// public static double EvaluateDifficultyOf(CoupledColourEncoding encoding) { return 1 - Sigmoid(encoding.RepetitionInterval, 2, 2, 0.5, 1); } /// /// Pre-evaluate and *assign* difficulty values of all hit objects encoded in a . /// Difficulty values are assigned to of each /// encoded within. /// public static void PreEvaluateDifficulties(CoupledColourEncoding encoding) { double coupledEncodingDifficulty = 2 * EvaluateDifficultyOf(encoding); encoding.Payload[0].Payload[0].EncodedData[0].Colour!.EvaluatedDifficulty += coupledEncodingDifficulty; for (int i = 0; i < encoding.Payload.Count; i++) { ColourEncoding colourEncoding = encoding.Payload[i]; double colourEncodingDifficulty = EvaluateDifficultyOf(colourEncoding, i) * coupledEncodingDifficulty; colourEncoding.Payload[0].EncodedData[0].Colour!.EvaluatedDifficulty += colourEncodingDifficulty; for (int j = 0; j < colourEncoding.Payload.Count; j++) { MonoEncoding monoEncoding = colourEncoding.Payload[j]; monoEncoding.EncodedData[0].Colour!.EvaluatedDifficulty += EvaluateDifficultyOf(monoEncoding, j) * colourEncodingDifficulty * 0.5; } } } } }