question

garrygaber avatar image
garrygaber asked

Found a discrepancy in GetLeaderboardAroundPlayer - might be an issue

In wiring up our Leaderboards, I have several entries that are set to 0 - not a "no score", but simply a score of 0. Currently, we have 28 beta users on the leaderboards, and I am calling for a max of 100 values.

In looking at the data in Leaderboards and focusing on one test user, he is listed as 21 in the list. When I pull up GetLeaderboard, he is indeed the 21st entry in the list.

However, when using GetLeaderboardAroundPlayer, he is listed as 9, which is the first of the 0 scores. Is this correct behaviour? Is there something I can do to make the two displays match?

Thank you!

Leaderboards and Statistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

marcowilliamspf avatar image
marcowilliamspf answered

Get Leaderboard and Get Leaderboard around player have two very different functionalities. Getting the leaderboard for top 100 players using "GetLeaderboard" will give you a liner list of ranked players. Where as Get Leaderboard around player will show you players above your rank and players below your rank. So the indexing of those rankings will not match between those two api calls.

to solve this we have included a "Position" attribute. so my question in response to your question is; are you saying that the Position field in the response of the API calls is returning two different Position values for the player? Or are you using the index from the array in the response to determine the position of the player. It is unclear from your question what value you are using to determine the position.

Please refer to the documentation on API usage and response. Here are some handy links below.

https://api.playfab.com/documentation/client/method/GetLeaderboard

https://api.playfab.com/documentation/client/method/GetLeaderboardAroundPlayer

Notice they both have a Position for each player in the response object.

If the Position is not matching between calls, please post the details of your test here, and we can have a look.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeremy Rose avatar image Jeremy Rose commented ·

Having the same issue. The position returned by GetLeaderboardAroundPlayer is not the same as if you call GetLeaderboard.

Looking at the dashboard list. This appears to be returning some kind of filtered list based on score. We have lots of ties in our leaderboard.

In the list of all stats my player is actually 32, but when calling GetLeaderboardAroundPlayer for my player id and count of 1, the position is 23, which is the position of the first value equal to my value. Basically the first of the tied values.

So when say listing the top 25 entries, and then my entry position is 23. But I am not in the list at position 23. When my position entry should actually be 32 if gotten from GetLeaderboard

0 Likes 0 ·
garrygaber avatar image
garrygaber answered

Hi Marco -

In answer to your question, my code takes the list and steps through it entry by entry, filling an array of canvas objects with the returned data of name , position (rank) and a single statistic. There is no position call that I can find for GetLeaderboardAroundPlayer(), but I use the default position with GetLeaderboard();

When I wrote this post, there were 28 users, so I (maybe incorrectly depending on your answer) assumed that the rank should match with the user if I stepped through and displayed them sequentially.

Does that answer your question and am I doing something incorrectly?

Here are the code snippets for both functions:

    public void displayLeaderBoard (GetLeaderboardResult result){

        // Calculate length from Count

        string display = "";

        int stat = 0;

        int pos = 0;

        int count = result.Leaderboard.Count;



        for (int i = 0; i < count;i++){

            if (result.Leaderboard [i].DisplayName == null)

                display = result.Leaderboard [i].PlayFabId;

            else

                display = result.Leaderboard [i].DisplayName;

            stat = result.Leaderboard [i].StatValue;



            // Convert back to original format of number:

            double d_stat = s_Main.convertFromInt (stat);

            string s_Stat = s_Main.convertBigNumName (d_stat, "", false);


            pos = result.Leaderboard [i].Position + 1;


            s_LeaderDetail[i].displayLeaderDetail (display, s_Stat, pos.ToString(), result.Leaderboard [i].PlayFabId == sGameCtrl.control.PlayFabID);

        }
    }
