mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Slightly optimise and de-branch repetition pattern recognition
This commit is contained in:
parent
00ae456f08
commit
d7ff3d77eb
@ -87,28 +87,29 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
|
||||
for (int start = monoHistory.Count - l - 1; start >= 0; start--)
|
||||
{
|
||||
bool samePattern = true;
|
||||
if (!isSamePattern(start, l))
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
if (monoHistory[start + i] != monoHistory[monoHistory.Count - l + i])
|
||||
{
|
||||
samePattern = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (samePattern) // Repetition found!
|
||||
{
|
||||
int notesSince = 0;
|
||||
for (int i = start; i < monoHistory.Count; i++) notesSince += monoHistory[i];
|
||||
penalty *= repetitionPenalty(notesSince);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return penalty;
|
||||
}
|
||||
|
||||
private bool isSamePattern(int start, int l)
|
||||
{
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
if (monoHistory[start + i] != monoHistory[monoHistory.Count - l + i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private double repetitionPenalty(int notesSince) => Math.Min(1.0, 0.032 * notesSince);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user