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.

13 December 2010

Reviews: Debugging and Write Portable Code

Two books I bought recently were ones I expected to be easy going. They were, but I think they were still worthwhile.

Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems by David J Agans is about, well, debugging. Anything, not just software. It’s full of war stories from many domains (including cars, houses, and Sesame Street). The rules are how to logically approach problem solving, and make sure the problem is actually solved (rule 9). Most of it is common sense, but it doesn’t hurt to see it distilled. And based on the war stories, it’s easy to get wrong. Of potential use to non-developers: there’s a chapter on applying the 9 rules from the Help Desk, when you can't observe directly.

Interestingly, one of his war stories was kind of mentioned in...





Write Portable Code by Brian Hook. I’d had some dealings with Brian when I was at GameHouse, so I knew he knew his stuff. This book too was largely review (I’ve had to deal with getting code to run on different processors and compilers), but again it’s nice to have things spelled out sometimes. And I’d never heard of compile-time asserts or #pragma STDC before. Some of it’s a bit dated (version control in particular — and it must have been written right before the Mac Intel transition), but much of it is stuff you’d still have to deal with when moving between Mac and Windows — or even Mac and iOS. (Scalability is one aspect of portability.)

12 December 2010

High-Bandwidth Sneakernet

I love the plan to deal with the huge amounts of data expected from a proposed black hole imaging project. Each station will create about 22 terabytes of raw data per day. “No imaginable link from remote mountaintops permits live telemetry of such a torrent. Astronomers will physically pull eight-pack cartridges of disk drives from the data recorders. ‘We’ll mail them,’ says Doelman. ‘You can’t beat the bandwidth of a 747 packed with hard drives.’”

09 December 2010

iPad Data Gotcha

Just spent way too much time on the phone with AT&T. I haven’t completely resolved problems I was having with cellular access for my iPad, but I can give a warning: be 100% sure your email address is correct.

If it’s not, you won’t be able to log in again (since it’s your account name). And you won’t be able to retrieve a lost password, even with the web form that asks for IMEI and ICCID, because it’s sent to the wrong address. Nor can AT&T change it for you. And you won’t be able to stop automatic billing.

The whole idea of having plans that purport to be by the month, but expire, seems pretty lame, and is ultimately responsible for my problems. But that’s perhaps the topic of another post.

06 August 2010

Predecessor to DiceBook

I had a reason to open up my Newton, and realized that I had written a dice roller for that platform. No PDF viewing, but it provided simplicity and easy configuration. (I apologize for the poor photograph — I can’t remember how to take a screen capture from the device.)

I don’t remember if this was ever distributed — there certainly wasn’t an App Store in those days!

29 July 2010

DiceBook Now Available for iPad

Just a quick note that I’ve finally gotten through the App Store approval process, and the ~4 hour wait to have the app show up in the store…

DiceBook is a specialized PDF reader that includes a flexible dice roller. It’s designed to be used with rolepaying games (like Dungeons & Dragons, HeroQuest, or Spirit of the Century). You can make dice rolls without leaving the app (so it should be useful even when iPad gets fast app switching).

Learn more from the DiceBook web site, or go right to the App Store.

30 June 2010

Apple Recycling Redux

I decided to upgrade my iPad to a model with 3G wireless (so I could access maps in the car if need be), so I was once again able to avail myself of the Apple Recycling Program. This time, I shipped off a Radius color pivoting monitor and another Power computer, both probably dating from 1998. Total shipping weight: 92 pounds. Shipping weight of the iPad: 3.3 pounds (about 1/28 as much).

So if you’re on the fence about getting an iPad, think about it as a great way to clean out your closet!

22 June 2010

Is the Future the Past?

One thing that struck me about John Siracusa’s interesting article on Apple’s language and API future: Apple did a high-level language once before. NewtonScript.

Whenever I see Python or Lua code, I think back to when I was coding in NewtonScript, which had a similar syntax and similar concepts. Here’s a bit of code from the original implementation of Jigami:


regTile := {_proto: pt_Tile, _parent: self, viewBounds: RelBounds(11, 112, 34, 34)};
regTile.edges := pt_Tile.possibleEdges[tileNum];
regTile:CalcEdges();
regTile.symbols := NIL;

There was also a visual design tool, Newton ToolKit (NTK). The combination of a dynamic language, no pointers, and a graphical editor was quite productive. And NewtonScript was good enough to use for all of the system apps. Yes, there was a little C++ code in parts, but a lot of it was probably premature optimization (there was nothing like Shark or Instruments for Newton).

I don’t know what direction Apple is moving, but at the very least it’s an interesting proof of concept for something that works well in a mobile device.

17 June 2010

Phishing Is For Phones Now?

I think I just got a phishing phone call on my cell phone, from 707-703-4722 (though of course caller ID is easy to spoof). I think it was from Cascade Bank about my credit card. Thing is, I don't have one from them (to my knowledge at least). I didn't enter my credit card # when asked…

To make it even more suspicious, it was a computer-synthesized female voice, though they mentioned something about recording the call.

This has never happened to me before, so I reported it to http://phonephishing.info/report/.

13 June 2010

WWDC Thoughts

Others have reported already, and everything except the keynote is covered by nondisclosure. But here are a few random thoughts on Apple’s Worldwide Developers Conference, held last week in San Francisco.

Apple made it very hard to plan — about 6 weeks notice. Luckily my employer, Rogue Amoeba, was waiting to pounce, because the event sold out in only 8 days.