public void displayLeaderBoardAroundPlayer (GetLeaderboardAroundPlayerResult result){

        // Calculate length from Count

        string display = "";

        int stat = 0;

        int pos = 0;

        int count = result.Leaderboard.Count;

        int playerPos = 0;



        for (int i = 0; i < count;i++){

            if (result.Leaderboard [i].DisplayName == null)

                display = result.Leaderboard [i].PlayFabId;

            else

                display = result.Leaderboard [i].DisplayName;

            stat = result.Leaderboard [i].StatValue;



            // Convert back to original format of number:

            double d_stat = s_Main.convertFromInt (stat);

            string s_Stat = s_Main.convertBigNumName (d_stat, "", false);


            pos = result.Leaderboard [i].Position + 1;


            if (result.Leaderboard [i].PlayFabId == sGameCtrl.control.PlayFabID) {

                // Mark player's position

                Debug.Log ("PlayerPos = " + i);

                playerPos = i;

            }



            s_LeaderDetailAroundPlayer[i].displayLeaderDetail (display, s_Stat , pos.ToString(), result.Leaderboard [i].PlayFabId == sGameCtrl.control.PlayFabID);

        }

        //Set viewport position y to player's position

        Scroll_Panel[0].verticalNormalizedPosition = 1f - ((float)playerPos / (float)count);

    }

Thank you for taking a look at this!

Kindest Regards,
Garry

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

Quick question - is the issue that you have a number of players who all have the same score (0)? If so, please see this thread: https://community.playfab.com/questions/958/211254247-users-with-same-stat-value-have-same-pos-in-leaderboard.html. Currently, players with identical scores are not deterministic in their ordering.

0 Likes 0 ·
garrygaber avatar image garrygaber commented ·

Yes, Brandon, that is true - this user is in the midst of the zero scores.

0 Likes 0 ·
brendan avatar image brendan garrygaber commented ·

Okay, so is that, in fact, the issue you're seeing? That the position of users in the list, when they have the exact same score, is non-deterministic? Or are you seeing something else?

0 Likes 0 ·
garrygaber avatar image garrygaber commented ·

That is exactly what I’m seeing - non deterministic behavior related to zero values. Any ETA on the fix mentioned in the other post? I like the idea of date posted being the determining factor,...

g

0 Likes 0 ·
brendan avatar image brendan garrygaber commented ·

Sorry, not currently. We prioritize in part based upon the number of developers who've asked for a particular feature, and we've actually had very little feedback on this particular issue. As such, I'm afraid it has remained a lower priority.

0 Likes 0 ·
claurenti avatar image
claurenti answered

Hello,

I'm digging up this thread as I'm still facing that issue.


We're providing our users the ability to either reach their ranking, or navigate by tens of players (10's to 19's) .
In order to do that, we're calling GetLeaderboardAroundPlayer with MaxResultCount set to 1, then GetLeaderboard to get the 10 results from 0 to 9 inside the decade where the local player is.
This works perfectly fine when there are no ex aequo entries.

However, when several users have the same value, the actual ranking (i.e the one seen on Playfab AND the one return by GetLeaderboard) does not match the one returned by GetLeaderboardAroundPlayer.

This is a major issue since when navigating through the leaderboard, we would see a different ranking from the one returned when seeking our rank.

Is there any workaround using some Cloud script with Server API calls that would return deterministic rankings like GetLeaderboard does ?

,

Hello,

I'm digging up this thread as I'm still facing that issue.


We're providing our users the ability to either reach their ranking, or navigate by tens of players (10's to 19's) .
In order to do that, we're calling GetLeaderboardAroundPlayer with MaxResultCount set to 1, then GetLeaderboard to get the 10 results from 0 to 9 inside the decade where the local player is.
This works perfectly fine when there are no ex aequo entries.

However, when several users have the same value, the actual ranking (i.e the one seen on Playfab AND the one return by GetLeaderboard) does not match the one returned by GetLeaderboardAroundPlayer.

This is a major issue since when navigating through the leaderboard, we would see a different ranking from the one returned when seeking our rank.

Is there any workaround using some Cloud script with Server API calls that would return deterministic rankings like GetLeaderboard does ?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lesniermarrero avatar image
lesniermarrero answered

i have the same issue

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.