Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BRZGames

Fighting Game AI

This topic is 5839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a fighting game, and need to finish the computer AI for single player modes. Right now, I have a simple system hacked in, but I thought I''d ask if anyone had any ideas, tutorials, etc. on implementing good AI in fighting games before I proceed. If you''re interested the game info is on my site http://brzgames.cjb.net/

Share this post


Link to post
Share on other sites
Advertisement
If you have a jump function, you should make some acrobatic reflexes like avoiding a lowkick. Well?

cool, hot chicks fighting game!
make some blondes will ya?

[edited by - pipo declown on September 13, 2002 3:00:48 PM]

Share this post


Link to post
Share on other sites
Yeah, I''ve already got a reflex system kind of implemented right now, although I still need to implement it when players are jumping or flipping. The biggest problem right now I have, is that the computer player doesn''t fight very naturally. She basically just keeps advancing, and attacks you. I''d like to be able to have the computer put several combos together, so it plays more like a person.

And yes there will be blondes..........

Share this post


Link to post
Share on other sites
I presume you have something like offensive and defensive modes, advancing and retreating modes and you permit permutations of these? Combinations can be programmed either using scripts (if you have a scripting engine in your game). If not, you can use a finite state machine with a heirarchical flow of actions. Certain actions trigger other actions, which in turn trigger further actions... and all of these might be affected by what the other player is doing.

Not much help I know... but it''s something to consider.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
Timkin,
Hmmmm, well I do have offensive, and defensive modes within a state machine. What I''m trying to do is specify characteristics in an XML file of each characters, regarding there aggressiveness, chance to block, etc (so each character will fight differently.) And also maybe weight several preferred offensive moves. I think maybe I need to add more states to my state machine though, to allow a better flow of possible actions as you suggested. Right now it''s pretty simple with only a handful of states. Thanks for the tip.

Share this post


Link to post
Share on other sites
quote:
Original post by BRZGames
I think maybe I need to add more states to my state machine though, to allow a better flow of possible actions as you suggested. Right now it's pretty simple with only a handful of states.



Ah! While it isn't the only way to program a fighting game, breaking up a fight into different modes really helps to 'mix it up'. Consider being in a real fight. When you're advancing you're putting pressure on your opponent. You're closing range and bringing your shorter range weapons (hands, elbows, knees) into the fraw. When you're retreating you're releasing pressure and removing these from your arsenal. When you're opponent is pressing their attack, they are also brining your shorter range weapons into the fray and when they are retreating (without you following) they are taking your short range weapons out of the fray. Both opponents are doing this, trying to find a range of most effectiveness of their weapons and least effectiveness of their opponents weapons. This is why speed and range are important in fighting. In boxing, for instance, the fighter with the longer reach has an advantage, but this can be countered by a fighter who can move faster.

You can also use these forward and backwards movements to your advantage. By retreating you can draw your opponent into moving forward. By suddenly changing to an advancing position (with an appropriate attack) you can catch your opponent off guard (if they were concentrating on attacking, rather than defending).

If you add in sideways motion, the complexity of the fight goes up exponentially... but it's a lot more fun and a lot more effective!

As to implementation, I would suggest having several movement states (advance, retreat, hold (stay still), jump) and two postures (offensive and defensive). These could be held in two state variables making a 2-D array of possible combinations:

|| posture
motion ||_____________________________
|| offensive | defensive |
_______||______________|______________|
|| | |
advance|| | |
_______||______________|______________|
|| | |
hold || | |
_______||______________|______________|
|| | |
retreat|| | |
_______||______________|______________|
|| | |
jump || | |
_______||______________|______________|


You could assign an effectiveness to each technique of a fighter in each different mode (entry in this table) and have the AI choose a technique based upon it's perceived effectiveness and the difficulty rating of the fighter. You could also/alternatively program set sequences of actions for each of these modes and make those options as well.

As an ultimate (fun/interesting/challengine) thing to do, implement a method of learning the effectiveness of each technique in each state (mode)!

I hope this gives you some good ideas!

Cheers,

