UPLOAD, SHARE, PRESERVE MUGEN FOR ETERNITY!

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: MUGEN AI Tutotial (Winane's method)

  1. #1
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default MUGEN AI Tutotial (Winane's method)

    *tutorial, lol, I can't modify the title.
    Btw, this is a tutorial from another forum, based on Winane's method to make a decent AI, for all the people which recently asked for it.

    First off, Open the CMD file of the character and add lines like these to declare the AI only commands and above any thing else in the CMD file:

    Code:

    ;-| AI |------------------------------------------------------
    [Command]
    name = "CPU1" <------------------------(AI Command Name)
    command = U, D, F, U, D, F <------------(Command combination)
    time = 0

    [Command]
    name = "CPU2"
    command = U, B, F, U, D, F
    time = 0

    [Command]
    name = "CPU3"
    command = U, D, D, U, D, F
    time = 0

    [Command]
    name = "CPU4"
    command = U, F, U, B, U, D, F
    time = 0

    [Command]
    name = "CPU5"
    command = B, B, B, U, B, U, D, F
    time = 0

    [Command]
    name = "CPU6"
    command = U, D, B, U, B, U, D, F
    time = 0

    [Command]
    name = "CPU7"
    command = F, F, B, U, B, U, D, F
    time = 0

    [Command]
    name = "CPU8"
    command = U, D, U, U, B, U, D, F
    time = 0

    [Command]
    name = "CPU9"
    command = F, B, B, U, B, U, D, F
    time = 0

    [Command]
    name = "CPU10"
    command = F, F, B, B, U, B, U, D, F
    time = 0


    You can add as much more as you like but don't exceed 60 cause the CMD only supports 128 unique commands per character including human commands, And you will not need that much any way, I only use 40 or even less, Also don't use same command combination, Each cpu command must have a unique combination and it doesn't matter what the combination is as you see above it's just some random combinations.

    It's time to announce to the CPU that it has control over the character, You can add the activation code in the CMD file under [Statedef -1] preferbly at the end of the CMD, Or you can program the AI in one of the CNS files of the character under [Statedef -2] or under [Statedef -3] but those statedefs must be declared, in some characters -2 or -3 are not declared so you have to declare them yourself by typing [Statedef -2] or [Statedef -3] and then add the activation code under them, in the CMD [Statedef -1] is always declared by the creator so no need to declare it again but if you separate the AI from the character files in a separate file, You're gonna have to declare it again.

    Activation Code:
    Code:

    ; AI switch -> ON
    [State -1, Activate AI]
    type = Varset
    triggerall = var(59) != 1
    trigger1 = command = "CPU1"
    trigger2 = command = "CPU2"
    trigger3 = command = "CPU3"
    trigger4 = command = "CPU4"
    trigger5 = command = "CPU5"
    trigger6 = command = "CPU6"
    trigger7 = command = "CPU7"
    trigger8 = command = "CPU8"
    trigger9 = command = "CPU9"
    trigger10 = command = "CPU10"
    v = 59
    value = 1



    This is a variable set telling the computer that when Var(59) is = 1 then do this and do that, But you must make sure that the variable 59 is available and not used in any thing else in the character coding or else use another variable, Also you must copy and past this line "triggerall = var(59) != 1"in each and every human command in the CMD file to differ between the commands you use to play with the character and the commands the CPU use against you, You'll find in the character CMD file human only commands look like this:

    Code:

    [State -1,FLK]
    type = ChangeState
    value = 310
    triggerall = command != "holddown"
    triggerall = statetype = S && ctrl
    trigger1 = command = "a" && command = "holdfwd"
    trigger2 = command = "a" && command = "holdback"


    Add the AI cancelation code to it like this:

    Code:

    [State -1,FLK]
    type = ChangeState
    value = 310
    triggerall = var(59) != 1 <---------------- This cancels the AI usage of the human commands
    triggerall = command != "holddown"
    triggerall = statetype = S && ctrl
    trigger1 = command = "a" && command = "holdfwd"
    trigger2 = command = "a" && command = "holdback"


    Open the CNS file and in the [Data] paragraph change the number of the IntPersistIndex to = 58, if it's already = 58 then keep it and if this line is not typed, Type it yourself "IntPersistIndex = 58" don't ask why cause i realy don't know, it just activates the AI faster i think.
    This means if you activated the AI in round one, it'll still be active in round 2+.
    Now you start programing the AI, Each cpu command must have [state -1] declaration or -2 or -3 depending on the state you're programming the AI in, For example:

    Code:

    [State -1, AI] ; punch
    type = ChangeState
    value = 200 <----------------------- State no. of the animation you want the CPU to perform
    triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
    triggerall = var(59) = 1 <------------ AI variable that must be used in every CPU command
    trigger1 = ctrl = 1 <----------------- Character can be controled (Not performing a move)



    Now you told the CPU that when Var(59) equals 1 and you have control over the character then perform a change state, In this case the state wanted is a weak punch(value = 200), There are 2 ways to know the state no. of the character moves while coding the AI, First one is choosing the character in training mode and turn on debug mode by pressing ctrl+D, Performing every move and the debug mode will tell you the state no. of the moves, The second way is the easiest just open the character in fighter factory and press the animation tab, you'll find the begin action no. bar displays every move state no.

    But the code above is very basic and will make the character keep punching continuasly like an idiot, So you must add more triggers to make the character punch only in a certain situation like this:

    Code:

    [State -1, AI] ; punch
    type = ChangeState
    value = 200 <----------------------- State no. of the animation you want the CPU to perform
    triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
    triggerall = var(59) = 1 <------------ AI variable that must be used in every CPU command
    triggerall = statetype != A <--------- Trigger when the char is not in air
    triggerall = random < 500 <---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
    triggerall = p2statetype != L <------- Trigger when opponent is not lying on the floor
    triggerall = p2bodydist x = [0,40] <--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
    triggerall = p2statetype != A <------- Trigger when the opponent is not in air
    trigger1 = ctrl = 1 <----------------- Character can be controled (Not performing a move)


    Now you told the CPU that when Var(59) is equal 1, The char is not jumping, Opponent is not jumping, Opponent is close, Opponent is not lying down and char is controlable then perform a weak punch, Now the code is much smarter.

    The differance between triggerall and trigger1 is:
    Triggerall is a condition that must be met for the whole changestate to be performed but trigger1 is a condition that triggers one part of the changestate, You can have trigger2, trigger3 or more like this:

    Code:

    [State -1, AI] ; punch
    type = ChangeState
    value = 200 <----------------------- State no. of the animation you want the CPU to perform
    triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
    triggerall = var(59) = 1 <--------------- AI variable that must be used in every CPU command
    triggerall = statetype != A <------------ Trigger when the char is not in air
    triggerall = random < 500 <------------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
    trigger1 = p2statetype != L <----------- Trigger when opponent is not lying on the floor
    trigger1 = p2bodydist x = [0,40] <------- Trigger when the opponent is between 0 to 40 pixels away horizontaly
    trigger1 = p2statetype != A <----------- Trigger when the opponent is not in air
    trigger1 = ctrl = 1 <-------------------- Character can be controled (Not performing a move)
    trigger2 = stateno = 210 && movehit<--- Trigger it in a combo when in stateno. 210 and the move hit the opponent
    trigger3 = stateno = 400 && animtime = 0<--chain it to stateno. 400 and the animation is over


    You can see that trigger1 is a different condition than trigger2 and trigger3, Three different conditions that the changestate can be performed in but all must meet the triggerall condition to be performed.

    - - - Updated - - -
    @kater15 @Leon72 @Dizzy can make this thread sticky, as many people were asking recently about AI? thanks!



  2. #2
    Join Date
    Nov 2017
    Location
    Posts
    8
    Uploads
    0
    Comments
    3

    Default Re: MUGEN AI Tutotial (Winane's method)

    Thank you, this has been really helpful in actually understanding how this works. I really was terrible in coding back when I was taking it and don't remember much and I really appreciate lessons that have easy instructions where they're needed rather than all over the place making you go "huh, hey, okay I do this where?" Sorry for the rambling here, it's just how my brain works. Also if I ever used this method, (which would provide that I actually manage to make a character off the ground period) should I credit you for posterity's sake? Thank you very much for your time.

  3. #3
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by JayZero View Post
    Thank you, this has been really helpful in actually understanding how this works. I really was terrible in coding back when I was taking it and don't remember much and I really appreciate lessons that have easy instructions where they're needed rather than all over the place making you go "huh, hey, okay I do this where?" Sorry for the rambling here, it's just how my brain works. Also if I ever used this method, (which would provide that I actually manage to make a character off the ground period) should I credit you for posterity's sake? Thank you very much for your time.
    No problem. ;)
    well, actually, as title says, it's winane's method. I don't personally know that user, that's why I credited him/her for the code. I just took it from another site when everybody here was asking about simple AI coding (and that's pretty simple, I guess).

  4. #4
    Join Date
    May 2016
    Location
    Posts
    28
    Uploads
    6
    Comments
    21

    Default Re: MUGEN AI Tutotial (Winane's method)

    why this doesn't work?AI are always being in 200 state and never goes to 300
    [State -1, Ai-Punch]
    type = ChangeState
    value = 200
    triggerall = var(59)!=0;&&numenemy
    triggerall = statetype = S
    triggerall = ctrl
    triggerall = pos y>=0
    trigger1 = playerid(enemynear,id),p2dist x<90
    trigger1 = playerid(enemynear,id),p2dist y<90
    ;----------------------------------------------------------------------
    [State -1, Ai-Punch]
    type = ChangeState
    value = 300
    triggerall = var(59)!=0;&&numenemy
    triggerall = statetype = S
    triggerall = ctrl
    triggerall = AIlevel
    triggerall = prevstateno = 200 && animtime = 0
    trigger1 = random<999

  5. #5
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    did you code each attack more like this?



    [State -1, AI] ; punch
    type = ChangeState
    value = 200 <----------------------- State no. of the animation you want the CPU to perform
    triggerall = roundstate = 2 <--------- Trigger during the fighting phase of the round "Round One...Fight"
    triggerall = var(59) = 1 <------------ AI variable that must be used in every CPU command
    triggerall = statetype != A <--------- Trigger when the char is not in air
    triggerall = random < 500 <---------- Trigger the move in 50% of the times the conditions is met (i'll explain more)
    triggerall = p2statetype != L <------- Trigger when opponent is not lying on the floor
    triggerall = p2bodydist x = [0,40] <--- Trigger when the opponent is between 0 to 40 pixels away horizontaly
    triggerall = p2statetype != A <------- Trigger when the opponent is not in air
    trigger1 = ctrl = 1 <----------------- Character can be controled (Not performing a move)

  6. #6
    Join Date
    May 2016
    Location
    Posts
    28
    Uploads
    6
    Comments
    21

    Default Re: MUGEN AI Tutotial (Winane's method)

    i deleted all old ai code in char exept activation.
    this is all what i have now
    [State -1, Ai On]
    type = VarSet
    triggerall = Var(59) < 1
    triggerall = RoundState = 2
    trigger1 = AILevel > 0
    trigger1 = ctrl=1
    v = 59
    value = 1
    ignorehitpause = 1

    [State -1, Ai Off]
    type= VarSet
    trigger1 = var(59) > 0
    trigger1 = RoundState != 2
    trigger2 = !AILevel||life<=0||Win||Lose||DrawGame
    v = 59
    value = 0
    Ignorehitpause = 1

    [State -1, Ai-Punch]
    type = ChangeState
    value = 200
    triggerall = var(59)!=0;&&numenemy
    triggerall = statetype = S
    triggerall = ctrl
    triggerall = pos y>=0
    trigger1 = playerid(enemynear,id),p2dist x<90
    trigger1 = playerid(enemynear,id),p2dist y<90
    ;----------------------------------------------------------------------
    [State -1, Ai-Punch]
    type = ChangeState
    value = 300
    triggerall = var(59)!=0;&&numenemy
    triggerall = statetype = S
    triggerall = ctrl
    triggerall = AIlevel
    triggerall = prevstateno = 200 && animtime = 0
    trigger1 = random<999


    Attacks works well,if they are not in combo.Problem in combo attack,they don't work.Works only first attack

  7. #7
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Yeah, happens to me too, on a random level sometimes CPU interrupts the combo, but sometimes the combo succeeds. Try by removing the random trigger and set triggerall=prevstateno=200 (for state 200) it should go necessarily after it (or at least it works this way for my chars, which I make from scratch... possibly it's not the same for edited chars as probably there's something you're missing in all that code).
    Last edited by mulambo; Nov 28, 2017 at 16:10.

  8. #8
    Join Date
    May 2016
    Location
    Posts
    28
    Uploads
    6
    Comments
    21

    Default Re: MUGEN AI Tutotial (Winane's method)

    but in my case he never succeeds combo
    I had no problem like this when i coded other char.Its strange for me

  9. #9
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by Hyper.Wave View Post
    but in my case he never succeeds combo
    I had no problem like this when i coded other char.Its strange for me
    then stick with other AI method, dunno what to tell you :D
    I used this method for SCF and all my chars are pretty challenging (so challenging I had to ask somebody else to make them more balanced and kid-friendly because they were rated "too hardcore / creepy" )
    you can always try to look for winane and ask him to give you more info about it... probably there are some conflicts between variables in the char or you didn't erase well the previous AI code (which may be sometimes related to the CNS of the char, not just the CMD).
    Last edited by mulambo; Nov 28, 2017 at 16:26.

  10. #10
    Join Date
    Jun 2018
    Location
    Posts
    5
    Uploads
    1
    Comments
    0

    Default Re: MUGEN AI Tutotial (Winane's method)

    Hello, i just started editing a character. Could you help me in coding the AI. Where i can link combos like normal cmbo attack => special move => then finish of a super move.

  11. #11
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by Jeross09 View Post
    Hello, i just started editing a character. Could you help me in coding the AI. Where i can link combos like normal cmbo attack => special move => then finish of a super move.
    in that case you just need to add a trigger (with a higher number) to the move you want to link, the trigger is whatever condition (it can be "time" or "movehit", etc...).

    example, if you want to link punch 1 (state 200) to punch 2 (state 201, below) right to have a 1-2 series of punches, here's how to edit such state:

    [State -1, AI] ; punch 2
    type = ChangeState
    value = 201
    triggerall = roundstate = 2
    triggerall = var(59) = 1
    triggerall = statetype =S
    trigger1 = stateno = 200 ;<---- this is the first punch which the second punch (state 201) is linked to
    trigger1 = movehit = 1 ;<-----this ensures that the second punch (state 201) comes right when the first punch (state 200) has hit the opponent.

    but you can also set it like it like this

    trigger1 = stateno = 200
    trigger1 = time = 10 ;<-----this ensures that the second punch (state 201) comes after 10 ticks of time during the state of the first punch (state 200)

    there are many triggers you can play with, so check the "triggers.html" doc of your "docs" folder (from the default MUGEN release).

    It's no big difference between "special", "normal" or "hyper", it's the number of the state that counts (so, example, the special has number 2000 instead of 201, and so on... be intuitive about it ;) )
    Last edited by mulambo; Jun 05, 2018 at 11:53.

  12. #12
    Join Date
    Jun 2018
    Location
    Posts
    5
    Uploads
    1
    Comments
    0

    Default Re: MUGEN AI Tutotial (Winane's method)

    Ok thank you. :) anyway do i still need to put the code “random” forthe frequency for this code to activate?
    Last edited by Jeross09; Jun 05, 2018 at 19:57. Reason: Additional message

  13. #13
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by Jeross09 View Post
    Ok thank you. :) anyway do i still need to put the code “random” forthe frequency for this code to activate?
    if you want it to be randomized, yes. if you want it to happen all the times, no.

  14. #14
    Join Date
    Jun 2018
    Location
    Posts
    5
    Uploads
    1
    Comments
    0

    Default Re: MUGEN AI Tutotial (Winane's method)

    I think i get the pattern now, but is it possible to put several attacks in 1 body of coding value? In the example you gave, its like 2 attacks. Is it possible to make 3 attacks? Ex. The value = 1000 before it reaches this value , the a.i should have done 5 different states first. So its like 6 hit combo in total.

  15. #15
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by Jeross09 View Post
    I think i get the pattern now, but is it possible to put several attacks in 1 body of coding value? In the example you gave, its like 2 attacks. Is it possible to make 3 attacks? Ex. The value = 1000 before it reaches this value , the a.i should have done 5 different states first. So its like 6 hit combo in total.
    Sorry I'm not understanding you properly. What was written above is the code to link a state to the other one. You got to link each attack one by one if you want a full combo.
    So when you "declare" a state, that means the AI does that state... at which condition? The triggers you put in that state. So if you want more triggers (more states) to be connected to the declared state, you just add the same trigger with higher number and different number for "stateno". But that only will link other attacks to the declared one. That won't create a full combo in a single "code block", it's better to make things step by step. So you first learn how to link 2 attacks, then you learn how to link 3 attacks and so on. It's better this way so you can find your method, instead of relying too much on presets.
    Last edited by mulambo; Jun 06, 2018 at 11:11.

  16. #16
    Join Date
    Jun 2018
    Location
    Posts
    5
    Uploads
    1
    Comments
    0

    Default Re: MUGEN AI Tutotial (Winane's method)

    Thanks for the help, i already balanced the combo links with it. Yup i guess its gonna be tedious to make a combo hits. Anyway i was fixing my super hadou, i got all the components except fot the hit ovverride. The beam just goes thru to enemie’s projectile and hits me in the process. So i tried the overridehit, doesnt change in a res box, it was still going thru projectiles. If i put the blue box on the animation sprite, it does the job canceling the projectiles but the animation just resets back to its first beam animation when everytime it connects.

  17. #17
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by Jeross09 View Post
    Thanks for the help, i already balanced the combo links with it. Yup i guess its gonna be tedious to make a combo hits. Anyway i was fixing my super hadou, i got all the components except fot the hit ovverride. The beam just goes thru to enemie’s projectile and hits me in the process. So i tried the overridehit, doesnt change in a res box, it was still going thru projectiles. If i put the blue box on the animation sprite, it does the job canceling the projectiles but the animation just resets back to its first beam animation when everytime it connects.
    no problem, but that's kinda offtopic if you ask me, as it's not related to AI, you can start another thread with that issue.

  18. #18
    Join Date
    Jun 2018
    Location
    Posts
    5
    Uploads
    1
    Comments
    0

    Default Re: MUGEN AI Tutotial (Winane's method)

    oh sorry, got carried away. anyway thank you for your help. here is a video of the character I am building. "https://youtu.be/yqnbAGxZydA" thanks again. ill make you guys proud :)

  19. #19
    Join Date
    Nov 2018
    Location
    Posts
    47
    Uploads
    0
    Comments
    15

    Default Re: MUGEN AI Tutotial (Winane's method)

    What's the point of the CPU1, CPU2 etc. commands?

  20. #20
    mulambo is offline wicked and toxic user banned for repeated defamation, spreading plain lies with clear intent to damage people's reputation and/or ruin people's motivation
    Join Date
    Aug 2016
    Location
    Posts
    1,733
    Uploads
    70
    Comments
    55

    Default Re: MUGEN AI Tutotial (Winane's method)

    Quote Originally Posted by DesertRose View Post
    What's the point of the CPU1, CPU2 etc. commands?
    those are commands impossible to perform by a human, but possible to CPU and they activate the var(59) which is triggered by each command assigned to the AI system. It means that any time CPU does that command, it activates the variable (1). I don't know what's their point neither, but you can try without them if the system still works.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 34
    Last Post: Dec 02, 2023, 10:44
  2. Replies: 90
    Last Post: Jul 07, 2020, 14:06
  3. Replies: 3
    Last Post: Nov 23, 2017, 23:29
  4. Replies: 16
    Last Post: Nov 23, 2017, 18:53
  5. Best Computer Storage Method
    By Fyreonix in forum Video Games & Computers
    Replies: 6
    Last Post: Oct 08, 2016, 03:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •