Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Sorting
2007-10-08 16:08
Oswald

Registered: Apr 2002
Posts: 5034
Sorting

are sorters really so slow in games? :) I have made my unrolled version for my theoretical game (;), and it takes 132 rlines to sort 32 numbers o_O worst case is ~200 lines. tho when its the case of 4 numbers have to be swapped only it does the job in ~10 lines. wastes a lot of memory but I like it :)
 
... 193 posts hidden. Click here to view all posts....
 
2020-04-08 13:03
Bezerk
Account closed

Registered: Mar 2020
Posts: 5
That's brilliant @Lft, well done!

@ChristopherJam, no need to put me + Lft on this one in the comparison table.
2020-04-08 14:21
Rastah Bar

Registered: Oct 2012
Posts: 336
Lovely! Question: if one would sort according to high nybble first, what would be the complexity?

And could someone post an equation for the the latest approach that shows the number of cycles as a function of Y-range and number of actors, please?
2020-04-08 15:01
ChristopherJam

Registered: Aug 2004
Posts: 1390
I should have included an e&oe really :)

ok, next draft just lft for final radix entry. Any comments on fieldsort memory usage will be integrated too, I just didn't manage to look that up before dinner.

Rastah Bar - Going by lft's writeup at codebase, it's an extra 51 cycles per actor regardless of order.

Flagged bucket sort's a little messier as it depends how many are on the same line or in the same eight line group.

graphs one of these days..
2020-04-08 16:27
lft

Registered: Jul 2007
Posts: 369
My approach uses 60 bytes of zero-page, so this should be updated in the table. It can be reduced to 32 bytes at the cost of a few extra cycles (I think 12, but haven't tested).

Adding support for the full range ($00-$ff, adding two more lists for the high nybble) will bump the zero-page size up to 64 bytes, and add 22 cycles.
2020-04-08 16:38
Oswald

Registered: Apr 2002
Posts: 5034
Quote: My approach uses 60 bytes of zero-page, so this should be updated in the table. It can be reduced to 32 bytes at the cost of a few extra cycles (I think 12, but haven't tested).

Adding support for the full range ($00-$ff, adding two more lists for the high nybble) will bump the zero-page size up to 64 bytes, and add 22 cycles.


a general solution would be nice to have on codebase, not everyone wants to sort sprites. also can it handle all entries showing up in 1 bucket ?
2020-04-08 16:40
ChristopherJam

Registered: Aug 2004
Posts: 1390
Quote: a general solution would be nice to have on codebase, not everyone wants to sort sprites. also can it handle all entries showing up in 1 bucket ?

Doesn't need to support more than eight entries per bucket for sprites…
2020-04-08 16:45
lft

Registered: Jul 2007
Posts: 369
@Oswald Yes, it handles all cases, always using the same amount of cycles.
2020-04-09 09:22
Rastah Bar

Registered: Oct 2012
Posts: 336
The costs per actor are lower for inline buckets. I was trying to figure out if it could be beneficial to combine the new radix sort and the inline bucket sort. F.e. one stage of radix sort followed by an inline bucket sort for each bucket of the first stage.
2020-04-11 14:04
Rastah Bar

Registered: Oct 2012
Posts: 336
<Original post deleted>
I thought I had found an improvement to inline buckets, but ChristopherJam already proposed that.
2020-04-14 06:23
ChristopherJam

Registered: Aug 2004
Posts: 1390
Ah, sorry about that :)

But also damn, I'd forgotten whether or not I'd already implemented what you wrote, and was looking forward to rummaging through my code to see if I could integrate it..

Interesting idea about combining radix with IBS - after all, a bucket sort is just a one digit radix sort (compared to the two digit radix sorts used elsewhere in this discussion)
Previous - 1 | ... | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
bugjam
Shake/Role
CA$H/TRiAD
elte
Asphodel
Monte Carlos/Cascade
Guests online: 61
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Aliens in Wonderland  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Birth of a Flower  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Offence  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.063 sec.