mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Slightly optimise and de-branch rhythm pattern recognition
This commit is contained in:
parent
d7ff3d77eb
commit
ce0e5cf9a1
@ -38,28 +38,29 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
{
|
||||
for (int start = rhythmHistory.Count - l - 1; start >= 0; start--)
|
||||
{
|
||||
bool samePattern = true;
|
||||
if (!samePattern(start, l))
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
if (rhythmHistory[start + i].Rhythm != rhythmHistory[rhythmHistory.Count - l + i].Rhythm)
|
||||
{
|
||||
samePattern = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (samePattern) // Repetition found!
|
||||
{
|
||||
int notesSince = hitobject.ObjectIndex - rhythmHistory[start].ObjectIndex;
|
||||
penalty *= repetitionPenalty(notesSince);
|
||||
break;
|
||||
}
|
||||
int notesSince = hitobject.ObjectIndex - rhythmHistory[start].ObjectIndex;
|
||||
penalty *= repetitionPenalty(notesSince);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return penalty;
|
||||
}
|
||||
|
||||
private bool samePattern(int start, int l)
|
||||
{
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
if (rhythmHistory[start + i].Rhythm != rhythmHistory[rhythmHistory.Count - l + i].Rhythm)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private double patternLengthPenalty(int patternLength)
|
||||
{
|
||||
double shortPatternPenalty = Math.Min(0.15 * patternLength, 1.0);
|
||||
|
Loading…
Reference in New Issue
Block a user