Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当创建一个有边的游戏时,例如跳棋,本地玩家需要被赋予白色或黑色来玩。如果您希望游戏中心自动匹配选择或分配到另一方的参与者,您如何做到这一点?
您在不知道谁在玩哪一边的情况下在玩家之间建立联系 - 只需找到匹配即可。玩家建立联系后,您决定谁得到什么。一种解决方案是在游戏开始时交换在每一方生成的随机数 - 谁获得更大的数字,则以白色开始并获得轮到。请记住,如果您不走运,随机数可以相等 - 在这种情况下,您必须重新生成它们并重新发送。