Race Ranking

0 favourites
  • 6 posts
  • Hello,

    I'm figuring out how is the best way to sort a Race ranking, but my code is huge and is not working properly, shuffling the results.

    Do you can share your knowledge about it, if possible, with a simple CAPX?

    The way I did it was, each checkpoint add a Score to the AI and Player. The player and AI can't miss any single checkpoint, if so, he will be teleported to the missing checkpoint to make sure the most accurate score.

    So, the bigger score will be sorted to be the first place and them ahead. the problem is when 2 competitors have the same score, them, the second place show empty =

    I can't figure out how to implement a best way to achieve it =<

    If you care to make a CAPX, please, try to deal with the challenge of 3 single squares running in line, earning points over the time and sorting their ranking.

    Thank you in advance.

  • I'm on my phone so I can't check right now, but can't you use a For Each Ordered and sort them by their points variable? Add in a check to see if the current object's var is the same as the previous to handle that issue, and if they are, give them the same ranking.

    The bigger issue I see is how to use the points set-up when the path isn't straight...

  • Hi SullyTheStrange, I'm stuck with it, because the treatment of same ranking issue.

    Later I'll do a simple CAPX to make easy for Us study the code of this issue.

    Thank you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Maybe Ashley, , Kyatric, or some of the Amazing programmers here can help with this issue, I'm not programmer, just a curious =(

    Rules, use only events, no plugins please.

    Here is the CAPX: https://dl.dropbox.com/u/47035927/Samples/ranking/ranking.capx

    Here is the sample: https://dl.dropbox.com/u/47035927/Samples/ranking/index.html

    Array sorting system (by Yann): http://www.scirra.com/forum/forum_posts.asp?TID=49771&PID=313345&title=sorting-an-array#313345

    The deal here is treat when two cars have the same score, how you deal with it? Who is the winner? Who have the best rank position? Who touched the line first! Right? but if they touch in the same tick. Oh my, headache =

    I think it was not a good idea, but how you can know what car is in the first position if you're not able to check pixel by pixel their track? I think using checkpoints was a good idea, but it's becoming a nightmare.

  • Sully's solution will work, but give the score a bias so that the first car to pass the first checkpoint will have a score of 1.5, the second 1.4 and so forth. No two cars can now have the same score. Discard the decimal portion of the score every time you hit a checkpoint as it's only to indicate the order the checkpoint was hit. The formula looks like this:

    set score to int(self.Score)+1+0.1*(5-Checkpoint.hit_count)

    It shouldn't matter if two cars hit the finish line in the same tick, the winner will be whichever car is processed first and I don't think a player will even notice.

    http://dl.dropbox.com/u/5426011/examples14/checkpoint.capx

  • Amazing R0J0,

    Thank you very much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)