Okami Posted March 6, 2012 Posted March 6, 2012 Whats up! Welcome to a Beginner Guide on AI Coding. Since there are a lot of AI tutorials that are a bit in depth, but not really helpful to others (DON'T KNOW WHY), Guess I'll post a tutorial on AI Coding. First, to start AI coding, YOU MUST KNOW HOW TO CODE A CHARACTER WITH SOME EXPERIENCE (Well at least understand the codes) (Important or you'll get confused like an idiot =x) First, there are 2 different methods of implementing AI in terms of compatibility: Var AI coding: Coding AI through variable activation. Usually having a var set at either the CMD or the CNS file. Use this to recognize if this is the player or not the player, and must include various cpu commands for AI through this method. NOT recommended since this is old AI coding, refer to mugendocs if you want to do the hard way for custom AI. Simple steps however: Varset - var(59) occasionally for AI activation Trigger - var(59) = 0 or var(59) > 0 to see if this is an AI command or Human Command Example: CPU COMMANDS : <- NEEDED, usually complex hard to implicate for humans [state -1, AI TRIGGER] <- TRIGGER FOR AI type = Varset <-VAR SETTING triggerall = RoundState = 2 <- Occurs if RoundState = 2 (ROUND START) trigger1 = command = "cpu1" <- make the commands like x,d,f,d,x,f,x -> etc 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" trigger11 = command = "cpu11" trigger12 = command = "cpu12" trigger13 = command = "cpu13" trigger14 = command = "cpu14" trigger15 = command = "cpu15" trigger16 = command = "cpu16" trigger17 = command = "cpu17" trigger18 = command = "cpu18" trigger19 = command = "cpu19" trigger20 = command = "cpu20" trigger21 = command = "cpu21" trigger22 = command = "cpu22" trigger23 = command = "cpu23" trigger24 = command = "cpu24" trigger25 = command = "cpu25" trigger26 = command = "cpu26" trigger27 = command = "cpu27" trigger28 = command = "cpu28" trigger29 = command = "cpu29" trigger30 = command = "cpu30" v = 7 <- Variable is 7 -> var(7) value = 1 <- Value is 1 -> var(7) = 1 Example of how this works: <- Duplication State Method - One for AI and One for You [state -1, Stand Medium Left Punch] ; Human State type = ChangeState value = 900 triggerall = var (7) != ; Trigger for When var(7) != 1 -> Its Human! triggerall = command = "Stand Medium Left Punch" ; Human Command trigger1 = statetype != A ; Your state should not be equal to A - Hence AIR trigger1 = ctrl ; You Have Control trigger2 = (stateno = 200 || stateno = 210 || stateno = 400 || stateno = 410 ) && movecontact trigger3 = (stateno = 901 && time > 17) && movecontact trigger4 = (stateno = 902 && time > 28) && movecontact trigger5 = (stateno = 903 && time > 10) && movecontact Triggers 1-5 are the conditions when it can happen and how many it can be linked or duplicated Important as you can use more complex triggers for better custom AI [state -1, Stand Medium Left Punch AI] AI State State type = ChangeState value = 900 triggerall = var (7) Trigger for When var(7) = 1 -> Its CPU triggerall = !Win ; Don't need but usually AI turns on if the AI did not win and won't go again after win. triggerall = P2bodydist X = [0,20] Move should occur if p2bodydist x is around 0-20 pixels triggerall = P2StateType != L Move should occur if p2statetype is not lying down trigger1 = statetype != A Can't do this move in AIR to prevent bugs in AI trigger1 = ctrl AI must have control to use this trigger1= random <= 300 Not recommended way to do random, you can use triggerall = random <= (expression) for better transition trigger2= random <= 300 trigger3= random <= 300 trigger4= random <= 300 trigger5= random <= 300 trigger2 = (stateno = 200 || stateno = 210 || stateno = 400 || stateno = 410 ) && movecontact trigger3 = (stateno = 901 && time > 17) && movecontact trigger4 = (stateno = 902 && time > 28) && movecontact trigger5 = (sta teno = 903 && time > 10) && movecontact Triggers 2-5! IMPORTANT FOR AI linking combos and states for better AI Note: AI can be scaled through variable by having a variable placed in the random with an expression, must be for moderate coders only =P Advantages : Can be used for custom combos really well, if you know how to code more complex triggers and using other triggers and expressions. Disadvantages: Coding may be complex, and CPU commands tend to override Human commands. Basically, ending up being controlled by the CPU while you SUPPOSE to play. Note: You can have one state for both AI and Human, just set it different triggers and don't use triggeralls that only apply to AI or Human or it will cause errors. This is the old method to use, but I recommend the AILevel method. AILevel Method Coding: This method of Coding is the most up to date and the best way to code characters as it includes a very handy feature: Adjustable Diffuculties! There is no need to include CPU commands or variables to activate AI, however, you can use complex expressions and vars for AI custom combos and human commands. Example: -> You can do it the Duplication State Way NOTE: For Human Commands YOU MUST HAVE TRIGGERALL = !AILEVEL TO SPECIFY THAT YOU ARE NOT AI While Triggerall = AIlevel is applied to CPU commands. [state -1, Lotus Sinking Fangs AI] type = ChangeState value = 1200 triggerall = AIlevel ; Applied if AI is activated triggerall = random <= AIlevel*10 ; AI level is based on level 1 - 8 - AIlevel is multipled by 10 meaning at AIlevel = 8 it has a 80% change of this move happening with 80% of the triggers that is activated. triggerall = p2bodydist x = [0,20] ; Distance trigger as explained above triggerall = power >= 3000 ; IMPORTANT, AI MUST HAVE THIS TRIGGER OR ELSE THEY CAN SPAM SUPER! trigger1 = statetype = S ; Has to stand to activate move trigger1 = ctrl ; AI is in control You can have more triggers to activate this move more by adding other expressions and more triggers. Most you probably need is 10 for triggers, for 10 different outcomes * state triggers outcomes in other states. THIS WAY OF CODING IS EASIER AND IT IS RECOMMENDED TO BE USED FOR BEGINNERS Moderate and Expert Coders Occasionally Use Vars and AIlevel coding together for Good AI, but AIlevel is all you really need for AI activation, and triggers are used to define the right trigger to make the move work without bugs and to work properly for AI NOTE: IF any questions is asked, I will answer and update this post and give feedback on it! NeoGeoKitsune, Mugen4Anthony and lyr 3 Milla Maxwell - Spirit Guardian of Reize Maxia
Yagami Brando Posted March 6, 2012 Posted March 6, 2012 Thanks for the info. I'd like to make hard-AI patch for Kamui. Wait.. YOU MUST KNOW HOW TO CODE A CHARACTER WITH SOME EXPERIENCE ..well not even worth trying then I guess xDD My youtube channel
Okami Posted March 6, 2012 Author Posted March 6, 2012 Thanks for the info. I'd like to make hard-AI patch for Kamui. Wait.. ..well not even worth trying then I guess xDD Not that hard lol, it just simple expressions, take your time and you can learn from it. Milla Maxwell - Spirit Guardian of Reize Maxia
NeoGeoKitsune Posted March 6, 2012 Posted March 6, 2012 thanks for the very informative tutorial vector , it doesn't look too difficult to comprehend so i'm going to try coding A.I. when i have the time to spare "I’m Cyan Garland, Captain of the Prairia Palace Guards." - Cyan Garland [Tail Concerto]
AngerLus Posted March 7, 2012 Posted March 7, 2012 Thanks man , it's very usefull :) ---†• Be Somewhere •†---
*BlueRoses Posted July 21, 2012 Posted July 21, 2012 I have read your totutal and try it in Q.cmd with Fighter Factory 3. I cause this error:
Okami Posted July 21, 2012 Author Posted July 21, 2012 AIlevel is only for 1.0, not winmugen. You have to use a variable for Winmugen. Milla Maxwell - Spirit Guardian of Reize Maxia
GohanSSM2 Posted July 22, 2012 Posted July 22, 2012 Thanks Vector and like you said 'for beginners'. AI Level is unique to MUGEN 1.0 so use wisely and convert stuff up when possible. Alos, for 'advanced' stuff, AI is used to keep the computer from doing stuff that may cause a character to go into a 'tired' or helpless state. Several other things can be done with AI as well, but its nice to tinker with. But also note that if you don't know what you're doing for sure, playing with the AI can be a nightmare (always have a backup version of a character you are tinkering with). Anyway, I remember back when Reu was doing Evil Ryu with King Tigre and I emailed Reu to let him know that a ~F,b with time = 1 or such command he used could also actually be done by a player which would set off AI mode while playing the character in person vs. person mode or such. Reu then relegated Evil Ryu to "AI only" type status (like Psycho Shredder and the like). Nice tutorial Vector.
RAMza Posted August 1, 2012 Posted August 1, 2012 i have a question related to AI? some chars suddenly gets possessed by their AI, so how do you stop that?
Okami Posted August 1, 2012 Author Posted August 1, 2012 The use of variables on AI, it happens mostly because of Winmugen coding. It is faulty and it tends to have errors like those. Another reason could be that the creator used the wrong triggers and could possibly lead to the AI taking over. Milla Maxwell - Spirit Guardian of Reize Maxia
centella Posted July 19, 2015 Posted July 19, 2015 The AI method with variable, must be applied in CMD file, using commands of cpu y activated in statedef -1, then use routines of each atack with a percent of time, if are codified good, then will no errors, this method applied winmugen and mugen 1.0. I do AIs for ninja slayer and rugal of Jin, the result of my work are good. I have a question about the method of AILevel, must be in CMD file? or another file? I probe in CMD File and mugen 1.0 accepted, now I will test the AI, and do more AIs, is very easy do this. thanks, sorry my bad english
Celest Posted November 22, 2015 Posted November 22, 2015 Imma just read this. I kinda need it considering the way I get my Ws so easily. But thanks for this
adallas18 Posted February 13, 2018 Posted February 13, 2018 I'm just looking for how to change the AI of each specific mugen char. i know you can go into the data folder to the MUGEN.cfg and change it there but that changes it for all, i just wanna know where to change it inside the character's cfg file? or wherever it is
ReneO93 Posted October 17, 2020 Posted October 17, 2020 On 2/13/2018 at 11:40 AM, adallas18 said: I'm just looking for how to change the AI of each specific mugen char. i know you can go into the data folder to the MUGEN.cfg and change it there but that changes it for all, i just wanna know where to change it inside the character's cfg file? or wherever it is Usually, under statedef -1 in the cmd file. Sometimes, other people use the state -2 under some CNS file. It doesn't really matter, as long as you know what you're doing.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now