mirror of
https://github.com/ppy/osu
synced 2025-01-12 09:09:44 +00:00
Implement new colour encoding and evaluator
This commit is contained in:
parent
5f8d21f33d
commit
505a24a68e
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
|
||||
{
|
||||
@ -12,40 +13,70 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
|
||||
return Math.Tanh(Math.E * -(val - center) / width);
|
||||
}
|
||||
|
||||
public static double EvaluateDifficultyOf(ColourEncoding encoding)
|
||||
private static double sigmoid(double val, double center, double width, double middle, double height)
|
||||
{
|
||||
return 1 / Math.Pow(encoding.MonoRunLength, 0.5);
|
||||
return sigmoid(val, center, width) * (height / 2) + middle;
|
||||
}
|
||||
|
||||
public static double EvaluateDifficultyOf(CoupledColourEncoding coupledEncoding)
|
||||
/// <summary>
|
||||
/// Evaluate the difficulty of the first note of a <see cref="MonoEncoding"/>.
|
||||
/// <param name="encoding">The encoding to evaluate.</param>
|
||||
/// <param name="i">The index of the mono encoding within it's parent <see cref="ColourEncoding"/>.</param>
|
||||
/// </summary>
|
||||
public static double EvaluateDifficultyOf(MonoEncoding encoding, int i)
|
||||
{
|
||||
double difficulty = 0;
|
||||
for (int i = 0; i < coupledEncoding.Payload.Length; i++)
|
||||
return sigmoid(i, 2, 2, 0.5, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluate the difficulty of the first note of a <see cref="ColourEncoding"/>.
|
||||
/// </summary>
|
||||
/// <param name="encoding">The encoding to evaluate.</param>
|
||||
/// <param name="i">The index of the colour encoding within it's parent <see cref="CoupledColourEncoding"/>.</param>
|
||||
public static double EvaluateDifficultyOf(ColourEncoding encoding, int i)
|
||||
{
|
||||
return sigmoid(i, 2, 2, 0.5, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluate the difficulty of the first note of a <see cref="CoupledColourEncoding"/>.
|
||||
/// </summary>
|
||||
public static double EvaluateDifficultyOf(CoupledColourEncoding encoding)
|
||||
{
|
||||
return 1 - sigmoid(encoding.RepetitionInterval, 2, 2, 0.5, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pre-evaluate and *assign* difficulty values of all hit objects encoded in a <see cref="CoupledColourEncoding"/>.
|
||||
/// Difficulty values are assigned to <see cref="TaikoDifficultyHitObjectColour.EvaluatedDifficulty"/> of each
|
||||
/// <see cref="TaikoDifficultyHitObject"/> encoded within.
|
||||
/// </summary>
|
||||
public static void PreEvaluateDifficulties(CoupledColourEncoding encoding)
|
||||
{
|
||||
double coupledEncodingDifficulty = EvaluateDifficultyOf(encoding);
|
||||
encoding.Payload[0].Payload[0].EncodedData[0].Colour!.EvaluatedDifficulty += coupledEncodingDifficulty;
|
||||
for (int i = 0; i < encoding.Payload.Count; i++)
|
||||
{
|
||||
difficulty += EvaluateDifficultyOf(coupledEncoding.Payload[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;
|
||||
}
|
||||
}
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public static double EvaluateDifficultyOf(TaikoDifficultyHitObjectColour? colour)
|
||||
{
|
||||
if (colour == null) return 0;
|
||||
|
||||
// double difficulty = 9.5 * Math.Log(colour.Encoding.Payload.Length + 1, 10);
|
||||
double difficulty = 3 * EvaluateDifficultyOf(colour.Encoding);
|
||||
// foreach (ColourEncoding encoding in colour.Encoding.Payload)
|
||||
// {
|
||||
// difficulty += sigmoid(encoding.MonoRunLength, 1, 1) * 0.4 + 0.6;
|
||||
// }
|
||||
// difficulty *= -sigmoid(colour.RepetitionInterval, 1, 7);
|
||||
difficulty *= -sigmoid(colour.RepetitionInterval, 6, 5) * 0.5 + 0.5;
|
||||
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public static double EvaluateDifficultyOf(DifficultyHitObject current)
|
||||
{
|
||||
return EvaluateDifficultyOf(((TaikoDifficultyHitObject)current).Colour);
|
||||
TaikoDifficultyHitObject? taikoObject = current as TaikoDifficultyHitObject;
|
||||
if (taikoObject != null && taikoObject.Colour != null)
|
||||
{
|
||||
return taikoObject.Colour.EvaluatedDifficulty;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
{
|
||||
public class ColourEncoding
|
||||
{
|
||||
public List<MonoEncoding> Payload { get; private set; } = new List<MonoEncoding>();
|
||||
|
||||
public bool isIdenticalTo(ColourEncoding other)
|
||||
{
|
||||
return other.Payload[0].RunLength == Payload[0].RunLength &&
|
||||
other.Payload[0].EncodedData[0].HitType == Payload[0].EncodedData[0].HitType;
|
||||
}
|
||||
|
||||
public bool hasIdenticalMonoLength(ColourEncoding other)
|
||||
{
|
||||
return other.Payload[0].RunLength == Payload[0].RunLength;
|
||||
}
|
||||
|
||||
public static List<ColourEncoding> Encode(List<MonoEncoding> data)
|
||||
{
|
||||
// Compute encoding lengths
|
||||
List<ColourEncoding> encoded = new List<ColourEncoding>();
|
||||
ColourEncoding? lastEncoded = null;
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
if (i == 0 || lastEncoded == null || data[i].RunLength != data[i - 1].RunLength)
|
||||
{
|
||||
lastEncoded = new ColourEncoding();
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
encoded.Add(lastEncoded);
|
||||
continue;
|
||||
}
|
||||
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
{
|
||||
public class CoupledColourEncoding
|
||||
{
|
||||
private const int max_repetition_interval = 16;
|
||||
|
||||
public List<ColourEncoding> Payload = new List<ColourEncoding>();
|
||||
|
||||
public CoupledColourEncoding? Previous { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// How many notes between the current and previous identical <see cref="TaikoDifficultyHitObjectColour"/>.
|
||||
/// Negative number means that there is no repetition in range.
|
||||
/// If no repetition is found this will have a value of <see cref="max_repetition_interval"/> + 1.
|
||||
/// </summary>
|
||||
public int RepetitionInterval { get; private set; } = max_repetition_interval + 1;
|
||||
|
||||
public static List<CoupledColourEncoding> Encode(List<DifficultyHitObject> data)
|
||||
{
|
||||
List<MonoEncoding> firstPass = MonoEncoding.Encode(data);
|
||||
List<ColourEncoding> secondPass = ColourEncoding.Encode(firstPass);
|
||||
List<CoupledColourEncoding> thirdPass = CoupledColourEncoding.Encode(secondPass);
|
||||
|
||||
return thirdPass;
|
||||
}
|
||||
|
||||
public static List<CoupledColourEncoding> Encode(List<ColourEncoding> data)
|
||||
{
|
||||
List<CoupledColourEncoding> encoded = new List<CoupledColourEncoding>();
|
||||
|
||||
CoupledColourEncoding? lastEncoded = null;
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
lastEncoded = new CoupledColourEncoding()
|
||||
{
|
||||
Previous = lastEncoded
|
||||
};
|
||||
|
||||
bool isCoupled = i < data.Count - 2 && data[i].isIdenticalTo(data[i + 2]);
|
||||
if (!isCoupled)
|
||||
{
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (isCoupled)
|
||||
{
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
i++;
|
||||
|
||||
isCoupled = i < data.Count - 2 && data[i].isIdenticalTo(data[i + 2]);
|
||||
}
|
||||
|
||||
// Skip over peeked data and add the rest to the payload
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
lastEncoded.Payload.Add(data[i + 1]);
|
||||
i++;
|
||||
}
|
||||
|
||||
encoded.Add(lastEncoded);
|
||||
}
|
||||
|
||||
// Final pass to find repetition interval
|
||||
for (int i = 0; i < encoded.Count; i++)
|
||||
{
|
||||
encoded[i].FindRepetitionInterval();
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if other is considered a repetition of this encoding. This is true if other's first two payload
|
||||
/// identical mono lengths.
|
||||
/// </summary>
|
||||
public bool isRepetitionOf(CoupledColourEncoding other)
|
||||
{
|
||||
if (this.Payload.Count != other.Payload.Count) return false;
|
||||
|
||||
for (int i = 0; i < Math.Min(this.Payload.Count, 2); i++)
|
||||
{
|
||||
if (!this.Payload[i].hasIdenticalMonoLength(other.Payload[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the closest previous <see cref="TaikoDifficultyHitObjectColour"/> that has the identical <see cref="CoupledColourEncoding.Payload"/>.
|
||||
/// Interval is defined as the amount of <see cref="CoupledColourEncoding"/> chunks between the current and repeated encoding.
|
||||
/// </summary>
|
||||
public void FindRepetitionInterval()
|
||||
{
|
||||
if (Previous?.Previous == null)
|
||||
{
|
||||
RepetitionInterval = max_repetition_interval + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
CoupledColourEncoding? other = Previous.Previous;
|
||||
int interval = 2;
|
||||
while (interval < max_repetition_interval)
|
||||
{
|
||||
if (this.isRepetitionOf(other))
|
||||
{
|
||||
RepetitionInterval = Math.Min(interval, max_repetition_interval);
|
||||
return;
|
||||
}
|
||||
|
||||
other = other.Previous;
|
||||
if (other == null) break;
|
||||
++interval;
|
||||
}
|
||||
|
||||
RepetitionInterval = max_repetition_interval + 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
{
|
||||
public class MonoEncoding
|
||||
{
|
||||
public List<TaikoDifficultyHitObject> EncodedData { get; private set; } = new List<TaikoDifficultyHitObject>();
|
||||
|
||||
public int RunLength => EncodedData.Count;
|
||||
|
||||
public static List<MonoEncoding> Encode(List<DifficultyHitObject> data)
|
||||
{
|
||||
List<MonoEncoding> encoded = new List<MonoEncoding>();
|
||||
|
||||
MonoEncoding? lastEncoded = null;
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
TaikoDifficultyHitObject taikoObject = (TaikoDifficultyHitObject)data[i];
|
||||
// This ignores all non-note objects, which may or may not be the desired behaviour
|
||||
TaikoDifficultyHitObject previousObject = (TaikoDifficultyHitObject)taikoObject.PreviousNote(0);
|
||||
|
||||
if (
|
||||
previousObject == null ||
|
||||
lastEncoded == null ||
|
||||
taikoObject.HitType != previousObject.HitType)
|
||||
{
|
||||
lastEncoded = new MonoEncoding();
|
||||
lastEncoded.EncodedData.Add(taikoObject);
|
||||
encoded.Add(lastEncoded);
|
||||
continue;
|
||||
}
|
||||
|
||||
lastEncoded.EncodedData.Add(taikoObject);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Evaluators;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores colour compression information for a <see cref="TaikoDifficultyHitObject"/>. This is only present for the
|
||||
/// first <see cref="TaikoDifficultyHitObject"/> in a <see cref="CoupledColourEncoding"/> chunk.
|
||||
/// </summary>
|
||||
public class TaikoDifficultyHitObjectColour
|
||||
{
|
||||
public CoupledColourEncoding Encoding { get; private set; }
|
||||
|
||||
public double EvaluatedDifficulty = 0;
|
||||
|
||||
private TaikoDifficultyHitObjectColour(CoupledColourEncoding encoding)
|
||||
{
|
||||
Encoding = encoding;
|
||||
}
|
||||
|
||||
// TODO: Might wanna move this somewhere else as it is introducing circular references
|
||||
public static List<TaikoDifficultyHitObjectColour> EncodeAndAssign(List<DifficultyHitObject> hitObjects)
|
||||
{
|
||||
List<TaikoDifficultyHitObjectColour> colours = new List<TaikoDifficultyHitObjectColour>();
|
||||
List<CoupledColourEncoding> encodings = CoupledColourEncoding.Encode(hitObjects);
|
||||
|
||||
// Assign colour to objects
|
||||
encodings.ForEach(coupledEncoding =>
|
||||
{
|
||||
coupledEncoding.Payload.ForEach(encoding =>
|
||||
{
|
||||
encoding.Payload.ForEach(mono =>
|
||||
{
|
||||
mono.EncodedData.ForEach(hitObject =>
|
||||
{
|
||||
hitObject.Colour = new TaikoDifficultyHitObjectColour(coupledEncoding);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Preevaluate and assign difficulty values
|
||||
ColourEvaluator.PreEvaluateDifficulties(coupledEncoding);
|
||||
});
|
||||
|
||||
return colours;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
{
|
||||
public class ColourEncoding
|
||||
{
|
||||
/// <summary>
|
||||
/// Amount consecutive notes of the same colour
|
||||
/// </summary>
|
||||
public int MonoRunLength = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of consecutive encoding with the same <see cref="MonoRunLength" />
|
||||
/// </summary>
|
||||
public int EncodingRunLength = 1;
|
||||
|
||||
/// <summary>
|
||||
/// How many notes are encoded with this encoding
|
||||
/// </summary>
|
||||
public int NoteLength => MonoRunLength + EncodingRunLength;
|
||||
|
||||
/// <summary>
|
||||
/// Beginning index in the data that this encodes
|
||||
/// </summary>
|
||||
public int StartIndex = 0;
|
||||
|
||||
public bool isIdenticalTo(ColourEncoding other)
|
||||
{
|
||||
return other.MonoRunLength == MonoRunLength && other.EncodingRunLength == EncodingRunLength;
|
||||
}
|
||||
|
||||
public static List<ColourEncoding> Encode(List<DifficultyHitObject> data)
|
||||
{
|
||||
// Compute mono lengths
|
||||
List<ColourEncoding> firstPass = new List<ColourEncoding>();
|
||||
ColourEncoding? lastEncoded = null;
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
TaikoDifficultyHitObject taikoObject = (TaikoDifficultyHitObject)data[i];
|
||||
// This ignores all non-note objects, which may or may not be the desired behaviour
|
||||
TaikoDifficultyHitObject previousObject = (TaikoDifficultyHitObject)taikoObject.PreviousNote(0);
|
||||
|
||||
if (
|
||||
previousObject == null ||
|
||||
lastEncoded == null ||
|
||||
taikoObject.HitType != previousObject.HitType ||
|
||||
taikoObject.Rhythm.Ratio > 1.9) // Reset colour after a slow down of 2x (set as 1.9x for margin of error)
|
||||
{
|
||||
lastEncoded = new ColourEncoding();
|
||||
lastEncoded.StartIndex = i;
|
||||
firstPass.Add(lastEncoded);
|
||||
continue;
|
||||
}
|
||||
|
||||
lastEncoded.MonoRunLength += 1;
|
||||
}
|
||||
|
||||
// Compute encoding lengths
|
||||
List<ColourEncoding> secondPass = new List<ColourEncoding>();
|
||||
lastEncoded = null;
|
||||
for (int i = 0; i < firstPass.Count; i++)
|
||||
{
|
||||
if (i == 0 || lastEncoded == null || firstPass[i].MonoRunLength != firstPass[i - 1].MonoRunLength)
|
||||
{
|
||||
lastEncoded = firstPass[i];
|
||||
secondPass.Add(firstPass[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
lastEncoded.EncodingRunLength += 1;
|
||||
}
|
||||
|
||||
return secondPass;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
{
|
||||
public class CoupledColourEncoding
|
||||
{
|
||||
public int RunLength = 1;
|
||||
|
||||
public ColourEncoding[] Payload;
|
||||
|
||||
/// <summary>
|
||||
/// Beginning index in the data that this encodes
|
||||
/// </summary>
|
||||
public int StartIndex { get; private set; } = 0;
|
||||
|
||||
public int EndIndex { get; private set; } = 0;
|
||||
|
||||
private CoupledColourEncoding(ColourEncoding[] payload)
|
||||
{
|
||||
Payload = payload;
|
||||
}
|
||||
|
||||
public static List<CoupledColourEncoding> Encode(List<ColourEncoding> data)
|
||||
{
|
||||
List<CoupledColourEncoding> encoded = new List<CoupledColourEncoding>();
|
||||
|
||||
CoupledColourEncoding? lastEncoded = null;
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
if (lastEncoded != null) lastEncoded.EndIndex = data[i].StartIndex - 1;
|
||||
|
||||
if (i >= data.Count - 2 || !data[i].isIdenticalTo(data[i + 2]))
|
||||
{
|
||||
lastEncoded = new CoupledColourEncoding(new ColourEncoding[] { data[i] });
|
||||
lastEncoded.StartIndex = data[i].StartIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastEncoded = new CoupledColourEncoding(new ColourEncoding[] { data[i], data[i + 1] });
|
||||
lastEncoded.StartIndex = data[i].StartIndex;
|
||||
lastEncoded.RunLength = 3;
|
||||
i++;
|
||||
|
||||
// Peek 2 indices ahead
|
||||
while (i < data.Count - 2 && data[i].isIdenticalTo(data[i + 2]))
|
||||
{
|
||||
lastEncoded.RunLength += 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
// Skip over peeked data
|
||||
i++;
|
||||
}
|
||||
|
||||
encoded.Add(lastEncoded);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
public bool hasIdenticalPayload(CoupledColourEncoding other)
|
||||
{
|
||||
if (this.Payload.Length != other.Payload.Length) return false;
|
||||
|
||||
for (int i = 0; i < this.Payload.Length; i++)
|
||||
{
|
||||
if (!this.Payload[i].isIdenticalTo(other.Payload[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Evaluators;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
@ -63,7 +64,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
centreObjects, rimObjects, noteObjects, difficultyHitObjects.Count)
|
||||
);
|
||||
}
|
||||
TaikoDifficultyHitObjectColour.EncodeAndAssign(difficultyHitObjects);
|
||||
var encoded = TaikoDifficultyHitObjectColour.EncodeAndAssign(difficultyHitObjects);
|
||||
|
||||
return difficultyHitObjects;
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores colour compression information for a <see cref="TaikoDifficultyHitObject"/>. This is only present for the
|
||||
/// first <see cref="TaikoDifficultyHitObject"/> in a <see cref="CoupledColourEncoding"/> chunk.
|
||||
/// </summary>
|
||||
public class TaikoDifficultyHitObjectColour
|
||||
{
|
||||
private const int max_repetition_interval = 16;
|
||||
|
||||
/// <summary>
|
||||
/// How many notes between the current and previous identical <see cref="TaikoDifficultyHitObjectColour"/>.
|
||||
/// Negative number means that there is no repetition in range.
|
||||
/// If no repetition is found this will have a value of <see cref="max_repetition_interval"/> + 1.
|
||||
/// </summary>
|
||||
public int RepetitionInterval { get; private set; } = max_repetition_interval + 1;
|
||||
|
||||
/// <summary>
|
||||
/// Encoding information of <see cref="TaikoDifficultyHitObjectColour"/>.
|
||||
/// </summary>
|
||||
public CoupledColourEncoding Encoding { get; private set; }
|
||||
|
||||
public TaikoDifficultyHitObjectColour? Previous { get; private set; } = null;
|
||||
|
||||
public TaikoDifficultyHitObjectColour? repeatedColour { get; private set; } = null;
|
||||
|
||||
public TaikoDifficultyHitObjectColour(CoupledColourEncoding encoding)
|
||||
{
|
||||
Encoding = encoding;
|
||||
}
|
||||
|
||||
public static List<TaikoDifficultyHitObjectColour> EncodeAndAssign(List<DifficultyHitObject> hitObjects)
|
||||
{
|
||||
List<TaikoDifficultyHitObjectColour> colours = new List<TaikoDifficultyHitObjectColour>();
|
||||
List<CoupledColourEncoding> encodings = CoupledColourEncoding.Encode(ColourEncoding.Encode(hitObjects));
|
||||
TaikoDifficultyHitObjectColour? lastColour = null;
|
||||
for (int i = 0; i < encodings.Count; i++)
|
||||
{
|
||||
lastColour = new TaikoDifficultyHitObjectColour(encodings[i])
|
||||
{
|
||||
Previous = lastColour
|
||||
};
|
||||
colours.Add(lastColour);
|
||||
}
|
||||
|
||||
foreach (TaikoDifficultyHitObjectColour colour in colours)
|
||||
{
|
||||
colour.FindRepetitionInterval();
|
||||
((TaikoDifficultyHitObject)hitObjects[colour.Encoding.StartIndex]).Colour = colour;
|
||||
}
|
||||
|
||||
return colours;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the closest previous <see cref="TaikoDifficultyHitObjectColour"/> that has the identical <see cref="CoupledColourEncoding.Payload"/>.
|
||||
/// Interval is defined as the amount of <see cref="CoupledColourEncoding"/> chunks between the current and repeated encoding.
|
||||
/// </summary>
|
||||
public void FindRepetitionInterval()
|
||||
{
|
||||
if (Previous?.Previous == null)
|
||||
{
|
||||
RepetitionInterval = max_repetition_interval + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
TaikoDifficultyHitObjectColour? other = Previous.Previous;
|
||||
int interval = 2;
|
||||
while (interval < max_repetition_interval)
|
||||
{
|
||||
if (Encoding.hasIdenticalPayload(other.Encoding))
|
||||
{
|
||||
RepetitionInterval = Math.Min(interval, max_repetition_interval);
|
||||
repeatedColour = other;
|
||||
return;
|
||||
}
|
||||
|
||||
other = other.Previous;
|
||||
if (other == null) break;
|
||||
++interval;
|
||||
}
|
||||
|
||||
RepetitionInterval = max_repetition_interval + 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,10 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Difficulty.Skills;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour;
|
||||
using osu.Game.Rulesets.Taiko.Difficulty.Evaluators;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
@ -15,7 +17,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
/// </summary>
|
||||
public class Colour : StrainDecaySkill
|
||||
{
|
||||
protected override double SkillMultiplier => 1;
|
||||
protected override double SkillMultiplier => 0.7;
|
||||
protected override double StrainDecayBase => 0.4;
|
||||
|
||||
/// <summary>
|
||||
@ -38,6 +40,11 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public static String GetDebugHeaderLabels()
|
||||
{
|
||||
return "StartTime,Raw,Decayed,CoupledRunLength,RepetitionInterval,EncodingRunLength,Payload(MonoRunLength|MonoCount)";
|
||||
}
|
||||
|
||||
// TODO: Remove befor pr
|
||||
public string GetDebugString(DifficultyHitObject current)
|
||||
{
|
||||
@ -47,18 +54,18 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
TaikoDifficultyHitObjectColour? colour = taikoCurrent?.Colour;
|
||||
if (taikoCurrent != null && colour != null)
|
||||
{
|
||||
ColourEncoding[] payload = colour.Encoding.Payload;
|
||||
List<ColourEncoding> payload = colour.Encoding.Payload;
|
||||
string payloadDisplay = "";
|
||||
for (int i = 0; i < payload.Length; ++i)
|
||||
for (int i = 0; i < payload.Count; ++i)
|
||||
{
|
||||
payloadDisplay += $"({payload[i].MonoRunLength}|{payload[i].EncodingRunLength})";
|
||||
payloadDisplay += $"({payload[i].Payload[0].RunLength}|{payload[i].Payload.Count})";
|
||||
}
|
||||
|
||||
return $"{current.StartTime},{difficulty},{CurrentStrain},{colour.RepetitionInterval},{colour.Encoding.RunLength},{payloadDisplay}";
|
||||
return $"{current.StartTime},{difficulty},{CurrentStrain},{colour.Encoding.Payload[0].Payload.Count},{colour.Encoding.RepetitionInterval},{colour.Encoding.Payload.Count},{payloadDisplay}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{current.StartTime},{difficulty},{CurrentStrain},0,0,0";
|
||||
return $"{current.StartTime},{difficulty},{CurrentStrain},0,0,0,0,0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
||||
|
||||
if (debugColour)
|
||||
{
|
||||
String filename = $"{beatmap.BeatmapInfo.Metadata.Title}[{beatmap.BeatmapInfo.DifficultyName}].csv";
|
||||
String filename = $"{beatmap.BeatmapInfo.OnlineID} - {beatmap.BeatmapInfo.Metadata.Title}[{beatmap.BeatmapInfo.DifficultyName}].csv";
|
||||
filename = filename.Replace('/', '_');
|
||||
colourDebugOutput = new StreamWriter(File.OpenWrite($"/run/mount/secondary/workspace/osu/output/colour-debug/{filename}"));
|
||||
colourDebugOutput.WriteLine("StartTime,Raw,Decayed,RepetitionInterval,EncodingRunLength,Payload");
|
||||
colourDebugOutput.WriteLine(Colour.GetDebugHeaderLabels());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user