Turn-based networking (similar to Words With Friends)

What’s the usual way to implement a turn-based 1v1 game in Unity? This would be very similar to Words With Friends except that each player can take their turn simultaneously, but only once both have submitted their move would the next turn be played.

Both users would then receive a notification that the turn was complete, they’d see the results, then start working on their next turn and submit until end game.

Match making and playing with a specific friend should be possible as well. Platforms would be PC and mobile if that makes a difference.

Maybe I should have been more specific since there hasn’t been any activity on this thread.

Would you use a master server to do the match making, then establish a Peer-to-Peer connection once the players are matched, or would you continue to use the master server as an authoritative server?

With the P2P model client side cheating remains a possibility, but the authoritative server model doesn’t scale as well.

Are there other pros/cons that I am missing?

Are there other networking options that I should be thinking about?

You have a wrong idea about what the masterserver is, it relays connections and doesn’t do any game logic.
All clients connecting to the masterserver will receive a list of active games and thats it.
All it does then is relaying the connections.

Yep, you’re right - I was confused. So I’ll just use the master server to set people up with another person looking for a game.

Master Server = Game Lobby, allows players to find lists of games, other players to play with etc.
Authoritative Server = Game Server, runs the actual game and has control of the environment

Thanks, what resources for authoritative servers with Unity are there? I’m not making Words With Friends, but the security/cheating parallels are close.

For instance, with Words With Friends I envision that an authoritative server ensures that the submitted word was possible with the tiles that were actually given to the player previously. I am looking to do much the same kind of checking.

If you are just starting out and I am inferring from your statements and questions that you have no server implementation experience, I would suggest you investigate SmartFox. It’ll get you the biggest bang for your buck up front (actually, it’s free up to a certain number of users) with the least number of headaches. It can get you “from here to there” if you decide to deploy it in a live environment, but by that time, you may have other ideas of what you want from your server and have the experience and knowledge to evaluate those other options intelligently.

P.S. Other people will weigh in with other servers I am sure (this wouldn’t be a forum if they didn’t), but the question you want to ask yourself, and them, is “have you done this on a real game?”

As an addendum, you can of course run the logic on all machines simultaneously, remote players are treated as local players. If there is a disagreement, cheating is considered and then you take appropriate action such as disconnecting the session. Yes, it is open to abuse, but you would be surprised how many games actually do this without a server. Of course, without a server, you have issues of firewalls and all sorts of other fun. :slight_smile:

Yea, I have no server implementation experience. I have a decade of other professional programming experience though, so new APIs and technologies are no big deal. Usually when entering new territory I like to make sure I’m following the most up to date idioms and techniques rather than implementing something that turns out to be a less well thought out implementation of a common best practice.

Thanks for the pointer to SmartFox - I’ll check it out.