The Daily Click ::. Forums ::. Klik Coding Help ::. Score ranking
 

Post Reply  Post Oekaki 
 

Posted By Message

Lobot



Registered
  04/08/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
27th October, 2011 at 11:36:37 -

Hello,
Does anyone know of a way of making a high score style score ranking system? There are 'A is Greater than B' events but how would you code 'A is greater than B but not as great as C or D' (making A third in the list). Is there a way of sorting values without having to input events for every ordering possibility?
Any ideas would be very much appreciated.

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
29th October, 2011 at 21:59:09 -

more information?

where are you storing your scores? external text file? .ini file? online? in a database? etc?

how are you retrieving said scores?

if you store them in order of rank, you will retrieve them in order by rank, and no sorting will be needed.

if they are stored in a database online, then its just a matter of querying the data to be sorted.

there are most likely extensions that can do sorting for you if you so choose to be lazy in your storing methods.

apart from that, i would suggest using a bubblesort algorithm.

 
n/a

Lobot



Registered
  04/08/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
30th October, 2011 at 05:42:27 -

Basically, I want to order counter values from top to bottom in a list in order of size. Is there any way that you can order these numbers without coding events for every possibility? Any ideas?

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
30th October, 2011 at 06:19:08 -

I'm going to repeat myself and say, you need to give more information. the more information you give the better answer you will receive.

Read my post again. I gave you several ideas. just in case you aren't aware of handy tools like google, and wikipedia, here is a place for you to start on my last and most useful idea on bubble sorting values. http://en.wikipedia.org/wiki/Bubble_sort

 
n/a

Lobot



Registered
  04/08/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
30th October, 2011 at 08:09:46 -

Cecilizer, Thanks very much for the bubble sorting idea and link- it's really logical. It flew straight over my head when I read your first post, maths is like a brick wall to me. sorry for making you repeat yourself. Happy Halloween!

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
30th October, 2011 at 09:47:27 -

no problem for sure.

just in case i can clarify how a bubble sort works.

a bubble sort works by taking a list of what is assumed to be unsorted values. take for example the numbers 1 through 5 jumbled up.

2 5 1 3 4

in order to sort them from smallest to largest you loop through the list from left to right, swapping the values positions if the left value is greater than the right. you make multiple passes through the list until all values are sorted. you use the same approach to sort from largest to smallest, only you check to see if the left value is less than the right before swapping.

in the given example you loop through the entire list making the following swaps.

first pass on the list is as follows.
[2 5] 1 3 4 = no swap. 2 is less than 5. list remains the same.
2 [5 1] 3 4 = swap. 5 is larger than 1. list is now 2 1 5 3 4.
2 1 [5 3] 4 = swap. 5 is larger than 3. list is now 2 1 3 5 4.
2 1 3 [5 4] = swap. 5 is larger than 4. list is now 2 1 3 4 5.

it is posited that on each pass, the value in the position equal to the length of the list minus the number of passes previously performed will be the largest value in that pass. in the first pass 5 is the largest number in the list and is now in the last position of the list (position 5) which is 5 - 0.

second pass on the list is as follows.
[2 1] 3 4 5 = swap. 2 is larger than 1. list is now 1 2 3 4 5.
1 [2 3] 4 5 = no swap. 2 is less than 3. list remains the same.
1 2 [3 4] 5 = no swap. 3 is less than 4. list remains the same.

we only made 3 comparisons this pass as opposed to the 4 comparisons we made during the previous pass. this is because at this point we already know that the largest number is in the next spot. so we stop. we now also know that the second largest value is in the second to last position, and the algorithm takes this into account for the next pass. even further we notice that the list is already sorted, however, our algorithm does not. so we begin the next pass.

third pass on the list is as follows.
[1 2] 3 4 5 = no swap. 1 is less than 2. list remains the same.
1 [2 3] 4 5 = no swap. 2 is less than 3. list remains the same.

we know from the previous passes that the next spots are already filled with the properly sorted values, so we stop. we also notice that no swaps were made during this pass. we can posit from this information that because the next positions are already sorted, and that no swaps were made, that the rest of the list must also be sorted, and there is no need to perform the last pass.

further notes: the reason we don't loop through the entire list comparing ALL values each pass is because we KNOW that the last position in the previous pass is the largest number for that pass. this allows us to do one less comparison for each successive pass thereby increasing our algorithms performance. Also, if during any given pass, no swaps are made, we can stop the algorithm because we know that the list is fully sorted. this also increases performance when a list is already partially sorted.

this animated image on the wiki shows the same process with a larger set of jumbled numbers. 1 through 8. please note that it can be any set of numbers, and they don't have to be sequential. the set 100 4 24 99 1 3 505 would work just as well.

Image
interesting to note that the image doesn't make use of the "if no swaps are made, sorting is finished" posit. waste of processing cycles doing unnecessary comparisons. shame on them.

Edited by Cecilectomy

 
n/a

Chris Burrows



Registered
  14/09/2002
Points
  2396

GOTW WINNER OCT. 2011
30th October, 2011 at 14:05:58 -


I had never heard of the Bubble Sort method until I read this thread and since Lobot, you find maths was like a brick wall I decided I would code it out for ya.

Image

http://www.whenthereisnoroominhellthedeadwalktheearth.com/MMF/bubblesort.zip

The zip file contains the mfa (fully commented) and an exe build. Hope you find it useful!
And please ignore the bubbles.... I needed to fill in space.

 
n/a

Lobot



Registered
  04/08/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
30th October, 2011 at 15:51:25 -

Ah, you guys are great. Chris, your program makes a lot of sense (I understand the comments and theory at least)-like a ladder for maths walls. More fancy than I'll be needing but I will definitely be having a dig around in the source file to try and get my head around the equations. Thanks very much.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click