mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:03:11 +08: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--)
|
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;
|
int notesSince = hitobject.ObjectIndex - rhythmHistory[start].ObjectIndex;
|
||||||
penalty *= repetitionPenalty(notesSince);
|
penalty *= repetitionPenalty(notesSince);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return penalty;
|
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)
|
private double patternLengthPenalty(int patternLength)
|
||||||
{
|
{
|
||||||
double shortPatternPenalty = Math.Min(0.15 * patternLength, 1.0);
|
double shortPatternPenalty = Math.Min(0.15 * patternLength, 1.0);
|
||||||
|
Loading…
Reference in New Issue
Block a user