YesNoOk
avatar

Editing a Character's AI Pattern (Read 2601 times)

Started by PRØJECT.13, January 29, 2020, 08:56:59 am
Share this topic:
Editing a Character's AI Pattern
#1  January 29, 2020, 08:56:59 am
  • ***
    • USA
    • YouTube.com/MugenX000
So I've been using JadeEye's edit of DivineWolf's Strider Hiryu since it's pre-update based and that version just feels better to me. However, the AI is just undeniably unfair whenever you're going up against it, with instant-supers upon you doing anything if Hiryu has the meter for it, immediately jumping up and air-grabbing you if you even slightly tap jump and even more examples of blatant input-reading.

I'm not looking to make him super easy or anything, I just want to get rid of the horrid input-reading and make him just slightly less aggressive without turning him into a pushover. Any and all help with this is greatly appreciated!
Re: Editing a Character's AI Pattern
#2  January 29, 2020, 09:43:29 am
  • ****
    • crepa.neocities.org
IDK how JadeEye code his AI so it may be different, but what I do in these situations is go in the CMD, search for the moves that I think the AI is "spamming" too much, and lower the random numbers, or including a random if it's not there.

An example taken from one of my own chars (I simplified the code for better understanding):

triggerAll = AILevel && NumEnemy
triggerAll = RoundState = 2 && StateType != A
trigger1 = (ctrl || StateNo = 52 || (StateNo = [100,101]))
trigger1 = P2BodyDist x >= 15 && Random < 250

That part in red reads more or less like "the AI will use this move with 25% chance". If you think it's too high you can decrease it like

trigger1 = P2BodyDist x >= 15 && Random < 100

Now it means 10% chance. Random generates a number from 0 to 999 every tick, the "<" symbol means "less than", so whenever the conditions are right for the move, the AI will use them. In other words, "if random is less than 100, this is true."

This is how I and most authors code AI, but as I said, may be different for a few authors.
Re: Editing a Character's AI Pattern
#3  February 02, 2020, 08:50:18 pm
  • ***
    • USA
    • YouTube.com/MugenX000
Sorry for replying late, I don't have internet service atm and I'm on my phone =P

I think JadeEye does the coding different or I'm blind because I don't recognize anything you're saying in the CMD file. It's also not that Hiryu's spamming the moves or anything, but that he's literally using supers and such as I'm pressing buttons and input reading me. I'm mainly looking to stop that.
Re: Editing a Character's AI Pattern
#4  February 03, 2020, 05:00:40 am
  • ****
    • crepa.neocities.org
Ok, I downloaded his AI and took a look.

The first thing I noticed is he separates the difficulty level, if it's 1~4, the AI is a little easier, while if it's 5~8 it's harder. The second thing is that, fortunately, Jadeeye named the changestates properly for the AI and placed them right after the normal commands, you can see it in the CMD, so they are easy to spot. I'm saying this because you can confuse the normal "human" moves with the AI exclusive moves (probably this was the cause you couldn't find the randoms I told you). Simplifying, !AILevel or AILevel = 0 is a human command, AILevel or AILevel = any number between 1 and 8 is an AI exclusive command. As I said, Jadeeye also named the AI commands like this: [State -1, AI Nagrarok]. So you know they are AI exclusive.

So, here is an example of what I mean. I'll highlight important stuff to make things easier.

[State -1, AI Nagrarok]
type = ChangeState
value = 3100
triggerall = (AILevel = [1,4]) && numenemy && roundstate = 2 && stateType != A && random < (150 * (AIlevel ** 2 / 64.0))
triggerall = p2statetype != L && p2statetype != A && (p2stateno != [120,155]) && (enemynear, stateno != [5100,5220]) && (p2bodydist x = [0,75])
triggerall = ifelse(var(20) <= 0, power >= 1000, power >= 0)
trigger1 = ctrl || StateNo = 40 || StateNo = 52 || (StateNo = [100,101])

[State -1, AI Nagrarok]
type = ChangeState
value = 3100
triggerall = AILevel >= 5 && numenemy && roundstate = 2 && statetype != A
triggerall = ifelse(var(20) <= 0, power >= 1000, power >= 0)
trigger1 = ctrl || stateno = 21 || stateno = 22 || StateNo = 40 || StateNo = 52 || (StateNo = [100,101]) || ((stateno = [120,131]) && movetype != H)
trigger1 = random < (125 * (AILevel ** 2 / 64.0)) && p2statetype != A && p2statetype != L && (enemynear, stateno < 3000) && p2movetype = A && (((enemynear, vel x <= 0) && (p2bodydist x = [0,75])) || ((enemynear, vel x > 0) && (p2bodydist x = [0,80])))
trigger2 = (stateno = 1000 || stateno = 1031) && movehit && (p2bodydist x = [0,40]) && random < (350 * (AIlevel ** 2 / 64.0))
trigger3 = stateno = 52 && (p2stateno = [5000,5011]) && (p2bodydist x = [0,40]) && random < (500 * (AIlevel ** 2 / 64.0))

What is happening here: as you can see in red, the first changestate is for when AI is 1~4, and the second is for 5~8. It's the same move though, state 3100.
In blue is the random values that he uses. You can see that in the easier version, it's random < 150, which is a low number so the AI will not use this move a lot, and it only has one trigger. The harder version though has a lot of triggers and the random values are higher (350, 500), resulting in the AI using this move whenever the conditions are right.

Maybe I used the wrong word (spamming), but what I meant is that reducing these numbers, the AI will not use the move as much as before, making it easier. Give it a try, change that 500 for example to 150 and you'll see what I mean.

Another thing that I noticed is that he puts the super moves first in the CMD, above the specials and normals, this also makes the AI preffers to use supers, since MUGEN reads codes from top to bottom. Moving them to the bottom will make the AI use the moves a little less.
Re: Editing a Character's AI Pattern
#5  February 03, 2020, 05:28:03 am
  • ***
    • USA
    • YouTube.com/MugenX000
I changed the values numerous times and noticed no real difference. Hiryu still read my inputs and used a super the moment I attacked if he had meter, or a faster normal if he didn't. The only real difference I noticed was that he was grabbing me on the ground more often than he would before, and even those were input-read...
Re: Editing a Character's AI Pattern
#6  February 03, 2020, 06:01:27 am
  • ****
  • CPU Purple Heart
    • USA
    • https://www.pixiv.net/en/users/8108265
 You need to reduce the random values massively if you want them to perform moves much less frequently. Reducing them by any noticeable fraction will barely effect their performance. I mean in the neighborhood of 1 to 10 as opposed to the 100 or more like shown above.

 There may possibly be other factors since some authors also use helpers, variables, signal-based explods or a combination of either to determine situations, but those can be a little more complicated to find without actually understanding AI coding.
Re: Editing a Character's AI Pattern
#7  February 03, 2020, 06:28:05 am
  • ****
    • crepa.neocities.org
Yeah, and you need to reduce it for all the moves that you think are being used "unfairly". The example I gave is one of his supers, if he stops using this super he still can use other supers or specials because their random values are still high.
Re: Editing a Character's AI Pattern
#8  February 03, 2020, 07:27:34 am
  • ***
    • USA
    • YouTube.com/MugenX000
Nothing I was changing was making any kind of change to his AI pattern for whatever reason, and I lowered the values all the way down to 50. So I just ended up deleting JadeEye's piece of the CMD in the end, and now Hiryu just doesn't attack anymore lol...

Well, I got him just to play as old Hiryu anyway, so it's whatever in the end, I guess. Maybe I'll just learn AI coding myself or something and use Hiryu as a test subject lol. Thanks all the same, guys. I do appreciate your help.