Advertisement

2D Top Down Space Shooter AI

Started by September 08, 2010 10:29 AM
4 comments, last by Whorse 14 years, 2 months ago
Hey there all, I'm busy working on a 2D top down space shooter for my portfolio using XNA. I was wondering if anyone could give me ideas on how the AI's shooting is handled. I've done the movements and spawning already. Would you just get them to fire a volley of shots at random intervals, or is there usually a more complex method?

Cheers
Quote: Would you just get them to fire a volley of shots at random intervals, or is there usually a more complex method?


Short answer... depends on what you want. That decision is not an AI one but rather a design decision.

For a more-detailed answer on the AI portion, there are two approaches that can be solved almost simultaneously.

First method: Explain the problem in detail to us. Include the types of information that are available from the object library that the AI can use to reason on. Then, explain how you might be able to use that information as part of your decision process. Also include how you would like the AI to look like it is behaving.

Second method: After writing up the information in the first method, sit back and realize that you can do a lot of this yourself just by doing one simple task at a time using the above through process.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement
You say you have movement done. What do you do to move the AI? Shouldn't how they move be directly related to how they shoot?

As an easy first approximation I could see using a few different types of AI one that tries to predict movement, one that shoots where the player is now, random etc. Kind of like packman.

Most current shooters don't have AIs they have enemies that shoot and move in patterns, and enemy creation is entirely predetermined.
This probably was the wrong place to post my question, it is more of a design question.

What, in your experience would be a better idea? The enemies already move sideways a certain amount of pixels, if they either hit the left or right boundaries, or collide with another enemy they change directions. Would random firing patterns suit this style of enemy movement, or have the enemies firing based on the player being within line of site?
Shooting from the hip here...

If the player is anywhere within +/-n pixels of your direct LOS, fire.
If the player is to the left of you and is moving right, fire.
If the player is to the right of you and is moving left, fire.

With those 3 rules, your enemies will fire on and off but at reasonable-looking times. It also has the tendency to fence the player in slightly making him dodge between the bullets.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Thank you very much InnocuousFox you answered my question perfectly. I'll work on implementing that tonight, and get back to ya'll with the results.

This topic is closed to new replies.

Advertisement