YesNoOk
avatar

Trying to make an AI from scratch (Read 262 times)

Started by sisco, November 08, 2014, 04:44:54 pm
Share this topic:
Trying to make an AI from scratch
#1  November 08, 2014, 04:44:54 pm
  • avatar
  • *
    • Colombia
    • grahf810@gmail.com
Hey people!

I want to try and do a better AI for this character, but he already has one, my question is if someone could help me telling me what I should delete from the this files to be able to start from scratch.

https://www.mediafire.com/?evkfbevd5b2g58c

Thanks.
Re: Trying to make an AI from scratch
#2  November 08, 2014, 10:09:27 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/

  • Online
AI is, most of the time, deeply intergrated into the character, there usually isn't something that you can delete to start completely from scratch, but you can get pretty close.

In his cmd file, there should be a bunch of changestate sctrls that have any of the following triggeralls:

AILevel > 0
ailevel
ailevel != 0

If any of those triggeralls or triggers have any of the above triggers, then it is an AI command and you can successful disable it. If it's not a triggerall, then you should just disable that particular set of triggers. If it is a trigger all, then you can delete the whole changestate sctrl.

If you have any further questions, please feel free to ask.
Re: Trying to make an AI from scratch
#3  November 08, 2014, 10:45:52 pm
  • avatar
  • *
    • Colombia
    • grahf810@gmail.com
Thanks for replying, and this is how it looks:

[State -1, famas]
type = ChangeState
value = 2006
triggerall = (Var(0) = 0)
triggerall = AILevel >0 && roundstate = 2 && statetype !=A
triggerall = (p2stateno!=[120,155]) && (p2statetype!=L)
triggerall = stateno != [800,8003]
triggerall = p2statetype !=A||((p2bodydist y =[-55,-20])&&enemy,vel y >=0&& AILevel >3)
triggerall = p2statetype !=L
triggerall = random<18*AILevel
triggerall = AILevel >=1000
triggerall = enemynear,anim!=5120
triggerall = p2bodydist x = [0,300]
trigger1= p2movetype=A && ctrl && p2bodydist x >90
trigger2 = stateno = 240 && movecontact
trigger3 = stateno = 440 && movecontact
trigger4 = stateno = 220 && movecontact
trigger5 = stateno = 221 && movecontact
trigger6 = stateno = 250 && movecontact
trigger7 = stateno = 2000 && movecontact
trigger8 = stateno = 2003 && movecontact
trigger9 = stateno = 2005 && movecontact
trigger10 = stateno = 2310 && movecontact
trigger11 = stateno = 2311 && movecontact
trigger12 = stateno = 2312 && movecontact
trigger13= stateno = 2500 && time > 17 && p2movetype=H
trigger14 = stateno = 2501 && time > 17&& p2movetype=H
trigger15 = stateno = 2502 && time > 17&& p2movetype=H
trigger16= enemynear,anim=5300 && ctrl

So going by what you said I can just delete the whole changestate sctrl, right?

But I have a question, is it possible to edit this current code to make the AI better? All of the tutorials I've seen teach you how to do it differently, like this one for example:

http://mugenguild.com/forum/topics/ai-coding-tutorial-108420.0.html

They don't mention anything about this AILevel stuff, so that is why I was thinking of making it from scratch.
Re: Trying to make an AI from scratch
#4  November 08, 2014, 11:03:17 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/

  • Online
You can just delete that or modify it to get rid of or modify the AI respectively.

You can ignore most of the old tutorials that don't include ailevel, unless you're programming for winmugen or something. Ailevel is a fairly new trigger that makes coding AI monumentally simpler. You simply add a trigger that says "ailevel," which means only activate if AI is activated via MUGEN's options, and then you code the conditions as usual. That being said, you can definitely just edit the code to make it better.

In that tutorial, think of ailevel as var(59) (var 59 was almost universally the AI variable, which was triggered by some concocted method of humanly impossible commands). For more modern MUGEN coding, you don't need to use anything except AIlevel as your trigger, as long as you're using 1.0 or 1.1.
Re: Trying to make an AI from scratch
#5  November 08, 2014, 11:15:10 pm
  • avatar
  • *
    • Colombia
    • grahf810@gmail.com
I see, would you mind giving me an example of how it's done?

For starters there are two "genome" in the cmd

[Statedef -1]
;---------------------------------------------------
;Genome
[State -1, Genome]
type = ChangeState
value = 8500
triggerall = power >= 3000
triggerall = (Var(0) = 0)
triggerall = AILevel >0 && roundstate = 2 && statetype !=A
triggerall = (p2stateno!=[120,155]) && (p2statetype!=L)
triggerall = stateno != [800,8003]
triggerall = p2statetype !=A||((p2bodydist y =[-55,-20])&&enemy,vel y >=0&& AILevel >3)
triggerall = p2statetype !=L
triggerall = random<18*AILevel
triggerall = enemynear,anim!=5120
triggerall = p2bodydist x = [0,300]
trigger1= p2movetype=A && ctrl && p2bodydist x >90
trigger2 = stateno = 2000 && movecontact
trigger3 = stateno = 2003 && movecontact
trigger4 = stateno = 2005 && movecontact
trigger5 = stateno = 2000 && movecontact
trigger6 = stateno = 2003 && movecontact
trigger7 = stateno = 2005 && movecontact
trigger8 = stateno = 2310 && movecontact
trigger9 = stateno = 2311 && movecontact
trigger10 = stateno = 2312 && movecontact
trigger11= stateno = 2500 && time > 17 && p2movetype=H
trigger12 = stateno = 2501 && time > 17&& p2movetype=H
trigger13 = stateno = 2502 && time > 17&& p2movetype=H
trigger14= enemynear,anim=5300 && ctrl

