Page 1 of 1

How do I create a Fighter game AI?

Posted: Wed Jun 22, 2022 8:16 pm
by PixelHero
I am making a fighter with my older sister, and i have the job of making the AI. How do I do that? :?
All tips help, so please share knowledge.

Re: How do I create a Fighter game AI?

Posted: Thu Jun 23, 2022 7:08 am
by darkfrei
PixelHero wrote: Wed Jun 22, 2022 8:16 pm I am making a fighter with my older sister, and i have the job of making the AI. How do I do that? :?
All tips help, so please share knowledge.
Simple solution: https://youtu.be/Q4MU7pkDYmQ
Hardcore solution: weak AI, that was trained for you needs. See perceptron. https://en.wikipedia.org/wiki/Perceptron

Re: How do I create a Fighter game AI?

Posted: Fri Jun 24, 2022 6:33 am
by togFox
The easiest is a bunch of if-else-then statements as deep or complex as you like.

Build up from there.

Re: How do I create a Fighter game AI?

Posted: Mon Jun 27, 2022 4:37 pm
by milon
Yeah, I wouldn't start with a full-on AI unless absolutely required. Enemies in most fighting games have scripted behavior that they follow, and it's fairly easy to make it complex enough that it will be difficult for players to anticipate every move.

Re: How do I create a Fighter game AI?

Posted: Mon Jun 27, 2022 6:50 pm
by ddabrahim
I did work on a fighting module in a different engine it was not Love2D but what I have done was to implement a state machine for both the player and the opponent so I can easily trigger any state for both player and the opponent.

-stand
-walk
-jump
-kick
-punch
-block
-crouch
...etc

And then I was tap in to this state machine with keyboard input for the player to trigger any of the states and for the AI I was simply use a bunch of if-else statements as togFox has recommended to check the state of the player and decide how the AI should respond.
For example if player punch I picked a random state if the opponent going to block or jump away or crouch or do nothing and take the hit or if the player was jumping then again pick a random state if the AI going to kick in the air or jump away..etc

It was pretty efficient to work with on a high level but it was a nightmare to debug when something did not work. But I liked it so this is what I would attempt to do again if I was making a proper fighting game.

But in case we are talking about some sort of boss fight in a platformer shooter game, I think it would make more sense what milon recommended and just script a pattern that repeat over and over again, this is how it works in most games.