Sign In Register

How can we help you today?

Start a new topic

Rolling 7 Day Realtime Leaderboard

I'm trying to create a rolling 7 day leaderboard that is updated in real time and contains the SUM of points scored in the last 7 days. I thought I had this working until I realised that a players leaderboard entry was only being updated when the player posts a score. This means if the player posts a score and doesn't return their entry hangs in leaderboard forever, when the desired behaviour would be that the score reduces over time until it drops off the leaderboard entirely after 7 days.


Here is my current set up:


I have an event called SKYJACKING_CLAIMED that is triggered when a player claims their points reward. POINTS and TIME are the only attributes relevant to this leaderboard.

image


I then have the leaderboard set up as follows:


image

Is it possible to achieve what I'm after? If so, where am i going wrong?


Hi Liam,


I have a similar request.


I would like to re-calculate a high score table every hour.


Player scores:

  • Players collect "points" for completing a chapter in the game
  • Each time they collect points, those are submitted as an event

High score:
  • Recalculated every day
  • Get all scores a player submitted in last 7 days (older scores expire)
  • Multiply each score with a factor, based on the timestamp at which it was submitted (basically the scores devalue with time, i.e. if you collect 100 points yesterday, today they are only worth 90 points, until they expire completely after 7 days)
  • Player score = Sum of the time devalued score (updated every day)

I was thinking to:
  1. Create an event to submit the score + add a time stamp to it via cloud code (not sure if GS already adds one automatically, that can be accessed) & save this to a runtime collection (with player id)
  2. use a scheduled script to do the calculation of the score per player
  3. use the scheduled script to submit those scores as another event ("on behalf of each user")
  4. use those submissions in a standard highscore table that only keeps last submitted value

before i get started on this, I would appreciate your opinion on the approach and any help that you can possibly provide

Hi Liam,


I'm starting to think that what I would like to do is not possible. Would you agree?


Thanks,


Rob

Hi Rob,


Yes I think I understand what you're after now. If the player scored 100 every day for 7 days they'd have a score of 700. Then when day 8 starts you want to go back and take day 1 score away. So on day 8 they'd have 600 until they posted a score that day and it was added to the new total. Does that sound right ? The filter above won't work, that would be used on a calculated leaderboard. The filter would be applied at the time of calculation and not in real time so it won't work in this case. Can you confirm that this is the functionality you're after ? When you have I'll do some more digging to see how you could best go about accomplishing this.


Regards,

Liam

Hi Liam,


Yes that is exactly what I'm after.


Thanks,


Rob

Hi Rob,


As far as implementing this out of the box goes I think the best way to achieve it would be by using a leaderboard that calculates daily and consumes scores from the last 7 days with the use of a filter. The calculation would happen each night at midnight UTC. So the leaderboard for that day would get created then. I think this would cover the rolling score solution. It wouldn't be real time as it's calculating each night but you could use the calculated boards as a reference point for updating a score when a player logs in. You might need to combine this with a periodic bulkJob to remove older player entries from the leaderboards altogether. Does this sound like it would work for you ? 


Regards,

Liam

Hi Rob, 


So each week scores will start off from 0 for each player ? The only way for a players score to change would be for them to submit another one. In the case of a SUM default calculation you could use a minus value to do this. A weekly partition might be the best way to handle this. This would mean every week is grouped and partitioned into it's own leaderboard and the latest one will only contain scores from players who have posted that week. Does that sound like what you need here ? 


Regards,

Liam

Hi Liam,


Thanks for your response. What I meant by a rolling leaderboard is that the scores are never reset as such, but scores drop out of the SUM calculation when they become older than 7 days. Rather than having a leaderboard for each calendar week I would like it to be the SUM of all scores from between now and 7 days before now.


Regards,


Rob

Login to post a comment