コード例 #1
0
        /// <summary>
        /// Finds and marks all sequences hittable using a roll.
        /// </summary>
        /// <param name="patternLength">The length of a single repeating pattern to consider (triplets/quadruplets).</param>
        private void findRolls(int patternLength)
        {
            var history = new LimitedCapacityQueue <TaikoDifficultyHitObject>(2 * patternLength);

            // for convenience, we're tracking the index of the item *before* our suspected repeat's start,
            // as that index can be simply subtracted from the current index to get the number of elements in between
            // without off-by-one errors
            int indexBeforeLastRepeat = -1;

            for (int i = 0; i < hitObjects.Count; i++)
            {
                history.Enqueue(hitObjects[i]);
                if (!history.Full)
                {
                    continue;
                }

                if (!containsPatternRepeat(history, patternLength))
                {
                    // we're setting this up for the next iteration, hence the +1.
                    // right here this index will point at the queue's front (oldest item),
                    // but that item is about to be popped next loop with an enqueue.
                    indexBeforeLastRepeat = i - history.Count + 1;
                    continue;
                }

                int repeatedLength = i - indexBeforeLastRepeat;
                if (repeatedLength < roll_min_repetitions)
                {
                    continue;
                }

                markObjectsAsCheese(i, repeatedLength);
            }
        }
コード例 #2
0
        /// <summary>
        /// Determines whether the objects stored in <paramref name="history"/> contain a repetition of a pattern of length <paramref name="patternLength"/>.
        /// </summary>
        private static bool containsPatternRepeat(LimitedCapacityQueue <TaikoDifficultyHitObject> history, int patternLength)
        {
            for (int j = 0; j < patternLength; j++)
            {
                if (history[j].HitType != history[j + patternLength].HitType)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #3
0
 public void SetUp()
 {
     queue = new LimitedCapacityQueue <int>(capacity);
 }