views:

38

answers:

1

I am trying to create a Pacman AI for the iPhone, not the Ghost AI, but Pacman himself. I am using A* for pathfinding and I have a very simple app up and running which calculates the shortest path between 2 tiles on the game board avoiding walls.

So running 1 function to calculate a path between 2 points is easy. Once the function reaches the goalNode I can traverse the path backwards via each tiles 'parentNode' property and create the animations needed. But in the actual game, the state is constantly changing and thus the path and animations will have to too. I am new to game programming so I'm not really sure the best way to implement this.

Should I create a NSOperation that runs in the background and constantly calculates a goalNode and the best path to it given the current state of the game? This thread will also have to notify the main thread at certain points and give it information. The question is what?

At what points should I notify the main thread?

What data should I notify the main thread with?

...or am I way off all together?

Any guidance is much appreciated.

A: 

Slightly unrelated, but have you seen the ASIPathFinder framework? Might help if you have more advanced pathfinding needs.

Joost Schuur