How to Create an Asynchronous Multiplayer Game

There’s no doubting the fact that “asynchronous” multiplayer gameplay, or the ability to play games one turn per session over the course of several days, is the new hot trend in mobile gaming. Many of the top multiplayer games are asynchronous, including the popular Words with Friends (a one-move-at-a-time implementation of Scrabble) and Draw Something (a unique take on Pictionary that was recently bought by Zynga for 200 million).

When my cross-platform multiplayer game, Hero Mages, launched on iOS, I thought people would be excited by the ability to play live online battles with their friends playing on PC’s or Android devices. To my surprise, the overwhelming feedback I got was “this game would totally rock if only it had async multiplayer!”

As most Hero Mages players know, I’m not one to disappoint- so I immediately restructured my priorities for the next game update to include asynchronous multiplayer. Having never programmed “async multiplayer” before, I figured I’d start like I always do: with a Google search. The returns for ” how to program async multiplayer” weren’t very helpful: I found articles talking about how async is awesome and learned about a great selection of titles that support it- but the key “how to” part was strangely absent. It then occurred to me “This would be a really great resource for game developers”, so I’ve decided to chronicle my development of async multiplayer for Hero Mages here on so that we can all benefit from what I hope will grow into a helpful “how to” series of articles.

Hero Mages is built using Adobe Flash, so my program code examples will be in ActionScript 3. The design and mechanics of async multiplayer, however, are applicable for any language.

Learn from the Masters

One of the best ways to learn how to program something new is to study an application that successfully achieves your desired result. My goal is to achieve asynchronous multiplayer gameplay for my fantasy themed turn-based tactical strategy game, Hero Mages. It just so happens there’s a similar game to Hero Mages on the App Store with a terrific implementation of async gameplay: Hero Academy by Robot Entertainment. So, I’ve spent some time the past couple weeks playing the game (what better way to do research) and I’ve got to give the developers serious props: their integration of social media such as Facebook and Twitter tied in with a very effective async multiplayer user interface does a very effective job at solving the “isolated community” dilemma one such as myself might experience in a “live online” multiplayer game.

Hero Academy Game Play

Multiplayer game list in Hero Academy

Here’s an overview of the async multiplayer in Hero Academy:

  1. Automatic login to servers upon launching game
  2. Invite/challenge players via Facebook and Twitter
  3. Option to create a new game or find a random opponent
    1. If player creates a new game, it gets added to an internal game list and waits for opponent to join
    2. If player opts to join game, a random game on the internal game list is selected and the player is connected. The joining player gets the first turn.
  4. Player can make up to 5 actions during their turn with the option to undo any or all of their choices before submitting their final commands.
  5. Once turn is submitted, database record of game is updated with new game state and a “Push” notification is sent to the opponent, indicating to them that it’s now their turn
  6. Opponent has 24 hours to complete their turn or the player can declare them as forfeit
  7. Player has the option to take turns in their next active game or return to their personal “Game list” which allows them to load any played game. Games are labeled with opponent, creation date, last move time, and status: victory, defeat, waiting for turn, ready to attack

Special Considerations for Hero Mages

Experimenting with Hero Academy provided a lot of insight into user experience of async multiplayer, but Hero Mages will need some specific considerations given its unique play mechanics:

  1. Hero Academy leverages an undo system which is great for async because players can experiment different move combinations before submitting their final choice. This works for Hero Academy because all damage is a fixed amount. Damage in Hero Mages, however, is calculated via dice rolls. Allowing an undo option isn’t feasible because it would affect a key play mechanic: chance.
  2. Hero Academy does not support live multiplayer. All of the moves and even player chat are communicated via database updates to the recorded game state. While it’s possible to play a game of Hero Academy with someone in the same room, the experience isn’t optimal because you have to wait for push notifications to go through and re-watch the animations your opponent already made when he commanded his units. An improvement to the system that would work well for Hero Mages would be the ability to restore a “live” game connection when both players are online- allowing you to see your opponents moves and communications being made in real-time.

How-to Create Async Multiplayer Development Outline

After  studying the user interface of Hero  Academy and carefully considering the special needs for Hero Mages, I came up with the following  steps that would be necessary to implement asynchronous multiplayer in my game:

  1. Create  a way to save the game state to an online database
  2. Write  a database query that loads a list of the player’s games and allows player to  load and restore a game session by clicking on an item in the list
  3. Upon  loading a game session, check to see if the session is currently available for  “live” play. If so, join the session in progress to connect with  opponents currently online. If not, create a “live” game room and  load the session.
  4. Devise  a way to replay any animations player did not “see” since their last  time playing the game session
  5. During  actual game play, write updates to the stored game state in the database each  time player issues an order (this differs from Hero Academy where you would wait until the end turn button is pressed  to update the database). By writing continuous, smaller updates to database  less bandwidth is used and the async-to-live play transition can be seamlessly  achieved.
  6. Find  a way to transition real-time gameplay elements (turn timer, drop timer, game  duration clock, AI turn controller) to async (unique challenge for Hero Mages, not applicable to all async  games)
  7. Design  a user interface for viewing and joining async multiplayer games
  8. Create  a match-making system that allows player to pick their army preferences,  preferred opponent type, etc. and matches player to games with available  opponents in database
  9. When  a game turn is complete, send a notification to next opponent via email or  device push notification indicating that it is now their turn to play

