How do I create a Fighter game AI?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
PixelHero
Prole
Posts: 45
Joined: Sat Apr 16, 2022 3:16 am

How do I create a Fighter game AI?

Post 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.
Dragons are great.
User avatar
darkfrei
Party member
Posts: 1169
Joined: Sat Feb 08, 2020 11:09 pm

Re: How do I create a Fighter game AI?

Post 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
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
togFox
Party member
Posts: 770
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: How do I create a Fighter game AI?

Post by togFox »

The easiest is a bunch of if-else-then statements as deep or complex as you like.

Build up from there.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: How do I create a Fighter game AI?

Post 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.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
ddabrahim
Party member
Posts: 182
Joined: Mon May 17, 2021 8:05 pm
Contact:

Re: How do I create a Fighter game AI?

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests