iosgame-centergamekitgkturnbasedmatch

How do you determine 'side' for turn based iOS games?


When creating a game with sides, checkers for example, the local player needs to be given white or black to play with. If you want game centre to auto match against participants who either picked or were assigned the other side, how do you do that?


Solution

  • You make connection between players without knowing who is playing which side - just find a match. After players gets connected you decide who gets what. The one solution is to exchange a random numbers generated on each side at the beginning of the game - whoever gets bigger number starts with white and gets turn. Remember that if you are unlucky randoms can be equal - you have to regenerate them and resend in that case.