Any tips for fighting game A.I. ?

Started by
5 comments, last by Christer Ericson 16 years ago
I'm making a simple 2d fighter (street fighter style), and am looking for any tips on how to make a dynamic, natural looking A.I. My approach is create an opponent that is as indestructible as possible while still obeying all the game rules, so as a base it can be scaled back to any degree of difficulty. My current A.I. is nearly impossible to beat for anyone I've set against it for about 5-10 rounds, then the gaps in the defenses become apparent and you learn how to take it down (with careful timing and concentration). I have only one standard attack, one air (jumping) attack, and one crouching sweep attack, so in that respect the options for it to be tricky or fancy are quite limited. What it does have currently is very good reflexes and several attacks and counter attacks that respond to where you are and what you're doing. Outside of that is a layer of more general behavior that randomly switches between different habits throughout the round. If anyone's messed around with this before and can offer pointers it'd be a big help. I'm having a lot of fun finding my own way, but I also want to make the game as kickass as possible :) Cheers
Advertisement
That sounds pretty much ideal to me. One suggestion I'd have would be to add a couple of "fake" moves that are rarely used before some other attack.
One think you could add, which would make it a lot harder to beat, is making it learn from the player.

Just keep track of the moves/attacks of the player and when you see a repeated series coming up, take counter action.

It is a bit harder to code but it would make vulnerabilities in the IA less exploitable.

To trim it down add a random factor that determines whether the counter action should be excecuted or not.
Something you could try out is adding a 'reaction' timer. A timer that gets activated and counts down whenever the cpu decides to perform a move. The actual time each move takes varies and overall depends on the difficulty level. (Could range from milliseconds to over a second.)

Let's say the player jumps towards the cpu. The cpu anticipates a jump kick and decides on an action chosen randomly. (Either do an uppercut, jump attack, or just guard.) The reaction does not always have to be the best one. The reaction timer then gets activated and when it reaches zero, the cpu performs the move.
Thank for the ideas. It's coming along ok today. I've just received all the animation clips from the project's designer which has totally thrown the A.I out of whack. All the moves/clips are different lengths now and timings are all off.

When I sort that out and get back to the point I was at with my temp animations, I'll be trying to implement some of this stuff.

The learning from the opponent thing is something I've been thinking about for a while, although I was going to take a slightly different approach. I thought about recording info every time the A.I gets struck, such as what it's current action was, where it was, on the ground or not, etc. And using that info to alter future decisions and prevent it walking into the same stupid trap over and over again.

I like the faking idea too. Hadn't considered that yet. Anything to decrease predictability would be a good thing I think.

Re: reaction timer, I've got basically that implemented, although it works in a less direct sort of round about way, but the end result is the same. With a lower difficulty setting, ideal actions and reactions have only a variable chance of actually executing at each iteration. It creates the illusion of slow and clumsy reflexes at low difficulty settings. At the highest difficulty setting, ideal actions execute immediately.

Cheers
Check out N-Gram Statistical Prediction to avoid the player beating the AI with the same sequence of moves.

To make your *offense* better, you might want to look into Weakness Modification Learning.

As always with adaptive AI: start small, be objective, and be sure you really understand the techniques you are using.
Quote:Original post by onfu
I'm making a simple 2d fighter (street fighter style), and am looking for any tips on how to make a dynamic, natural looking A.I. [...] My current A.I. is nearly impossible to beat for anyone I've set against it for about 5-10 rounds, then the gaps in the defenses become apparent and you learn how to take it down (with careful timing and concentration). [...] If anyone's messed around with this before and can offer pointers it'd be a big help. I'm having a lot of fun finding my own way, but I also want to make the game as kickass as possible :)
Here's some inspiration: http://realtimecollisiondetection.net/blog/?p=51

This topic is closed to new replies.

Advertisement