Tuesday, November 10, 2009

Snow Leopard: essential for developers

Why? Nothing to do with 64-bitness. The reason every iPhone developer must have Snow Leopard is STATIC ANALYSIS! Shift-Option-A does Build-And-Analyze, which uncovers more mistakes than you thought it possible you could make, especially in the iPhone environment where memory management is strictly by reference count, no garbage collection. A run through this and testing with the Leaks instrument becomes a formality. If you're working on a non-Intel Mac (or one that can't run Snow Leopard for some other reason) go buy one right now. The time you save will easily cover the cost of a mini and possibly even a Pro.

Sunday, October 25, 2009

Approval

So the email came from Apple and the application is live on the store, which is great. It took about 9 days to be approved, certainly not what I had expected - in fact I had almost expected rejection or demand for a higher rating since a player who so wishes could spell all kinds of naughty words given the right set of random letters. Other application developers have come across this problem apparently just because their apps could access someone else's content - like a web page or an eBook.

Writing this thing was fun but not as easy as first thought. Or to be more accurate doing it so that it was fast enough to play was difficult. The SOWPODS word list is very large, 2.8MB of text, which takes an appreciable time to load into the application even before processing begins. Many words are greater than 9 letters so since this game only deals with words of 9 letters or less the word list can be made smaller without affecting the game at all.

Calculating the solution for a random word and key letter was an interesting problem. At first it seems easy. The method is fairly well-known and involves sorting every word in the word list, sorting every possible word from the puzzle word and looking for the intersection. First problem - using arrays for this is very slow since looking for the word can involve hundreds of thousands of comparisons and that task is multiplied by the number of words in the dictionary. Second problem, if "LILT" is a word in the solution then so is "TILL" - you can't just stop looking after the first match. The advantage of calculating the whole solution in a background thread is that once done the complete solution is available at any time and it makes response better when checking words as they are built letter-by-letter.

Tuesday, October 13, 2009

App store submission


I've been doing these puzzles for years, sometimes it takes a few seconds to get the nine-letter word and sometimes I only think of it 20 minutes later when I have given up and am doing something else.
Months ago when I was looking for something to do as a Cocoa programming exercise I started doing an anagram solving engine and it worked. Months later, here's the first release of my first iPhone application, Gridagrams.
It's basic. It's simple. But I think people who like this sort of thing will like it a lot. If you just want word, and plenty of them, this is it.
If you're wondering what the slightly fuzzy background image is supposed to be, it is reversed newsprint - a fairly simple attempt to hint at the puzzle's newspapery origins. I should have done a lot more image tweaking such as making the grid and the letters just a tiny bit ragged to look like newsprint too but you can go too far.