07 April 2016

Game Center With a Bad Network

I got a question about Game Center and network connectivity, and thought I’d share my thoughts publicly, since this was a major issue we had to deal with at Shenandoah Studio when we did multiplayer for Battle of the Bulge, Drive on Moscow, and Desert Fox.

Basically, the issue stems from loss of internet connection during a turn: at the end of a turn we save the state of the game board (locally, to PlayerPrefs), and use an End Turn method to communicate to Game Center that the turn is over.

If there’s no internet connection, the game state is saved but the end of turn message never gets sent (Android is awesome in the sense that end of turn messages are cached if the user has no internet connection, and sent when there is).

That is awesome, if it handles all network errors and not just lack of internet.

 So my question here is really, how do you gracefully handle a loss of internet connection? The only solution we have is to test for a connection prior to saving/ending the turn and present a pop-up advising the player to connect to the internet (otherwise, their turn is held in that state).

This one is enormously tricky with Game Center, because it has no guaranteed delivery.

First, I would not check for any specific error, because you can have anything at all go wrong during networking. (“No internet” might be worth a special test just because the player can deal with it by turning on WiFi or whatever, but it’s the least of your problems.)

Basically, you need to send the turn to Game Center and check for an error when your completion handler is called. If there’s failure, you need to do your own saving, and then send the update again later.

The problem is, you can get false negatives. Did you get a timeout because your network was so slow or noisy that the packet could not be delivered to Game Center? Or was the timeout because the “yes, turn received” acknowledgement from Game Center timed out? This is critical because the other player will have gotten the turn, and may have sent their own by the time you get to repost. So you also need some sort of logic to handle posting a stale turn.

To test your code, you’ll want to use the Network Link Conditioner (enable this in the Developer settings on the device). This lets you simulate a terrible network. Just be sure to disable it when you want to actually do anything (it’s all too easy to forget and wonder what’s wrong with your phone).

28 July 2015

King of Dragon Pass is on Steam!

I originally created King of Dragon Pass mostly with a Mac, and all of the iOS adaptation used a Mac. But the original game ran only under Mac Classic, so I haven’t been able to play the game on a Mac since Apple removed Classic support. So I’m really happy that HeroCraft is bringing the game back to Mac OS X. King of Dragon Pass for Windows and Mac is now available on Steam! (You can also discuss it in the Steam Community.)

I’ve talked more about King of Dragon Pass at the Development Blog over the past few  years.

03 November 2012

iPad mini first thoughts

I’ve had the new iPad mini for about a day, and have been trying to use it whenever practical (I got the WiFi model so I can’t use it in the car).

My main impression continues to be: it is very light. Partly that’s because I’ve sort of been trained to know how heavy an iPad is: 1.46 pounds (662 g) for my current 3rd generation device. My mini is 0.68 pound (308 g). Somehow it feels almost the same as the iPhone 5, which is 3.95 ounces (112 grams). I’m not sure how to explain that, other than the iPhone 5 always feels really light too, and they must be about the same density. Light is good, and I can’t wait to use it on the subway (the iPad has always been a little tricky to hold while standing and holding on to a rail).

The other thing that is the same is pixel size. It’s true that the iPhone 5 has a retina display and the mini doesn’t. But the mini has exactly the same pixel density as the original iPhone, and the recent iPhones really have the same pixels in terms of layout (the pixels are just capable of better detail).

So buttons, text, any screen element you need to interact with is the same size (in millimetres) on iPad mini and on any iPhone. The basic pixels are the same size, you just have more of them.

By contrast, the iPad (3rd or 4th generation) is blown up slightly, as well as having better pixels.

What this means is that text isn’t as crisp as the iPad retina display, but it does seem better than the iPad 2 (it is smaller but harder to make out the pixels).

I think less expensive and lighter are going to make this the device to recommend to most people. I’m still waiting to see how it works on the commute to have a final judgement for myself. I do think Apple has another winner.

30 August 2011

King of Dragon Pass Is In Review

The iPhone game I’ve been working on is now waiting for review in the App Store!

I originally created King of Dragon Pass for Windows and Mac, but have been porting it to iOS. It’s optimized for the screen size of an iPhone or iPod touch, but runs fine on iPad.

28 February 2011

Review: Seized

Seized: A Sea Captain’s Adventures Battling Soundrels and Pirates While Recovering Stolen Ships in the World’s Most Troubled Waters — with a subtitle like that, do I really need to say more?

This is in fact a first-person account of an honest captain’s dealings with the seamier side of the modern shipping business. In some ports around the world, people abuse local law and make fraudulent claims against ships. The crew (and owner) often have little recourse. Captain Max hated the idea of his ship being stolen by a bogus claim, and managed to get it out of port. He was later called on to do the same.

At other times in his career, he acts as a ship broker, again dealing with locals who may not have quite the same respect for law as he does. In fact, he even uses the law as a weapon in one case.

As a book, I found Seized well-written and interesting. As a gamer, I immediately wanted to make use of it in a game. Surely the players’s spaceship should dock at an outlaw port! And Captain Max might have made a Climb roll or two, but typically he solved problems with his wide array of contacts, his ability to judge people, and his broad knowledge of ships.

It’s the last one that makes me reconsider game scenarios based on Seized. While any reasonable game doesn’t require a player to have the same knowledge as his character, there’s a difference between not knowing what a MacGregor hatch cover is, and knowing that your character knows about their pros and cons of one, and how they may impact his actions. Without sea-going experience, I think it would just be too hard to have a game that revolved around the intricacies of JB Weld.

But again, that sort of thing works fine in a book. Hardberger always explains things so us landlubbers can understand. And the events in the book are always dramatic, because there is always a very real chance of failure (indeed, he recounts stories when things did not end up going well).

Another issue with game scenarios is that I’d been running a Diaspora game, where a spaceship visits a small number of ports. Many of the outlaw ports in Seized can get away with it because a ship may only visit once even if all goes well. In a smaller cluster, ports have a much greater interest in ships returning — there won’t always be another sucker.

A recommended read, and even if I can’t easily duplicate Captain Max’s adventures, there probably will be corrupt judges in one of my future games.

05 February 2011

Review: A History of the World in 6 Glasses

Since I enjoyed Tom Standage’s The Victorian Internet, I picked up A History of the World in 6 Glasses. This covers the history of the six beverages that “chart the flow of world history:” beer, wine, distilled spirits, coffee, tea, and Coca-Cola.

Most of the book was about the history of the drinks, and how they were regarded at the time (for example, Native Americans didn’t want to drink unless they could get drunk). The section I found most interesting was about how tea (and its monopolist, the British East India Company) was a major cause of American independence (the famous Boston Tea Party was the result of a law dictated by the company).

An interesting read, recommended.