# Google turn based multiplayer automatch criteria

I've set up a multiplayer game using Google's turn-based API. I now want to put some qualifiers on auto-matching and am racking my brain on how to solve this issue...

I'm using GetVariant() to distinguish between the Lite and Pro versions of my game. That's easy enough. Other than that I want to have several parameters that can be varied. As a restricted example, let's say there are three difficulty levels and two types of game. I want the players to be able to either specify which they want or to leave the option completely open (and before it's pointed out, I realise that the more specific the qualifiers, the longer it might take to get a match).

It seems that setting the exclusiveBitMask in the createAutoMatchCriteria function call could be the solution (and, indeed, I can't see anything else at all that might be useful in this task).

I thought that the game type could be specified in the lower two bits and the difficulty level could be specified using the next three bits. Essentially, the bit mask would mask out the difficulty levels and game types that the player isn't interested in. So, looking at the lower 5 bits of exclusiveBitMask we would have

011 10 - difficulty 3, game type 1
101 10 - difficulty 2, game type 1
110 01 - difficulty 1, game type 2


And the difficulty level (for example) could be left open by not masking any of the difficulty bits

000 10 - any difficulty level, game type 1


This works fine (in theory) so long as one player specifies the type of game he wants and the other players all leave their options open. It's likely that most players will select "quick match" which defaults the settings to "any" so that might not be such a problem. (If two players specify the same difficulty, for example, the exclusive bits will prevent a match. If two players specify differing game types, they will actually be given a match, but that can be overcome by using three bits to specify the game type).

But this system would require every player to join the match before it can actually commence which isn't ideal. It could be that one player has specified the type of game he wants, one player has specified the difficulty level he wants and three players have left all options open. We can't initialise the game until we have all players ready and know what choices each of them has made.

So this brings me to the crux of the problem. Without each player taking an empty turn to pass their information on to the next, how can I determine what exlusiveBitMask each has used? I was hoping that exclusiveBitMask might be modified by a logical OR operation after each player joins and that this would be available via getAutoMatchCriteria but this isn't the case.

So, the questions I have...

1) This method isn't nice but it's the only one that seems remotely viable for specifying game types (and being able to leave some options open in the specification). Is there a nicer, cleaner method available?

2) If no other method is available, are there any suggestions as to how to overcome the caveats and identify each player's specification without every player having to run an empty turn at the beginning of a game to pass the information on?