SP4CEBAR 2022-08-17 16:54
It generates an array of index values so it can leave the original array in-tact
SP4CEBAR 2022-08-17 17:02 (Edited)
without waiting for VBL it can complete the sorting of all 128 items in 6 frames
It loops through all values once. Each value is compared to all values that are stored so far, after each comparison values are shifted in the array to create a gap, once a comparison is positive the index is written in the gap. Does anyone know what sorting algorithm this is equivalent to?
SP4CEBAR 2022-08-17 17:09
Update: how could I forget, the audio
G-9 2022-08-19 21:22
the audio 🤯
G-9 2022-08-19 21:22
the audio 🤯
SP4CEBAR 2022-08-20 14:23 (Edited)
I just added red progress lines
SP4CEBAR 2022-08-20 14:24
And in the version after that I slowed it down so that you can see how it works
was8bit 2022-08-20 16:43
Nice animation :)
SP4CEBAR 2022-08-22 06:29
Does anyone know what sorting algorithm this is equivalent to?
was8bit 2022-08-22 18:01
I dont know them by name... i know for small batches this one is straightforward... i do remember other ones used for bigger batches...
SP4CEBAR 2022-08-24 09:41
Thanks
GAMELEGEND 2022-09-01 16:03
It sounds like a space shooter in the arcade.
SP4CEBAR 2022-09-11 14:31 (Edited)
I recently made a card shuffle algorithm, at one point I had to test for duplicates, I didn't want to count them by hand, so I just hooked up my sorting algorithm to un-shuffle and check for duplicates, and found that the shuffle algorithm worked, this is when programming is just great
was8bit 2022-09-11 15:06
For shuffling I just make a straight set then use a ton of SWAP to randomly mix the set
was8bit 2022-09-11 15:08
Actually, real life shuffling isn't perfect.. if you start with a straight deck and only manually shuffle it twice, it actually remains almost entirely in order ;)
SP4CEBAR 2022-09-11 20:17 (Edited)
The idea for my algorithm is inspired by the riffle shuffle technique: my algorithm generates a random number for "group size" and then it inverts all cards of each group, I repeated it 16 times to get a pretty good shuffle
But I didn't think about using swap, that's a lot simpler, however it may need quite a lot of iterations to be effective when both swap variables are randomly selected, but I just realized, that if only one of the two is randomly selected and the other one loops through all cards once, then that should work
was8bit 2022-09-12 03:34
Yea, for a good shuffle using SWAP you need a min of 4x#ofcards so a standard deck of cards needs at least 200 swaps... but even 2,000 swaps doesn’t really take any time considering you only shuffle the cards once or so....
was8bit 2022-09-12 03:36
What I do is
c1=RND(cardsmax)
C2=rnd(Cardsmax)
Adjust the math if needed if you aren’t using the zero index
Then swap card(c1),card(c2)
SP4CEBAR 2022-09-12 10:32 (Edited)
Wait, does RND accept a parameter: RND(V)?
was8bit 2022-09-12 12:00
Yes, RND by itself produces a number 0 to 0.999999 . RND(N) produces a whole number 0 to N ;)
SP4CEBAR 2022-09-12 19:09
I didn't know NX could do that, nice to know :)
was8bit 2022-09-12 23:59
Oh yea!! :D