Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing my first 2D game, and I'm writing some tracking logic for the computer enemies. Basic follow-the-player tracking was easy, but ineffectual. Too easy to escape. So I'm trying to implement some more sophisticated flanking and other tactics, and (as expected) it's pretty tricky. This is a topic I know nothing about.

I'm going to keep trying, but it'd be awesome to have some examples or tips to work off of.

Is there any place that has a decent set of pseudocode AI algorithms, or tips or advice on the subject, e.g. for 2D tracking?

share|improve this question

migrated from Jun 9 '12 at 4:54

This question came from our site for professional and enthusiast programmers.

Oh, yeah, I forgot. I should've totally asked this there. Can a mod migrate this? – New2This Jun 9 '12 at 1:42
Just flagged it for a mod to review. Hopefully they'll help shortly. :-) Good luck. (Just for future reference: StackOverflow is not a link engine - questions about where to find things aren't appropriate to ask here.) – Ken White Jun 9 '12 at 1:45 – selbie Jun 9 '12 at 1:49
Try Matt Buckland's book. He overuses templates, but it's still a good book – bobobobo Jun 10 '12 at 23:14

A great book is Artificial Intelligence for Games, Second Edition, and you can find the code repository here.

share|improve this answer

What kind of game logic are you looking for? Pathfinding? FSM? Genre-specific logic (RTS, FPS)?

Take a look at Alive.

share|improve this answer
At the moment I happen to be seeking (As I said?) 2D tracking logic . . . like to make a computer enemy effectively chase the player. Alive isn't really what I was looking for...I'm hoping for help in algorithm design. I can't even really tell what Alive is from it's very poor project description. Thanks anyway though. – Aerovistae Jun 9 '12 at 16:28
Searching for 'steering behaviours' on might help. The steering behaviours can be combined to form more complex behaviour, e.g. flanking would be avoiding the player while moving towards a spot besides the player. – sarahm Jun 9 '12 at 21:43 is run by Steve Rabin, an accomplished game logic engineer (editor for the AI Game Wisdom series of books, and coordinator for the AI dev panels at GDC). Unfortunately it mostly just contains summaries of the articles in the books themselves, which can be a bit hard to get a hold of these days. That said, if you can get a copy of the books, they are quite excellent. is also a good resource.

I also agree with integeruser's answer. The book he mentions is quite good for someone just starting out.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.