Turn Based Mobile game

Started by
5 comments, last by SoulRyder 11 years, 1 month ago

Hello,

I am working on a game created in Unity3D and I am familiar with programming for games, but I have never really worked on network functionality for any kind of multiplayer before. And I would like to have some advice how to start with this. I am the only programmer in our team, and even though most programming problems I always see as a challenge, to be honest working with networking always seems a bit more difficult and scary to me.

The multiplayer functionality of the game works somehow similar to Wordfeud or Draw Something. A turn based game where you can challenge friends or random players to play a game with you. Everytime someone makes his/her move, confirm it, and then the other player makes his/her move etc.

Now I was first looking into network engines like Photon, but someone told me I would be better off, and alot cheaper if I just work with databases. But I am wondering if you have alot of players on those databases, wouldnt you still need some sort of big server where all players can connect to?

I have some experience with databases concerning webdesign, but nothing in the field of games. So what I am looking for is some tips sending me in the right direction into creating a turn based game for android and ios in unity3D

Thanks alot in advance!

Alexander

Alexander Sarton

Co - Founder / Producer @ Barrelman Games
Advertisement
For a turn based game, you need three things:

1) A way to store the state of the game between turns.
2) A way for a client to see the current state and provide new state.
3) A way to tell the "waiting" player that it's now "their turn."

The first one is typically solved with a database -- MySQL, Redis, Oracle, even flat files on disk could work. The database is talked to by your game server, which knows how to enforce rules and protect the data against bad actors on the internet.

The second one is typically solved with an application server. For a shooter game, you'll have a custom game server with high packet rates. For a turn-based game, you can use a web server using HTTP GET/POST.

The third one is tricky, and depends on the speed of the game. You can use HTTP long-polling (COMET) if you want quick notifications to online players, at the cost of higher load. You can use web sockets if you have a modern browser. You can use occasional polling by the client application if a slower response is OK, but that will still generate load based on the number of online players, not based on the number of turns. You can use another notification mechanism, like SMS messages or email. Or, finally, you could use regular old-school sockets if your client and your server has this ability (websockets are similar to this.)
enum Bool { True, False, FileNotFound };
For #3 above, I'd recommend a combination of COMET for those who are currently online, along with an intermittent low-cost poll (perhaps hourly) for those who are offline.

Now I was first looking into network engines like Photon, but someone told me I would be better off, and alot cheaper if I just work with databases. But I am wondering if you have alot of players on those databases, wouldnt you still need some sort of big server where all players can connect to?

This part is a business decision.

Photon is free(*) up to 100 concurrent users (* as long as you meet the other conditions like <$10K/month). SO if it helps you out right now it may be worth it. 100 concurrent users can equate to thousands of daily active users. If you hit thousands of daily users hopefully you will have enough revenue to cover the $99 indie cost.

If your goal is a learning experiment to figure out how the technology works then by all means roll your own. If you are looking for an inexpensive middleware solution, Photon is a fairly reasonable choice.

I looked into this a little (not using Unity, but I don't think that makes much difference), and I decided my best bet would be to use either GameCenter for simplicity and just accept that an Android port will be not possible, or to use a Backend-As-A-Service provider.

I found this article fairly useful http://www.raywenderlich.com/20482/how-to-choose-the-best-backend-provider-for-your-ios-app-parse-vs-stackmob-vs-appcelerator-cloud-and-more which tallied well with my impression that Parse looks like the best of the bunch. I haven't started any implementation yet though so can't comment on what it's actually like.

My decision to use BAAS providers was influenced by my inexperience in implementing code for, or even setting up any sort of back-end. Sounds like you have more experience than me in that regard, so not necessarily the right choice for you.

If you are working on an indie mobile title like wordfeud then you do not need your own server. You can go with a cloud soulution. I too have used Parse and managed to get a simple words with friends clone working in a couple of hours. I am currently working on a turn based scorched earth / worms type game for a client and so far it hasn't let me down.

There are many others besides Parse some of whom advertise in the banner at the top of this very website. Most of these services use schemaless databases and also if you don't like the service you can usually drop your data into a CSV and upload it to an alternative service with no fuss.

Personally i would just use a solid webhost that serves JSON (writing a python, php or asp.net script for this is extremely easy) data and send notifications using GCM and APNs when it is the players turn. (The app can then just pull state updates from the webserver)

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Wow thanks alot for all the replys! Im definitly helped with this and will look into all options and find out which option works best for me! :D

Alexander Sarton

Co - Founder / Producer @ Barrelman Games

This topic is closed to new replies.

Advertisement