C#C
C#2y ago
mynarco

Optimize Search Algorithm to find Most dense part in rhythm game map.

Hello, so i am struggling with a logic problem, i am writing a 3d rhythm game where notes approach at you(a rewrite for this game https://www.youtube.com/watch?v=t40kkLAAvtk)

I need to be able to calculate the MAX amount of notes that will be rendered at a time so i can just create a statically sized array for instances to render to optimize

now the 2 things i am working with are an approach time, hitwindow, and each notes time

to get the max lifetime of a note i just need to add approach time to hitwindow

so now i have a notes lifetime and each notes specific time into the song

so i have written out a solution, now i need to optimize it, there is absolutely NO room for error as this is determining the amount of memory to allocate for notes
    public int CalculateMaxInstanceCount() {
        float lifetime = Global.Settings.Note.ApproachTime + NoteObject.HitWindow;
        int max = 0;
        for(int i = 0; i < OrderedNotes.Length; i++) {
            int count = 0;
            for(int j = i; j < OrderedNotes.Length; j++) {
                if(OrderedNotes[j].Time > OrderedNotes[i].Time + lifetime) break;
                count++;
            }
            if(count > max) max = count;
        }
        return max;
    }
YouTubeazer
done last stream, sorry for taking so long to upload!
i've been playing osu! a lot recently and earlier today got a 112pp play in just 11 days of playing! :)

Rhythia Settings:
---------------------------
Please note that I do regularly change my settings when I feel like I need a change. If I am streaming and you happen to notice that I am usin...
Was this page helpful?