Patrick Kafka
Patrick Kafka

Reputation: 9902

Android TurnBasedMultiplayer auto matching with exclusiveBitMask

Can someone explain how this bitmask parameter might be used to auto-match exclusive roles in a game? Does it seem possible to auto-match multiple players of unique roles?

It is mentioned here here

Your game can also use the exclusiveBitMask parameter in createAutoMatchCriteria() to pair auto-matched players who are interested in playing specific exclusive roles in a game.

and also the api docs

public static Bundle createAutoMatchCriteria (int minAutoMatchPlayers,
                             int maxAutoMatchPlayers, long exclusiveBitMask)

Creates an auto-match criteria Bundle. Can be passed to createMatch(GoogleApiClient, TurnBasedMatchConfig) to create a match for a turn-based game.

Parameters minAutoMatchPlayers min number of auto-matched players. maxAutoMatchPlayers max number of auto-matched players. exclusiveBitMask exclusive bitmask for exclusive roles for the player. The exclusive bitmask of each pairing of players must equal zero for auto-match.

Upvotes: 2

Views: 667

Answers (2)

Bram
Bram

Reputation: 8283

From the documentation:

When auto-matching with this option, players will only be considered for a match when the logical AND of their exclusive bit masks is equal to 0.

So if you have a bit set in this mask, your opponents CANNOT have that bit set as well, if they want to be paired to you.

E.g. in chess, if A wants to play white, and B wants to play black, they can specify this in this mask (0x1 for white, 0x2 for black), and can be paired. Two players wanting to play white will not be matched.

A player with mask 0x0 can be paired with any player, either as white or as black.

Upvotes: 1

Eric Woodruff
Eric Woodruff

Reputation: 6410

"The exclusive bitmask of each pairing of players must equal zero for auto-match" essentially means that the exclusiveBitMask must be the exact same between players. The usefulness would be limited. That doesn't mean you couldn't create a bit mask that represents role A and role B if the relationships were that simple. But it would mean it would match players with either role A or B and it would need to be filtered. If role A could also match with role C then the user would have to select a filter that matches A+B or A+C but not both.

Upvotes: 0

Related Questions