2020-05-11 05:50:02 +00: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-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-05-11 05:50:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Difficulty.Skills;
|
2020-08-18 17:13:18 +00:00
|
|
|
|
using osu.Game.Rulesets.Difficulty.Utils;
|
2021-02-06 04:06:16 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Calculates the colour coefficient of taiko difficulty.
|
|
|
|
|
/// </summary>
|
2021-08-16 22:14:29 +00:00
|
|
|
|
public class Colour : StrainDecaySkill
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
|
|
|
|
protected override double SkillMultiplier => 1;
|
2020-05-22 11:50:21 +00:00
|
|
|
|
protected override double StrainDecayBase => 0.4;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Maximum number of entries to keep in <see cref="monoHistory"/>.
|
|
|
|
|
/// </summary>
|
2020-08-22 15:51:35 +00:00
|
|
|
|
private const int mono_history_max_length = 5;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
2020-08-13 04:47:35 +00:00
|
|
|
|
/// <summary>
|
2020-08-22 17:34:16 +00:00
|
|
|
|
/// Queue with the lengths of the last <see cref="mono_history_max_length"/> most recent mono (single-colour) patterns,
|
|
|
|
|
/// with the most recent value at the end of the queue.
|
2020-08-13 04:47:35 +00:00
|
|
|
|
/// </summary>
|
2020-08-22 15:51:35 +00:00
|
|
|
|
private readonly LimitedCapacityQueue<int> monoHistory = new LimitedCapacityQueue<int>(mono_history_max_length);
|
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="HitType"/> of the last object hit before the one being considered.
|
|
|
|
|
/// </summary>
|
2020-08-22 15:51:35 +00:00
|
|
|
|
private HitType? previousHitType;
|
2020-08-13 04:47:35 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-08-22 15:51:35 +00:00
|
|
|
|
/// Length of the current mono pattern.
|
2020-08-13 04:47:35 +00:00
|
|
|
|
/// </summary>
|
2020-09-10 16:22:49 +00:00
|
|
|
|
private int currentMonoLength;
|
2020-05-11 05:53:42 +00:00
|
|
|
|
|
2021-02-06 04:06:16 +00:00
|
|
|
|
public Colour(Mod[] mods)
|
|
|
|
|
: base(mods)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-12 16:35:56 +00:00
|
|
|
|
protected override double StrainValueOf(DifficultyHitObject current)
|
2020-05-22 11:50:21 +00:00
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
|
// changing from/to a drum roll or a swell does not constitute a colour change.
|
|
|
|
|
// hits spaced more than a second apart are also exempt from colour strain.
|
2020-08-12 16:35:56 +00:00
|
|
|
|
if (!(current.LastObject is Hit && current.BaseObject is Hit && current.DeltaTime < 1000))
|
|
|
|
|
{
|
2020-09-10 17:21:16 +00:00
|
|
|
|
monoHistory.Clear();
|
|
|
|
|
|
|
|
|
|
var currentHit = current.BaseObject as Hit;
|
|
|
|
|
currentMonoLength = currentHit != null ? 1 : 0;
|
|
|
|
|
previousHitType = currentHit?.Type;
|
|
|
|
|
|
2020-08-12 16:35:56 +00:00
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var taikoCurrent = (TaikoDifficultyHitObject)current;
|
|
|
|
|
|
|
|
|
|
double objectStrain = 0.0;
|
|
|
|
|
|
2020-08-18 17:39:03 +00:00
|
|
|
|
if (previousHitType != null && taikoCurrent.HitType != previousHitType)
|
2020-08-12 16:35:56 +00:00
|
|
|
|
{
|
2020-08-13 04:47:35 +00:00
|
|
|
|
// The colour has changed.
|
2020-08-12 16:35:56 +00:00
|
|
|
|
objectStrain = 1.0;
|
|
|
|
|
|
|
|
|
|
if (monoHistory.Count < 2)
|
2020-08-13 04:47:35 +00:00
|
|
|
|
{
|
|
|
|
|
// There needs to be at least two streaks to determine a strain.
|
2020-08-12 16:35:56 +00:00
|
|
|
|
objectStrain = 0.0;
|
2020-08-13 04:47:35 +00:00
|
|
|
|
}
|
2020-08-12 16:35:56 +00:00
|
|
|
|
else if ((monoHistory[^1] + currentMonoLength) % 2 == 0)
|
2020-08-13 04:47:35 +00:00
|
|
|
|
{
|
|
|
|
|
// The last streak in the history is guaranteed to be a different type to the current streak.
|
2020-08-22 15:15:08 +00:00
|
|
|
|
// If the total number of notes in the two streaks is even, nullify this object's strain.
|
|
|
|
|
objectStrain = 0.0;
|
2020-08-13 04:47:35 +00:00
|
|
|
|
}
|
2020-08-12 16:35:56 +00:00
|
|
|
|
|
|
|
|
|
objectStrain *= repetitionPenalties();
|
|
|
|
|
currentMonoLength = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentMonoLength += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousHitType = taikoCurrent.HitType;
|
|
|
|
|
return objectStrain;
|
2020-05-22 11:50:21 +00:00
|
|
|
|
}
|
2020-05-11 05:53:42 +00:00
|
|
|
|
|
2020-08-13 04:47:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The penalty to apply due to the length of repetition in colour streaks.
|
|
|
|
|
/// </summary>
|
2020-06-08 07:30:26 +00:00
|
|
|
|
private double repetitionPenalties()
|
2020-05-11 05:50:02 +00:00
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
|
const int most_recent_patterns_to_compare = 2;
|
2020-06-08 07:30:26 +00:00
|
|
|
|
double penalty = 1.0;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
2020-08-18 17:13:18 +00:00
|
|
|
|
monoHistory.Enqueue(currentMonoLength);
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
|
for (int start = monoHistory.Count - most_recent_patterns_to_compare - 1; start >= 0; start--)
|
2020-06-08 07:30:26 +00:00
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
|
if (!isSamePattern(start, most_recent_patterns_to_compare))
|
2020-08-18 17:44:41 +00:00
|
|
|
|
continue;
|
2020-05-22 11:50:21 +00:00
|
|
|
|
|
2020-08-18 17:44:41 +00:00
|
|
|
|
int notesSince = 0;
|
|
|
|
|
for (int i = start; i < monoHistory.Count; i++) notesSince += monoHistory[i];
|
|
|
|
|
penalty *= repetitionPenalty(notesSince);
|
|
|
|
|
break;
|
2020-06-08 07:30:26 +00:00
|
|
|
|
}
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
2020-06-08 07:30:26 +00:00
|
|
|
|
return penalty;
|
|
|
|
|
}
|
2020-05-11 05:50:02 +00:00
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the last <paramref name="mostRecentPatternsToCompare"/> patterns have repeated in the history
|
|
|
|
|
/// of single-colour note sequences, starting from <paramref name="start"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool isSamePattern(int start, int mostRecentPatternsToCompare)
|
2020-08-18 17:44:41 +00:00
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
|
for (int i = 0; i < mostRecentPatternsToCompare; i++)
|
2020-08-18 17:44:41 +00:00
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
|
if (monoHistory[start + i] != monoHistory[monoHistory.Count - mostRecentPatternsToCompare + i])
|
2020-08-18 17:44:41 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Calculates the strain penalty for a colour pattern repetition.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="notesSince">The number of notes since the last repetition of the pattern.</param>
|
2020-08-13 04:47:35 +00:00
|
|
|
|
private double repetitionPenalty(int notesSince) => Math.Min(1.0, 0.032 * notesSince);
|
2020-05-11 05:50:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|