Forum BigDB Get Position of Score

Discussion and help relating to the PlayerIO database solution, BigDB.

Get Position of Score

Postby TheEarthGroup » October 19th, 2014, 4:29 am

Hi,

I want to create a simple high score ladder.
Every time the player finishes the game, I would like to create a table to know which rank he is in (for example #123), as well as the people who are 10 positions in front and behind of him (i.e position #113 to #133).


How do I use indexes to do this?

Thanks. :D
TheEarthGroup
 
Posts: 1
Joined: October 19th, 2014, 4:25 am

Re: Get Position of Score

Postby hangar » October 23rd, 2014, 4:38 am

NoSQL databases aren't great at counting. Basically you'd have to run a background process that does the counting, there'd be a time lag you'd have to adjust for (or flag dirty bunches and recount them on the fly) and there's no real support for background processes in gamesnet. Counting in leaderboards gets really complicated. But knowing you're number 10,876 in a list of 23,475 isn't very useful information. Here's some alternatives:

Friends Leaderboard: If you have some list of the person's friends, just load all their scores (One LoadKeys query, making the keys some concatenation of something like user id and what leaderboard it's for). Doubtful anyone has >1,000 friends, so just load them all and sort them yourself.

Group Leaderboard: If you have some way to divide players up into small groups, like by elo rating or bracket, you can show the user a ranking for this small group of people. Good for bigger games. (Works same as friend's list.)

Relative Leaderboard: Show people at around your score. (Two LoadRange queries on an index, starting at your score and ascending or descending respectively.)

Global Top X: Show who's at the very top of the leaderboard for bragging rights (and attracting whales). Note that leaderboards on single player games are often easily hacked, making this less useful to show to the user. (One LoadRange query on an index, descending.)
hangar
 
Posts: 8
Joined: September 16th, 2014, 7:00 am

Re: Get Position of Score

Postby Chacaros » October 23rd, 2014, 10:56 am

Based on the updates in the SDK [3.0.14 - ufk7o16JQ5UUW7Hiqn8uDQ] I would think that the YGN team is working on implementing some kind of score/ranking system. It doesn't look finished to me and I could only find a client side API, but thats a great sign nonetheless.
Chacaros
 
Posts: 13
Joined: September 5th, 2014, 5:47 pm

Re: Get Position of Score

Postby hangar » October 23rd, 2014, 7:32 pm

Possibly, but unless they use another type of database, or put in a lot more work than I'd think was worth it, I doubt they'll have anything past what you can write yourself with db queries. Will probably save a lot of time to use their implementation though, and it'll be more accessible.
hangar
 
Posts: 8
Joined: September 16th, 2014, 7:00 am

Re: Get Position of Score

Postby Henrik » October 27th, 2014, 1:54 am

No, you can't use BigDB to create the functionality you describe.

Yes, we'll be adding a backend service for scores and ranking soon.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Get Position of Score

Postby Retimer » October 27th, 2014, 10:07 pm

Could there not be functionality for this from indexing? Why can the position in the index not be recorded at the time of the table indexing of db objects?
Retimer
Paid Member
 
Posts: 14
Joined: March 9th, 2013, 2:53 pm

Re: Get Position of Score

Postby Chacaros » October 28th, 2014, 5:13 pm

No. The crucial part of all ranking solutions is that you have to centralize data. NoSql databases do the complete opposite of this. You would at least need a count operation in order to create rankings. SQL db's however store data mostly more centralized, so their counting is way more efficient.
Chacaros
 
Posts: 13
Joined: September 5th, 2014, 5:47 pm

Re: Get Position of Score

Postby Henrik » October 28th, 2014, 6:19 pm

Indexes are typically tree structures that make it easy to go from the root to a specific leaf node. If you want to count the number of scores that are higher than yours, an index can help you find your starting point very quickly, but after that you still need to scan the rest of the index to get the count.

It's a pretty difficult problem to solve in a scalable fashion, but there are ways to compromise. I'll make sure to bump this thread when we officially release our scoring service.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Get Position of Score

Postby Retimer » October 28th, 2014, 6:22 pm

Looking forward to it. Thanks for the responses :)
Retimer
Paid Member
 
Posts: 14
Joined: March 9th, 2013, 2:53 pm


Return to BigDB