Saturday 2 July 2011

'AI' and Moore's Law: What happened?

My phone is well over fifty times faster than The STs and Amigas I started coding games for, the iPad2, faster still. Back at Bullfrog we made four games on those old ~8Mhz machines with several hundred NCPs, all 'doing their own thing'. They were of course just drawn with sprites and the 'AI' was just a few hundred lines of assembler or painstakingly optimised C, which can be pretty much the same thing if you're obsessive enough about looking at compiler output.

With a few notable exceptions, none of which I've played as they all look a little to fiddly to be my idea of fun, the number of NCPs just hasn't gone up like Moore's law says it might have. There are several possible reasons for this:

  1. People like to see extra processing power spent on more realistic models, proper physics etc.
  2. 10x the NCPs can require far more than a 10x speed increase: 100x100 = 10,000, 1000x1000 = 1,000,000 so could require a 100x speed increase.
  3. Over the last 20 years, vast amounts of that extra processing power have been pissed away on heavyweight C++ or, worse still, scripting languages.
Right or wrong we're pretty much ignoring all of these with Topia because we believe:
  1. If they are small enough on screen, characters don't need to be high-poly models. Physics doesn't need to be via a completely realistic, generalised system if your game doesn't require it.
  2. There are ways round the ' N squared' problem, pretty oldschool ways but they still work. There are almost certainly trendy new ways too but I'm not the sort of programmer...
  3. It's still possible, even in C++, to write this stuff in an optimal way if you resist the temptation to use all of it's cool features. That said, it could all be done in a higher level language on a bigger machine but we're aiming at phones and tablets here.
So Topia is a weird mix of old and new coding styles and, because of this, is doing a pretty good job of supporting several thousand NCPs, even on the iPhone 3gs.

Right now I'm in the middle of a rewrite of collision and physics systems that means everything can now react to everything else. The herd movement is a hell of a lot cooler than the last video, herds now flow around trees and scatter for predators. Video coming soon but here is a screen grab from earlier today:

1 comment:

  1. Nice stuff glenn, takes me back to bullfrog days!

    ReplyDelete