Timkin

[edited by - Timkin on September 16, 2002 9:59:20 PM]

Share this post


Link to post
Share on other sites
I think it would be really impressive if you could implement some kind of player pattern recognition. My experience of playing fighting games is that I tend to find a sequence of moves that the ai is weak against, and then simply repeat the sequence of moves to beat the ai. If you could have some kind of player pattern recognition, your ai could learn to defend and conteract repeated patterns, thus forcing the player to be inventive and making the game more fun and interesting.

For example, the player finds that the following sequence of moves is very effective against the ai...punch, jump, block and kick. If your ai can recognise this repeated pattern, then then next time the player executes a punch, jump, block, the ai will predict the next move will be a kick and thus block the kick.

Of course, all of this is a lot easier said than done. I''ve not actually impemented anything like this myself, so other people will probably have some better ideas. But you could try creating a recurrent neural network which is capable of learning sequences over time. I''m not entirely sure how well such a network would be able to deal with very noisy data, and whether or not it would be practical to train such a network in real time.

Share this post


Link to post
Share on other sites
Thanks for the feedback guys. Timkin, I actually worked on the state machine a little yesterday, and have already implemented some of what you have suggested in you email. I hadn''t thought about the two posture idea though, I need to think how I could incorporate that in. Here''s what I have now. I have an XML file laid out for the player AI that specifies player moves, and there area of effect (like up high, down low, mid range), and range of effect (close, far). It also allows me to tweek Aggressiveness, Retreating, and Blocking variables that act as percentages to determine what state the computer is in. My state machine now has 8 states. These are:

Standing : Default state, computer just stands there. Leads to Attacking, or Retreating

Advancing : Causes the computer to advance towards a player. Leads to the Attacking state. Can also lead to the flipping state if players are far away.

Attacking : Causes the computer to attack with a close range attack if the players are close enough, or a far attack if the players
are far away.

Blocking : If the computer is attacked, causes computer to block, or can lead to ducking, and jumping state dependant upon the area of effect of the attack.

Retreating : computer retreats from the player

Ducking : Ducks a high attack

Jumping : Jump a low attack

Flipping : Causes the computer to flip toward an opponent

I also have a timer (currently set to 1 sec) for the maximum amount of time to remain in the state.

I fights a lot more natural than before, but still needs some work.

And along the lines of what Mr. Nonsense was saying (but not as complicated), I thought about keeping track of the moves performed against the computer, and have the more times a move (or moves) are used against the computer, the higher the chance of the computer blocking it.

Thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you want to be adventurous you could train Neural Network, that would learn how to not get hit and how to maximise damage (use different players otherwise it will learn how to fight one player not all of them). When it is satisfactory, simply save its state and you should have an effective AI. Either that or you can just leave it open, so when new players start fighting it will learn off them.

Share this post


Link to post
Share on other sites
Have you considered the implimentation of combination attacks?

Given your current set up you would simply have a chain of attacks that have a decreased execution speed.

For example: Ken has a pre-determined combination of attacks that, when executed in sequence, goes off with split second timing.

So you decide that when the user presses: high kick, low kick,
medium punch, power punch,; within an alotted amount of time, that the character will high kick, low kick, medium punch, power punch, and then perhaps perform some additional move that is pretty much indefensible, kind of a bonus for knowing the right sequence of buttons to press. Where three fast punches may take the least amount of time normally, you might time the total execution of this combo to a similar time. thereby increasing the effectiveness of the combo. Now give this ability to players and agents alike. The results of the combination should lend a more "liquid" style to the agents attack initiations, as well as build a broad spectrum of competencies.(the first guy you fight may only know 3 attack combo''s where the final guy may attack in combos exclusively) This also gets you started down the path of "easy to pick up and difficult to master". The more combos you allow, the more there is to master, as well as the added value of further distinguishing fighting styles of different players by the different types of combos available to them.

Just a few thoughts.

Dreddnafious Maelstrom

"If i saw farther, it was because I stood on the shoulders of giants."

Sir Isaac Newton

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!