Async Game List UI Mockup for Hero Mages

Coming Next

Stay tuned for the next article in “How to Create an Asynchronous Multiplayer Game” where I’ll discuss saving game states to the online database.

About Ross Przybylski

Ross Przybylski is a game designer, Flash developer, and technical consultant. He is the founder of D20Studios, LLC and the creator of Hero Mages, a cross-platform, multiplayer strategy game. He is also the Director of Flash Development for Reflection Software, an innovative eLearning services provider company. You can learn more about Ross on his website and follow him on Twitter @RossD20Studios.
This entry was posted in Asynchronous Multiplayer, Game Development, Mobile Development and tagged , , , , , , . Bookmark the permalink.

6 Responses to How to Create an Asynchronous Multiplayer Game

  1. James says:

    Great article. I am anxiously waiting for this update 🙂 at the risk of bombarding you, there are some other excellent implementations of async on iOS that bear consideration. These are not tactical games like hero mages, but they are turn based and are probably the best implementations I have seen on the system to date. Carcassonne is the best overall asyn game IMHO, it has several extremely clever aspects to the way it handles async (which hero academy does not). Firstly, when you get a notification of your turn if you slide to view or tap this notification in notification centre it immediately takes you to the game that it’s your turn to take, rather than just opening the app. There are custom notification sounds which is a really nice, slick touch. The log in time from tapping the notification to being able to take your turn is also very fast, this is essential for async IMHO. Hero academy takes way too long to log in. Another nice touch in carc is that when a chat message is sent, this message is sent to the opponents as a notification also, and if you choose to tap the notification, you are again immediately taken right into that game. Another game worth checking out for its implementation I async is Ascension:chronicle of the fallen. A turn based deck building card game, this has a very slick interface on ios and performs similar functions to carc. This is deficient in a few areas however, a notable lack of chat, and also no “next game” button for games where you have turns waiting to be taken. Both of these games have a very nice touch that if your opponent logs in while you are taking your turn then you have a little signal to say that they are currently online so that you can seamlessly transition to a “live” game from async (in ascension there is a red/green traffic light an in carc the player tab becomes highlighted) I firmly believe that async is one of the best things that happened to gamin on iOS, I can honestly say that it has changed my video gaming habits immeasurably over the past year, an I know for a fact that it has had the same effect on some friends of mine too. I have a group of friends that I met online and we play async games pretty much every day. We have never met in person, but we talk and play all the time. Due to the nature of our geographical locations, “live” play is very difficult to coordinate (we live in uk, USA, Italy, Germany and Singapore) . Async on our iPhones has brought us a perfect way to play when and where we like to. Many thanks for taking the time I read this mammoth response, I hope that it helps in any way. Good luck with the development and I wish you all the luck on the AppStore! 🙂 James

  2. Ross Przybylski says:

    Thanks for the response, James. It sounds like Carcassonne is a step ahead of the rest in async gaming. I will have to check this out and see if I can add similar functionality to Hero Mages. I definitely think the transition to “live” play is important. I presume by your description then that Carcassonne updates your moves as they are made vs. something like the “5 actions per turn” in Hero Academy with the “undo” option?

  3. James says:

    In carc you place your tile wherever you want, but placement confirmation does not occur until you confirm whether you want to place one of your “meeples” or not. This acts as a nice “turn confirmation” which is always useful in turn based games, avoiding unforced errors.

  4. Ross Przybylski says:

    Ok, so a turn of carc equates to placing a piece on the game board and submitting turn. Makes sense. Hero Mages differs a bit in that you can issue several orders to multiple units in the same turn as well as playing cards. There’s a similar confirmation mechanism. It used to be that players had to click a separate “Confirm” button for each action, but this really slowed down gameplay (particularly on the browser based version) as well as confused many players. Whenever doing a demo at a convention, I’d have to keep repeating “Ok, now click the confirm button”. So, I replaced this mechanism with the “double tap” confirmation: Issue an order by tapping a target. A reticule then appears over target. Tap that target again to confirm. So where Hero Mages and carc both differ from Hero Academy is in the way actions write to database. For the former, you’d write commands as they are received (once command is issued and confirmed, it’s written to database). In Hero Academy, you can undo all five of your command before submitting your turn, allowing you to experiment with different outcomes (very fun for async play, but ineffective for live play transition since opponents have to wait until all commands are issued instead of seeing them in realtime).

  5. James says:

    One of the most recent async games I have been playing is by the makers of the previously mentioned ascension, called Nightfall. This is another slick async/live play turn based card game and I enjoy it immensely. However, one thing that I DEFINATELY don’t like is that during one of the turn phases, you have to “chain” your cards to bring them into play. Unfortunately at the moment, the game shows you all the moves made by the opponent. I.e they can place some cards down, then may change their mind and pick them up, place a different card or different order etc. this can carry on till the player is happy with their combination and then confirms their “chain” the problem is that I can see all of this, and it has a dreadful effect of slowin the turn down and also the added problem of me being able to see cards in the opponents hand that I would not normally see until my opponent chose to play them. So basically it’s nice to see the result but would be preferable if you didn’t/couldn’t see the “working” that occurred to get to it!

  6. Pingback: How to Create an Asynchronous Multiplayer Game Part 2: Saving the Game State to Online Database | Indie Flash Blog