Advertisement

AI in a fighting game

Started by September 04, 2004 05:56 PM
13 comments, last by GameDev.net 20 years, 2 months ago
Does anybody now where i could find info on how ai is done in a fighting game??I did this 2d fighting game in c++ and all works well in the two player mode.But i need AI for it to be playable in one player mode,and i was wondering if anybody knew somewhere where i could learn this.I have some idea how it could be done.But i want to make sure no other way is possible before getting down to doing that. Thanks for any help.
have 2 human players play each other and take records

use the data to make a big table where the inputs are p1's last move, p2's last move, and maybe some other factor like distance between players
and the value stored in each cell is a histogram of p1's next move given the inputted previous moves

then just have your computer opponent play by looking up moves in the table


if you like, you could also sort the table rows and columns by situation frequency/similarity
and choose moves in a semirandom/stochastic Nearest Neighbor type approach
Advertisement
Well, you know the rules of your fighting system, so base your AI off that. First, defense: for a particular move made by the human player, there are certain moves the AI can do to counter, so just have it execute one of them. Next, offense: when the AI isn't involved in defence, have it pick an offensive move that the human player's current state is not blocking, either purely at random or based on a weighting. He may also choose to wait, especially if the player is currently blocking.

Now you have a perfect AI. Tone him down a little by having him fail to execute the proper defensive moves at times, and by sometimes making easily blockable offensive moves.
Yep.Sneftel's suggestion was what i had in mind.An d the toning down part would vary according to the chosen level(easy,medium,hard..) right?I hadnt though of hap's one though.I kind of like it.I'll do both and see which one works best,although hap's method could be harder than the other one.Thanks for the help.
Any further suggesttions are welcome.
oh
i forgot to mention

when you build that table
you might want to leave out moves that led to the player losing
like, maybe populate the table only with the move data from the player that won the match
or maybe track player's health and only input moves that didn't result in a health loss
dont want to build an ai that's really good at getting beat up.....
that method does not take into account the players you are recordings ablitly. you would want the players you are reoording to be good at the game and know the moves else recording a random button mashing game will reproduce random events which would be ahard to find a partern in.
Advertisement
From what i understood of haps suggestion,this is what i had in mind:
I intended on recording the players reaction to every move,in what occasion a certain move is attempted..etc,and use this data has triggers.I was hoping it would lead to:

1) reactions that dont seem irrational

2) A humain like adversary (i.e not able to block EVERY move you throw at it)

Does anybody think i'm doing this wrong (I'm currently working on sneftel's suggetion,so it's not too late)
Thanks ahead

[Edited by - zic on September 9, 2004 4:40:34 PM]
of course if your players suck
or dont take the game seriously and button mash randomly
then your end result will be just as bad

ideall'y you would want to use player's who have played your game a while and gotten to know the game balance and everything

if there is no game balance, and button mashing is actually encouraged by the current setup
then you'd want to fix that issue first


anyhow
my experience with this method is academic
simple games in a classroom, so you might not totally trust my experince, but...
it tended to imitate the the source data, but have some randomness thrown in
an explicitly rule/trigger based AI will tend to beat it due to the randomness introducing mistakes
but then again, this might be the kind of effect you want
But thats exactly what i intended on doing.This is what i meant:
say you throw a fireball.On one of his reactions he jumps.On another he blocks.On a third one he's hit.This all reprents 3 different reactions to a same move.
If the player does this move,this triggers one of the reactions but the reaction is of course chosen randomly.This generates rationnal and human like reactions.
thanks
you could just as easily write an AI that learns. There are a limited number of offensive & defensive moves & position orientations on the board... if the AI did something & it resulted in more health loss than it inflicted... add a negative weight to that move's score & it will continuously improve itself.
Whatsoever you do, do it heartily as to the Lord, and not unto men.

This topic is closed to new replies.

Advertisement