YesNoOk
avatar

How to make a good AI? (1.0-1.1b) (Read 16133 times)

Started by WastedCoder, December 26, 2021, 03:08:43 pm
Share this topic:
How to make a good AI? (1.0-1.1b)
#1  December 26, 2021, 03:08:43 pm
  • **
    • Ukraine
Hello, everyone.
I need some tips, tricks etc. on how to make a good AI for 1.0-1.1b character.
Re: How to make a good AI? (1.0-1.1b)
#2  December 27, 2021, 02:35:28 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Think of how you would like the character to play and react, and code it. AI is nothing more than just preparing scenarios and adding them to a list
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: How to make a good AI? (1.0-1.1b)
#3  December 27, 2021, 03:22:13 pm
  • **
    • Ukraine
Think of how you would like the character to play and react, and code it. AI is nothing more than just preparing scenarios and adding them to a list

Thank you, I understand that, but in terms of coding things. Like, recently, I learned that it's not recommended to use more than 100 random, because random is checked every tick and it results in spamming, also I've found out some people would use variables instead of random. I ask for this kind of tips. What should and should not people do when coding AI? What people use to make AI better, more human-like and AIlevel dependable? When Ailevel - 1 it's weak and AIlevel - 8 actually strong and smart. Some useful triggers or probably any examples, since I am a beginner and would like to learn some alternative ways instead of doing anything like this:

Spoiler, click to toggle visibilty

Which ends up in the AI standing in one place, charging and spamming specials OR running to you recklessly to spam its combos.

Re: How to make a good AI? (1.0-1.1b)
#4  December 27, 2021, 04:56:44 pm
  • ****
    • USA
    • twitter.com/inktrebuchet
AI is an awesome spot for a beginner to start in my opinion. I think the main thing you should focus on is making sure that AI can't do anything that a player wouldn't be able to do. This is easily achieved by making sure you have the right triggers on the AI changestates. Sounds obvious but I still see that mistake.

Using random is really useful and there are a few different ways that people use it with ailevel for scaling the AI. Pots has a cool example of this work really well, if you are looking for an example. Actually this would probably be more useful to checkout https://mugenguild.com/forum/msg.2321829

If you want to get into more advanced AI, you can start thinking about disabling default AI walk, jump since a human player would never do those at random. Coming up with the logic for your own can be really fun.

For me the best AI is the ones that seem really human. Not insanely overpowered or perfect, still makes mistakes but also makes solid choices.

Last Edit: December 27, 2021, 05:31:31 pm by inktrebuchet
Re: How to make a good AI? (1.0-1.1b)
#5  December 27, 2021, 08:30:27 pm
  • **
    • Ukraine
AI is an awesome spot for a beginner to start in my opinion. I think the main thing you should focus on is making sure that AI can't do anything that a player wouldn't be able to do. This is easily achieved by making sure you have the right triggers on the AI changestates. Sounds obvious but I still see that mistake.

Using random is really useful and there are a few different ways that people use it with ailevel for scaling the AI. Pots has a cool example of this work really well, if you are looking for an example. Actually this would probably be more useful to checkout https://mugenguild.com/forum/msg.2321829

If you want to get into more advanced AI, you can start thinking about disabling default AI walk, jump since a human player would never do those at random. Coming up with the logic for your own can be really fun.

For me the best AI is the ones that seem really human. Not insanely overpowered or perfect, still makes mistakes but also makes solid choices.



Ok, Thank you so much ^-^
Re: How to make a good AI? (1.0-1.1b)
#6  December 27, 2021, 09:28:04 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
Here's an example of an AI snippet for one of my chars, Eighteen and in particular for her multiple fireball move, with some comments for your learning:

;AI Blitz Deadend
[State -1, AI Blitz Deadend]
type = ChangeState
triggerall = AILevel>0 && numenemy && roundstate=2 && StateType != A trigger when AI is on, there's an enemy, during the match and while on the ground
triggerall = NumHelper(1500)<3 ; Blitz Deadend limiter checks that we have not reached the max number of moves
triggerall= (enemy,stateno!=[120,155])&&(enemy,stateno!=[5100,5120]) && (enemy,vel x>=0) the move will be performed when the enemy is not blocking, or lying on the ground and while the enemy is moving forward
trigger1 = ctrl && time>5 && random < 50*(AIlevel ** 2 / 64.0) time>5 gives a reaction of at least 5 frames for the AI, to simulate a command input- the part following the random is an AI scaler, resulting in a harder AI when AI level is higher
trigger2 = ((stateno = 200) || (stateno = [210,215]) || (stateno = 220))
trigger2 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger3 = ((stateno = 230) || (stateno = 240) || (stateno = 250))
trigger3 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger4 = ((stateno = 400) || (stateno = 410) || (stateno = 420))
trigger4 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger5 = ((stateno = 430) || (stateno = 440) || (stateno = 450))
trigger5 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger6 = stateno = 100 || stateno = 101
trigger6 = random < 50*(AIlevel ** 2 / 64.0) all these conditions are to ensure a combo chain from a previous specific hit and with a variable rate of successing at the combo
value = Cond(p2bodydist y<0,1500,1500+10*(random%3)) if the AI activates one of the above conditions, then if the enemy is jumping, she will do the backwards version to stay safe. If the enemy is not jumping then she will perform any of the 3 versions

As you can see, the scenario is pretty simple for this specific move, but it gives a human feeling and reaction on when to perform a move, and also open to mistakes
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: How to make a good AI? (1.0-1.1b)
#7  December 28, 2021, 10:57:50 am
  • **
    • Ukraine
Here's an example of an AI snippet for one of my chars, Eighteen and in particular for her multiple fireball move, with some comments for your learning:

;AI Blitz Deadend
[State -1, AI Blitz Deadend]
type = ChangeState
triggerall = AILevel>0 && numenemy && roundstate=2 && StateType != A trigger when AI is on, there's an enemy, during the match and while on the ground
triggerall = NumHelper(1500)<3 ; Blitz Deadend limiter checks that we have not reached the max number of moves
triggerall= (enemy,stateno!=[120,155])&&(enemy,stateno!=[5100,5120]) && (enemy,vel x>=0) the move will be performed when the enemy is not blocking, or lying on the ground and while the enemy is moving forward
trigger1 = ctrl && time>5 && random < 50*(AIlevel ** 2 / 64.0) time>5 gives a reaction of at least 5 frames for the AI, to simulate a command input- the part following the random is an AI scaler, resulting in a harder AI when AI level is higher
trigger2 = ((stateno = 200) || (stateno = [210,215]) || (stateno = 220))
trigger2 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger3 = ((stateno = 230) || (stateno = 240) || (stateno = 250))
trigger3 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger4 = ((stateno = 400) || (stateno = 410) || (stateno = 420))
trigger4 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger5 = ((stateno = 430) || (stateno = 440) || (stateno = 450))
trigger5 = movehit && random < 100*(AIlevel ** 2 / 64.0)
trigger6 = stateno = 100 || stateno = 101
trigger6 = random < 50*(AIlevel ** 2 / 64.0) all these conditions are to ensure a combo chain from a previous specific hit and with a variable rate of successing at the combo
value = Cond(p2bodydist y<0,1500,1500+10*(random%3)) if the AI activates one of the above conditions, then if the enemy is jumping, she will do the backwards version to stay safe. If the enemy is not jumping then she will perform any of the 3 versions

As you can see, the scenario is pretty simple for this specific move, but it gives a human feeling and reaction on when to perform a move, and also open to mistakes

Thanks :з
I appreciate your help <3