Question about the documentation for Bucket Leaderboard

I have a question about the implementation code in the documentation for Bucket Leaderboard.

According to the documentation, my understanding is that we create an infinite tournament, and all users join this tournament. However, each user maintains a bucket data structure, which contains user IDs filtered by the bucket, based on random or other rules. In this way, the user IDs in the bucket data structure form a bucket leaderboard.

My question is, in the code, this data structure is stored under the current user ID. For example, when Player 1 joins the leaderboard, and we allocate Players 2, 3, 4, 5, along with Player 1, to form a bucket, we then add [P1-P5] as a bucket data structure under P1. However, for P2, P3, P4, P5, shouldn’t they also see the same group? Do we need to create the same bucket for P2-P5 as well? Otherwise, when P2 also tries to join the leaderboard, if he doesn’t have a bucket data structure, a random bucket might be created, and in the end, P1 sees P2 added to his group, but the bucket that P2 joined is completely different from what P1 sees.

If it’s not like this, did I misunderstand something? Are bucket data structures bound to a specific user?

After watching the video of the bucket leaderboard: seem like the code is different with the document, where i can find the corresponding repo and sample which used in the video?

The video for the bucket leaderboard uses Hiro which is a licensed product. Please reach out to if you are interested in Hiro.

thanks, but could you help to review my question for the bucket leaderboard logic in the doc?

Hello @mengxin, the example in the documentation is a simple bucketing strategy where the buckets are formed of completely random players, so they might all see different players in their leaderboard buckets/views.

If you’d like to, for example, add a player’s friends into the same bucket, then you’ll need to have additional logic in place to insert their user IDs in the bucket list at creation and possibly on friendship graph changes.

Hope this helps

ok, thanks for the explanation. but random is not the problem, the problem is that the player in the same bucket cannot see other players. like i said how to guarantee P1 bucketed with p2, p3, p4 and P2 can also see P1, P3,P4?

To do this I’d suggest you have a list of storage object owned by the system user each with a bucket with a max amount of players, every time a player joins the leaderboard you assign it to the next incomplete bucket, if none is available create a new one. When a player is assigned a bucket you create a storage object for him that references the system owned bucket, this way you have a 1-to-many bucket that gives a consistent view across all players within it.