Add judge priority.
This commit is contained in:
@@ -16,19 +16,15 @@ namespace Cryville.Crtr {
|
|||||||
struct JudgeEvent {
|
struct JudgeEvent {
|
||||||
public float StartTime { get; set; }
|
public float StartTime { get; set; }
|
||||||
public float EndTime { get; set; }
|
public float EndTime { get; set; }
|
||||||
|
public float StartClip { get; set; }
|
||||||
|
public float EndClip { get; set; }
|
||||||
public JudgeDefinition Definition { get; set; }
|
public JudgeDefinition Definition { get; set; }
|
||||||
public ContainerState State { get; set; }
|
public ContainerState State { get; set; }
|
||||||
}
|
}
|
||||||
static readonly IComparer<JudgeEvent> _stcmp = new JudgeEventStartTimeComparer();
|
static readonly IComparer<JudgeEvent> _stcmp = new JudgeEventStartTimeComparer();
|
||||||
class JudgeEventStartTimeComparer : IComparer<JudgeEvent> {
|
class JudgeEventStartTimeComparer : IComparer<JudgeEvent> {
|
||||||
public int Compare(JudgeEvent x, JudgeEvent y) {
|
public int Compare(JudgeEvent x, JudgeEvent y) {
|
||||||
return x.StartTime.CompareTo(y.StartTime);
|
return x.StartClip.CompareTo(y.StartClip);
|
||||||
}
|
|
||||||
}
|
|
||||||
static readonly IComparer<JudgeEvent> _etcmp = new JudgeEventEndTimeComparer();
|
|
||||||
class JudgeEventEndTimeComparer : IComparer<JudgeEvent> {
|
|
||||||
public int Compare(JudgeEvent x, JudgeEvent y) {
|
|
||||||
return x.EndTime.CompareTo(y.EndTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Judge(PdtRuleset rs) {
|
public Judge(PdtRuleset rs) {
|
||||||
@@ -48,8 +44,10 @@ namespace Cryville.Crtr {
|
|||||||
activeEvs.Add(input, new List<JudgeEvent>());
|
activeEvs.Add(input, new List<JudgeEvent>());
|
||||||
}
|
}
|
||||||
var ev = new JudgeEvent {
|
var ev = new JudgeEvent {
|
||||||
StartTime = st + def.clip[0],
|
StartTime = st,
|
||||||
EndTime = et + def.clip[1],
|
EndTime = et,
|
||||||
|
StartClip = st + def.clip[0],
|
||||||
|
EndClip = et + def.clip[1],
|
||||||
Definition = def,
|
Definition = def,
|
||||||
State = container,
|
State = container,
|
||||||
};
|
};
|
||||||
@@ -57,6 +55,20 @@ namespace Cryville.Crtr {
|
|||||||
if (index < 0) index = ~index;
|
if (index < 0) index = ~index;
|
||||||
list.Insert(index, ev);
|
list.Insert(index, ev);
|
||||||
}
|
}
|
||||||
|
// Adopted from System.Collections.Generic.ArraySortHelper<T>.InternalBinarySearch(T[] array, int index, int length, T value, IComparer<T> comparer)
|
||||||
|
int BinarySearch(List<JudgeEvent> list, float time, int stack) {
|
||||||
|
int num = 0;
|
||||||
|
int num2 = list.Count - 1;
|
||||||
|
while (num <= num2) {
|
||||||
|
int num3 = num + (num2 - num >> 1);
|
||||||
|
int num4 = -list[num3].Definition.stack.CompareTo(stack);
|
||||||
|
if (num4 == 0) num4 = list[num3].StartClip.CompareTo(time);
|
||||||
|
if (num4 == 0) return num3;
|
||||||
|
else if (num4 < 0) num = num3 + 1;
|
||||||
|
else num2 = num3 - 1;
|
||||||
|
}
|
||||||
|
return ~num;
|
||||||
|
}
|
||||||
public void Feed(Identifier target, float ft, float tt) {
|
public void Feed(Identifier target, float ft, float tt) {
|
||||||
Forward(target, tt);
|
Forward(target, tt);
|
||||||
var actlist = activeEvs[target];
|
var actlist = activeEvs[target];
|
||||||
@@ -69,7 +81,7 @@ namespace Cryville.Crtr {
|
|||||||
var actlist = activeEvs[target];
|
var actlist = activeEvs[target];
|
||||||
for (int i = actlist.Count - 1; i >= 0; i--) {
|
for (int i = actlist.Count - 1; i >= 0; i--) {
|
||||||
JudgeEvent ev = actlist[i];
|
JudgeEvent ev = actlist[i];
|
||||||
if (tt > ev.EndTime) {
|
if (tt > ev.EndClip) {
|
||||||
actlist.RemoveAt(i);
|
actlist.RemoveAt(i);
|
||||||
// TODO miss ev
|
// TODO miss ev
|
||||||
}
|
}
|
||||||
@@ -79,9 +91,9 @@ namespace Cryville.Crtr {
|
|||||||
var list = evs[target];
|
var list = evs[target];
|
||||||
var actlist = activeEvs[target];
|
var actlist = activeEvs[target];
|
||||||
JudgeEvent ev;
|
JudgeEvent ev;
|
||||||
while (list.Count > 0 && (ev = list[0]).StartTime <= tt) {
|
while (list.Count > 0 && (ev = list[0]).StartClip <= tt) {
|
||||||
list.RemoveAt(0);
|
list.RemoveAt(0);
|
||||||
var index = actlist.BinarySearch(ev, _etcmp);
|
var index = BinarySearch(actlist, ev.StartClip, ev.Definition.stack);
|
||||||
if (index < 0) index = ~index;
|
if (index < 0) index = ~index;
|
||||||
actlist.Insert(index, ev);
|
actlist.Insert(index, ev);
|
||||||
// TODO priority?
|
// TODO priority?
|
||||||
@@ -122,6 +134,8 @@ namespace Cryville.Crtr {
|
|||||||
public Identifier[] pass;
|
public Identifier[] pass;
|
||||||
public Identifier miss;
|
public Identifier miss;
|
||||||
public Dictionary<ScoreOperation, PdtExpression> scores;
|
public Dictionary<ScoreOperation, PdtExpression> scores;
|
||||||
|
public int stack;
|
||||||
|
public int prop = -1;
|
||||||
}
|
}
|
||||||
public class ScoreOperation {
|
public class ScoreOperation {
|
||||||
public Identifier name;
|
public Identifier name;
|
||||||
|
Reference in New Issue
Block a user