tag:blogger.com,1999:blog-6997440551610060560.post6788832332344798793..comments2023-05-20T03:34:03.651-05:00Comments on Nathan's Development Blog: Kernels, enemies dying, and bankswitchingNathanhttp://www.blogger.com/profile/14248157226095069791noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6997440551610060560.post-87736217753709486172014-10-22T09:30:29.278-05:002014-10-22T09:30:29.278-05:00Hi Sverx! Didn't know you read my blog! That p...Hi Sverx! Didn't know you read my blog! That puts me up to somewhere around 4 readers, I think!<br /><br />Anyway, yeah, I agree. I actually came really close to using a Bubble Sort in GBA Anguna as well, in the same way -- to sort my enemies according to Y value. In that case, I reasoned that the vast majority of the time, they'd be already sorted. Occasionally (once every 120 frames or so?) 2 of them would swap places with each other. In that case, Bubble Sort seemed like a perfect choice, as it would only require one pass the vast majority of the time.<br /><br />I was finally convinced away from that idea when I had a few rooms with ghosts that randomly appeared in different places. Those would require a full sort, so I went with a merge sort, which was going to have more reliable performance (not as fast as the optimal bubble sort situation, but not quite as slow as the worst)<br /><br />And in both cases, I was usually only sorting at most 12 enemies. Just about any sort would work with numbers that small.Nathanhttps://www.blogger.com/profile/02763963217187530121noreply@blogger.comtag:blogger.com,1999:blog-6997440551610060560.post-33029849725677279802014-10-22T03:07:19.328-05:002014-10-22T03:07:19.328-05:00Bubble sort isn't always bad. Yes, I know it&#...Bubble sort isn't always bad. Yes, I know it's O(n^2) but if you compare some k*n^2 efficient algorithm to a some k'*n*log(n) you might find that in some cases (small n) the first is faster. People tend to forget the constant...sverxhttps://www.blogger.com/profile/13552101081332715415noreply@blogger.com