I’ve been to the conference a number of times (I think my first was 1989), so I knew I’d be getting a t-shirt, and packed accordingly. Except this year they no longer handed out a t-shirt and a bag (sadly I didn’t go last year, when they handed out a slim laptop backpack). This year it was a lightweight jacket. This was actually pretty useful, given the temperature, but meant I had to get my own WWDC shirt so I didn’t stink on Friday.

Oddly, unwashed developer wasn’t something I noticed. I did however have to sit through a session next to someone with bad breath, someone smelling of alcohol (in a 09:00 session), and a smoker.

It was pretty obvious from the event list going in that it was going to be an iPhone-centric show. Apple doesn’t release all the event names until after the keynote, so I had some hopes that there would be a little more Macintosh content. Sadly, there wasn’t. On the other hand, I did manage to get to one session (the last one as it happened) that was directly helpful to my current work on Pulsar.

More surprising was the number of women. There are never a lot (you inevitably hear someone joking about the lines for the men’s toilet and the lack of line for the women’s), but this year seemed worse than I remember. Perhaps I was especially surprised because the very capable programmer I hired to do an iPhone game while at GameHouse was a woman.

Overall numbers seemed bigger than I recalled from 2 years ago as well. I remember lining up for the keynote, but I didn’t remember having to line up for other sessions — and some of these lines snaked around two corners.

I believe the conference cost significantly more this year ($1600), but the amenities seemed cut back. I already mentioned the reduction in attendee premium. There was also no reception, and no espresso bars inside Moscone. And the Beer Bash didn’t serve sushi.

We also got nothing at registration except the jacket and badge. Going paperless seemed reasonable though, because there was a custom application (apparently this was first available last year). It had some usability problems, and crashed relatively often. It was handy to have on both my iPhone and iPad despite that.

Speaking of iPad, this year I decided to try leaving my laptop home and using just an iPad (with Bluetooth keyboard) to take notes. This made it the first year I didn’t have to worry about keeping my battery charged (although several of the session rooms had electrical outlets attached to the seats, a great feature I made use of 2 years ago). I plan on discussing this more in a later post.

All in all, I found the week worthwhile, though I would have liked more on Macintosh.

28 April 2010

Apple Recycling Program

One of the cool things about getting an iPad was that it qualified me for Apple Recycling. I can get rid of two computers, monitors, or printers in a responsible fashion.

I went with some of the biggest and heaviest stuff, which has long been out of service (the computer was one we used on King of Dragon Pass, released in 1999, and the printer was introduced in 1993).

So by buying 2622 cc worth of tablet (by box size), I get rid of 222400 cc worth of obsolete hardware. For free (Apple pays shipping)! Not a bad deal.

17 April 2010

iPad Case

Whenever I get a new portable device, it seems like I have to get a new case.*

I just got an iPad, and while I suspect it will be pretty rugged, putting it in my laptop case seemed like overkill — it rattles around.

After a little online research, I decided on the “iPad Suede Sleeve” from CaseCrown.

And then I didn’t buy it, because their stupid web site makes you register. Hello CaseCrown! I want to buy one item for my one device. Just let me buy the damn thing!

However, I wasn’t able to find another case that I liked any better, so I finally bit the bullet and bought it. Sight unseen, but $20 with free shipping seemed like a good deal.

The case came promptly. It fits pretty well (it could be a little smaller) and seems well made. The sides are padded, though I imagine if I ever drop it, the corners will be what hits. There’s a side pouch, which ought to hold the charger or a paperback book.

I have used it once so far, and wonder if I made a minor mistake in not getting the similar CaseCrown Protective Sleeve, which has a strap. After 5 minutes of walking with the case in my hand, it started to feel heavy. On the other hand, a strap for such a small device seems a bit silly, and this case is small enough to toss in a backpack.

Obviously choice of case is a personal matter, but I recommend this one.

* The only exception has been my iPhone. It fits in my pocket so well that I don’t want to bulk it up with a case.

06 April 2010

Proper Names in SCRABBLE?

Supposedly the UK edition of SCRABBLE will allow proper names.

This seems seriously broken, because there’s really no way to know what’s legal or not.

Yeah, the argument about having to memorize SOWPODS has validity, but what will be the arbiter of what’s legal? More proper names get created all the time. And what languages are you restricting this to? Who’s to know what all the last names in Croatia (or Tonga) are.

Essentially, it will become a word game that has nothing to do with words. To me, those are a lot less fun because they’re totally arbitrary.

30 March 2010

Improving iPhone Security

Since my iPhone has email and a bunch of other sensitive information on it, I’ve always set a passcode. But I’ve always been a bit dubious about the security of a 4-digit code. In fact, one of my coworkers once saw what I entered as we were walking down the street. While I’m not really worried about coworkers, and 10000 possibilities might be enough given there’s an Erase Data option, I still wanted more security — especially once I get an iPad and may have more data on it.

Enter iPhone Configuration Utility. While this has a wide variety of enterprise options, it’s actually easy to make a simple profile.

Download and install the utility (there’s also a Windows version). Launch it, and click “Configuration Profiles” in the left pane. Click “New” in the toolbar. Enter a name and ID in the “General” section, then click “Passcode.” Now you can set up a more secure passcode — more than 4 characters, letters as well as numbers, etc. (You don’t actually choose the passcode here.)

Then attach your iPhone via USB. Click it in the left pane. Click the “Configuration Profile” tab, then click the “Install” button for your new profile. You’ll confirm this on the device.

Now you can set up a passcode as usual, in Settings > General > Passcode Lock.

Now when you unlock the screen, you’ll get a full keyboard instead of a 10-digit pad. Note that you’ll still be able to make emergency calls (911) without unlocking.