and

;Genome
[State -1, Genome]
type = ChangeState
value = 8500
triggerall = power >= 3000
triggerall = command = "genome"
triggerall = AILevel =0
triggerall= (statetype != A)
trigger1= ctrl
trigger2 = stateno = 201 && movecontact
trigger3 = stateno = 200 && movecontact
trigger4 = stateno = 210 && movecontact
trigger5 = stateno = 230 && movecontact
trigger6 = stateno = 240 && movecontact
trigger7 = stateno = 400 && movecontact
trigger8 = stateno = 410 && movecontact
trigger9 = stateno = 430 && movecontact
trigger10 = stateno = 440 && movecontact
trigger11 = stateno = 220 && movecontact
trigger12 = stateno = 221 && movecontact
trigger13 = stateno = 250 && movecontact
trigger14 = stateno = 420 && movecontact
trigger15 = stateno = 2000 && movecontact
trigger16 = stateno = 2003 && movecontact
trigger17 = stateno = 2005 && movecontact
trigger18 = stateno = 2310 && movecontact
trigger19 = stateno = 2311 && movecontact
trigger20 = stateno = 2312 && movecontact
trigger21 = stateno = 2500 && time > 17
trigger22 = stateno = 2501 && time > 17
trigger23 = stateno = 2502 && time > 17

What should I change in them to make it better? I apologize for the trouble in advance.
Re: Trying to make an AI from scratch
#6  November 08, 2014, 11:18:55 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/

  • Online
No need for apologies, this section is here to help people.

One says ailevel = 0, which means activate only when a human is controlling the character, the other says ailevel > 0, which means activate only when AI is controlling the character. So, naturally, you would edit the one that contains the latter. Leave the human command alone, as it's what allows you to perform that move when playing as that character.

I can't give you specific triggers, because it depends on what you want the character to do, but you can always look at other characters' AIs that you might want to emulate!
Re: Trying to make an AI from scratch
#7  November 08, 2014, 11:24:26 pm
  • avatar
  • *
    • Colombia
    • grahf810@gmail.com
Ah ok, so:

triggerall = (Var(0) = 0)
triggerall = AILevel >0 && roundstate = 2 && statetype !=A
triggerall = p2statetype !=A||((p2bodydist y =[-55,-20])&&enemy,vel y >=0&& AILevel >3)
triggerall = random<18*AILevel

Pretty much every command has this 4, so my guess is that when I change one, I should change them all? Or it is just changing this one:

triggerall = AILevel >0 && roundstate = 2 && statetype !=A

Re: Trying to make an AI from scratch
#8  November 08, 2014, 11:31:24 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/

  • Online
If you're just trying to modify AI and not delete it, then you can pretty much leave the following wo lines alone:

triggerall = (Var(0) = 0)
triggerall = AILevel >0 && roundstate = 2 && statetype !=A



The other lines are sort of triggers that read the enemies movement and tell the AI when to activate, the other one just randomizes the frequency of the move, so you can edit those at your heart's content. If you're having problems understanding some triggers, you can always look at the trigger documentation that comes with your MUGEN:

http://elecbyte.com/mugendocs/trigger.html

The triggers below those "triggeralls" further dictate the conditions for the move to activate. Triggeralls apply to all triggers: trigger1, trigger2, et, but trigger1 and trigger2 don't apply to each other. Get it?
Re: Trying to make an AI from scratch
#9  November 08, 2014, 11:39:57 pm
  • avatar
  • *
    • Colombia
    • grahf810@gmail.com
So if triggeralls apply to 1 and 2 what is the point of having trigger1 and trigger2?
Re: Trying to make an AI from scratch
#10  November 08, 2014, 11:46:51 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/

  • Online
Trigger1 and trigger2 add specific conditions that trigger the changesate. Each one is separate and all triggeralls apply to every other trigger. That's the simple answer.

For example, if you want the character to use the move only when they're within a certain distance, but you want to to trigger based on other additional circumstances that don't go together, then you use a triggerall for the distance, and then use trigger1, trigger2, etc to encompass each other circumstance. It's useful in other ways too.
Re: Trying to make an AI from scratch
#11  November 08, 2014, 11:55:55 pm
  • avatar
  • *
    • Colombia
    • grahf810@gmail.com
Ah ok, something like this:

triggerall = FrontEdgeBodyDist < 30
trigger1 = Const(velocity.walk.fwd.x) > 4
trigger1 = ScreenPos Y < GameHeight / 2

?