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?

  • \$\begingroup\$ Oh, yeah, I forgot. I should've totally asked this there. Can a mod migrate this? \$\endgroup\$ – New2This Jun 9 '12 at 1:42
  • \$\begingroup\$ 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.) \$\endgroup\$ – Ken White Jun 9 '12 at 1:45
  • \$\begingroup\$ gamasutra.com/category/programming \$\endgroup\$ – selbie Jun 9 '12 at 1:49
  • \$\begingroup\$ Try Matt Buckland's book. He overuses templates, but it's still a good book \$\endgroup\$ – 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.


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

Take a look at Alive.

  • \$\begingroup\$ 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. \$\endgroup\$ – temporary_user_name Jun 9 '12 at 16:28
  • \$\begingroup\$ Searching for 'steering behaviours' on gamedev.stackexchange.com 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. \$\endgroup\$ – Exilyth Jun 9 '12 at 21:43

http://aiwisdom.com 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.

http://aigamedev.com is also a good resource.

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy