Sunday 21 March 2010
ASIPathFinder - cooperative path finding for real-time strategy games
I had great fun building Space Harvest, and learned a massive amount. However, as with any project in which you have very little existing expertise, there were a couple of tricky areas. I spent many evenings banging my head against the wall, wondering if I’d ever get something out the door.
I had never written a full game before this, and, in hindsight, probably didn’t choose the simplest place to start with an RTS game. Broadly speaking, there were two things I found especially difficult, path finding, and performance.
I‘d like to write a post with some tips for improving performance in games for iPhone OS (with a particular focus on the amazing Cocos2d for iPhone framework) a bit later this week.
First though, path finding.
What is path finding?
Path finding is what units in Space Harvest do to find their way around the map. In basic terms, they look at where they want to get to, see if there are any obstacles in their path, and, if so, try to find a way around them.
Cooperative path finding takes this a bit further - units plan their path in advance, letting other units on the same team know where they’re likely to be in future. This way, units can plan to avoid each other before they collide.
So, it turns out that a) this is incredibly difficult to get right, and b) it’s even more difficult to get right in a frame-rate-friendly fashion on a relatively slow device like the iPhone / iPhone 3G.
So, I’ve decided to open source the path finding code I wrote for Space Harvest. In keeping with my tradition of releasing software with names that don’t exactly trip off the tongue, it’s called ASIPathFinder. An overview is available here, and the source is on Github.
Posted by Ben @ 3:57 PM