Sign in to follow this  

AI in 2003

Recommended Posts

How would I create a simple ai for an enemy ship in a game like space invaders, insteaded of just having it randomly fire and move back and forth across the screen. I want the ship to be able to think a little bit, instead of being stuck on a predictable track... (Note: I have no experience in A.I)

Share this post

Link to post
Share on other sites
Here's what I would do.

First off make the ship try to always turn towards you. (so have the AI do math, find out what direction you are and start turning in that directions)

Then next thing to do is if aiming in the same direction fire the engine up.

Finally if in range shoot.

This will give an ultra simple but possibly suprisingly hard to beat enemy. Then you can work a little more, having the engine fire before you turn to the right direction and so on, but essentially your first ai after random, should be something like this.

If you want to weaken the enemy, make it random if it turns in the right direction or does the right move. If you want to make it harder, make it shoot more often. so on. This is a basic AI, if you want a more difficult one you can figure out what you want. If you want an impossible one, you can make it learn from mistakes but that seems needless at this point.

EDIT for more info on minor AI theory:

All base AI is, is states and math, prediction, and at the root, state analysis. Trying to figure out what to do based on the situation. You don't want to give it too many options in a certain areas, but if theres two good options you can give it a random choice (it doesn't have to be 50 50, it can be 70 30, what ever you want, and it doesn't have to be two options, you can have 10 options and if no situation fits do a random move)

Basically then what you should do is watch the AI and improve it slowly where you see it making it's big mistakes. Don't make huge jumps unless your definate of problems, you want to slowly increase it over and over, making sure the mistakes it makes slowly shrinks. The randomness should return if your AI is perfect, but that's a while off, just remember having a random move is not bad in an AI, as it allows more humanistic behavior but it's good to only use that sparingly.

Best way to make an AI is figure out what type of game you have (sounds like you have a live action game so long thought paterns is less attractive) and build it in that direction it shouldn't be too hard to get used to.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this