Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 am working on a shoot-up-game in XNA, it is going to be my final project in school. I was thinking of utilizing the minimax algorithm for AI agents for making tactics. However, I realized that the most important issue in such a game is to avoid bullets(fired by the player). An AI agent making tactics but no good at avoiding bullets would be useless in a shoot-em-up game I guess.

So, I need your help about what algorithm to utilize. It's not going to be a bullet storm like game, but it's fast(thanks to XNA). I have read about using threat maps and also pathfinding algorithms but couldn't figure out which one is ideal in such a game. I mean it needs to be simple enough for a fast paced gameplay, but it should also help AI agents act intelligently.

share|improve this question
This question might be of interest for you. Maybe it's even a duplicate of yours. – bummzack Apr 28 '12 at 13:04

You could just keep it simple. Create a frustum (smaller than view frustum) to calculate a sort of target area for the player. If the enemy is in that frustum, they should stay in cover (for a period of time, not forever). Then make sure you're A.I. always try to spread out.

If they are always trying to use some tactics then you should be able to find out where you want them to be and create a path for them to that point. So they will always be trying to follow their path to that point. If you use the frustum to tell them to take cover then it could look effective. They move a bit along the path, then their in sight so they instantly take cover.

It should be smart enough to look compelling, but dump enough to give the player plenty of time to shoot them. Also, if their popping up when your not looking, it means it will drive the player to look around a lot, which will add to the sense of vertigo in your fast paced shooter.

The main problem, I think, will be keeping a track of the nearest bit of effective cover to get them to run to when their being aimed at.

share|improve this answer

I don't think you've got your answer since you're asking about dodging bullets (and not general avoidance ai behaviour).

There are many simple ways to deal with that, each one is appropriate for a different scenario.

1- trace a ray from all bullets towards their respective progrades and with the ray magnitude (distance) relative to their velocity PLUS (or TIMES) the inverse of a 'response time' factor. If the ray hits an enemy, you get they outta the way. (MEDIUM SPEED BULLETS)

2- trace a ray(/triangleish/coneish shape if there's spread) from the weapon when the player shoots. If there's an enemy there, move him outta the way. (HIGH SPEED BULLETS)

3- if the bullets are really slow, you could simply loop all of them for each enemy and determine their positions in the future, and add to that the velocity vector of the current enemy being looped, consider a reasonable response time and threshold, if the positions are similar, then don't move the enemy there OR move the enemy outta there. (LOW SPEED BULLETS)

P.S.: I'm assuming you're using a physics engine (box2d, etc) for the 1st and 2nd items.

if the bullets doesn't have 'speed', but are simply raytraces (instantly hits anything), then there's no way other than using the direction the player is facing to somehow determine that (see OriginalDaemon's answer).

share|improve this answer

You should use a combination of Steering Behaviours and speed fluctuation if you want your AI to be able to dodge bullets. It will not be perfect so maybet it will be the right tool.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.