Mugen ai tutorial

Mugen ai tutorial DEFAULT

Thread: Mugen Basic AI Tutorial with Sample Code

type = ChangeState-> You are setting the type of command you want the following definition to apply to
-> In this case you are telling Mugen let the following definitions cause the character to change to the State you set in the "value" field

value = -> In this case the state number you want to activate (Light Punch - State )

triggerall = statetype != A-> You are telling Mugen to not trigger this ChangeState definition at all if my character is in the air ("!=" implies "does not equal." Had this just been "=" it would mean DO this if my character's statetype is in the air"

triggerall = p2statetype != L-> You are telling Mugen to not trigger this ChangeState if the enemy is lying down

trigger1 = p2bodydist x <= 85-> You are telling Mugen to Trigger this ChangeState if the midpoint of P2's body (or it's axis or CLSNs) are at a distance of less than or equal to 85 pixels from my character (this can be seen in the debug information you displayed in previous steps

trigger1 = ctrl -> You are telling Mugen that if you are in a state (a neutral state) where you can generally freely interrupt into other states, trigger this ChangeState. So if you are in a state like a regular standing state, a regular crouching state, or a regular walking state, you may trigger this attack. By contrast you cannot trigger this state if you are performing a hadouken -- You can't interrupt in the middle of a regular hadouken animation into a Light Punch
Sours: https://mugenarchive.com/forums/
AI Generator

Creator

Netyzh

Download

MEGA

Version

AI Generator is a tool that automatically generates A.I. patches for characters that do not have custom A.I. It does this by calculating the frames and hitboxes of each move to determine when the character will use the move. The tool is best used as a starting point to making an A.I. patch, rather than a full substitute for custom A.I. A complete A.I. made with this will&#;improvise&#;based on the startup times of its attacks, its own distance from the opponent, and the length of the opponent's current animation. It also takes the opponent's y position and&#;head/mid.pos&#;into account, meaning it is less likely to use moves that will only go over the opponent's head or under an airborne opponent.

Steps

  1. Make a backup of the character.
  2. Make sure the character does not already have custom A.I.. If it does, you can still remove the A.I. coding.
  3. Copy and paste AI Generator's files into the character folder. If there's already a common1.cns, don't overwrite it.
  4. If any .cmd, .cns, .st, or .air files are in their own subfolder, create a new folder named "AI-(the name of said subfolder)". For instance, if there is a CNS file in a folder called "CNS", you will need to create a folder called "AI-CNS". It is unnecessary to copy the files into the new folder, they will only be overwritten.
  5. Delete any spaces from any .cmd, .cns, .st, and .air file names and do the same for their entries in the character's DEF.
  6. Open a command prompt window in the character folder and run ai.exe or ai.py. It is not recommended to run it from Explorer because if it fails, the window will close immediately, not allowing you to read the error for troubleshooting.
  7. If there are multiple DEF files, it will ask you to specify which one to scan.
  8. The tool will now scan the DEF file and all .cmd, .cns, .st, and .air files it points to. If successful, there will be new files starting with "AI-". If it fails, consult the "Troubleshooting" section and make sure you've followed all previous steps.
  9. Open the new AI-.def file and make sure it has st entries pointing to aihelper2.cns and aisummary.txt. (For example, "st2 = aihelper2.cns" and "st3 = aisummary.txt".) They are usually there, but if not, you must manually add them. Without these entries, the character will still use the default A.I.
  10. Install the character folder into M.U.G.E.N like normal and enjoy.

Troubleshooting

  • If any file has non-ASCII characters, the tool will give a charmap error. At the beginning, the tool lists all files it's scanning. Open one of these files in Notepad++. Press CTRL+H to call the "Replace" window, tick "Regular Expression" under "Search Mode" in the bottom left, put [^\x\x7F]+ in "Find What", leave "Replace With" blank, and click "Replace All". This automatically deletes all non-ASCII characters. Repeat this process with the rest of the files in the scan list.
  • If it gives an "UnboundLocalError" relating to local variable "m0", try running ai.py instead of ai.exe. Otherwise it is unknown how to fix this error.
  • With ai.py, you may get the message "NameError: name 'n' is not defined". This is caused by too many human player commands in the CMD.
  • If M.U.G.E.N crashes while trying to load a match, it is likely related to aisummary.txt. Refer to the crash message for the problematic character and the specific line in aisummary.
  • If the character seems like it's still using M.U.G.E.N's default A.I., make sure that the character entry in select.def is pointing to the DEF beginning with "AI-" and not the original DEF. Also check the AI-.def and make sure it's referencing aihelper2.cns and aisummary.txt. (Refer back to step 9.)

Limitations

AI Generator struggles with moves that use helpers and will not generate coding for them, so the character will never use them. Likewise, it will skip past most moves that aren't attacks, with the exception of moves with universal state values like dashes.&#;If the xscale and/or&#;yscale value in the coding for the character uses a decimal, AI Generator will round down when it uses the decimal in its calculations, resulting in skewed attack spacing. For attacks with multiple hitboxes, it will only use the hitbox closest to the character in its calculations, meaning the character will typically only use longer-ranged moves when close up. It is recommended for a more experienced programmer to learn the calculations the tool uses and manually add any moves the tool skipped over, along with tweaking distance values. It also uses the WinMUGEN style of A.I. activation, so it will not always activate right away and will not use the in-game difficulty levels. Users of M.U.G.E.N and above can fix this by simply opening aisummary.txt and replacing the activation triggers with a single "AILevel > 0" trigger, though they will still have to find their own way of incorporating the actual A.I. levels.

Sours: https://mugen.fandom.com/wiki/AI_Generator
  1. Easy a imdb
  2. Aws region code
  3. Starbucks girl meme
  4. Clover vs toast
  5. Hays county jail

 Quick AI patch tutorial

The Mugen Multiverse

Welcome!!! - Bienvenidos!!! - ( We hope you will get involved in the MMV Community which is dedicated to having fun with Mugen ) - Bienvenidos!!! - Welcome!!!
 
 Go down 
AuthorMessage
BigPimp



Posts :
Join date :
Age : 30
Location : Russia

Quick AI patch tutorial Empty
PostSubject: Quick AI patch tutorial   Quick AI patch tutorial EmptyJanuary 28th , am

So i was always bummed out when characters in 1 mugen game have vastly different AI
and i found a quick and good way to add it. works great so far (but only tested on Marvel/Capcom characters)
all code parts are taken from IMT marvel characters, so this custom AI will be basically the same, which is used in AvX/Project X

so, first of all, you have to make sure character doesnt have any custom AI in place. if it does, you will need to replace it
it sounds difficult, if you never edited AI before, but its actually pretty easy, since most of the characters have the same AI code pattern. but i would suggest to try this method on character with no custom AI first, and then, when you successful in that, go a step further and replace existing custom AI

1st part is really easy. it will make you no-AI character to have combos and proper defence
1st step of this 1st part is to just copy this text segment to the beggining of .cmd file, before all special/hypers input commands:

Spoiler:
 

;-| AI Commands |

;-| AI |
[Command]
name = "CPU1"
command = U, D, F
time = 1

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

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

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

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

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

[Command]
name = "CPU7"
command = F, F, B
time = 1

[Command]
name = "CPU8"
command = U, D, U
time = 1

[Command]
name = "CPU9"
command = F, B, B
time = 1

[Command]
name = "CPU10"
command = F, F, B, B
time = 1

[Command]
name = "CPU11"
command = U, U, F
time = 1

[Command]
name = "CPU12"
command = U, B, B
time = 1

[Command]
name = "CPU13"
command = U, B, F, F
time = 1

[Command]
name = "CPU14"
command = U, F, B, U
time = 1

[Command]
name = "CPU15"
command = U, B, F, U
time = 1

[Command]
name = "CPU16"
command = U, B, B, B
time = 1

[Command]
name = "CPU17"
command = U, D, B, F
time = 1

[Command]
name = "CPU18"
command = U, D, B, D
time = 1

[Command]
name = "CPU19"
command = U, D, F, U
time = 1

[Command]
name = "CPU20"
command = U, D, U, B
time = 1

[Command]
name = "CPU21"
command = U, D, F, F
time = 1

[Command]
name = "CPU22"
command = F, F, F, F
time = 1

[Command]
name = "CPU23"
command = U, U, U, D
time = 1

[Command]
name = "CPU24"
command = B, B, B
time = 1

[Command]
name = "CPU25"
command = D, D, D, D
time = 1

[Command]
name = "CPU26"
command = D, D, D
time = 1

[Command]
name = "CPU27"
command = F, F, F
time = 1

[Command]
name = "CPU28"
command = U, U, U
time = 1

[Command]
name = "CPU29"
command = U, U, B, B
time = 1

[Command]
name = "CPU30"
command = D, D, F, F
time = 1


second step is pretty similar. you need to copy this part AFTER [statedef -1] to the same .cmd file

Spoiler:
 

[State -1, AIActivate]
type = VarSet
triggerall = var(59) != 1
triggerall = RoundState != 3
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"
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"
var(59) = 1

;======================================================================
;===========================================================================
;======================================================================
; A.I Commands
;

;====================================================================
;GUARD/BLOCK CODE
;====================================================================

[State -1, standGuard]
type = ChangeState
triggerall = var(59) && random <=
triggerall =(StateType != A) && (Ctrl)&& (enemynear, Facing != Facing)
trigger1 = (P2StateType != C) && (P2MoveType = A)
;trigger2 = inguarddist  
value =

[State -1, airGuardHitBack]
type = ChangeState
triggerall = var(59) && random <=
triggerall =(StateType != A) && (enemynear, Facing != Facing)
triggerall = (P2StateType = C) && (P2MoveType = A)  
trigger1 = StateNo =
;trigger2 = inguarddist  
value =

[State -1, crouchGuard]
type = ChangeState
triggerall = var(59) && random <=
triggerall = (StateType != A) && (Ctrl) && (enemynear, Facing != Facing)
trigger1 = (P2StateType = C) && (P2MoveType = A)  
;trigger2 = inguarddist  
value =

[State -1, standGuardHitBack]
type = ChangeState
triggerall = var(59) && random <=
triggerall =(StateType != A) && (enemynear, Facing != Facing)
triggerall = (P2StateType != C) && (P2MoveType = A)
trigger1 = StateNo =
;trigger2 = inguarddist  
value =

[State -1, airGuard]
type = ChangeState
triggerall = var(59) && random <=
triggerall = (StateType = A) && (Ctrl) && (enemynear, Facing != Facing)
trigger1 = P2MoveType = A
;trigger2 = inguarddist  
value =

;
;&& (StateNo = ) && (MoveHit = 1)

;
;Super Jump
[State -1, Super Jump]
type = ChangeState
value =
triggerall = (StateType != A) && Var(59) && random <
trigger1 = (StateNo = ) && (MoveHit = 1)
trigger2 = (enemynear, Vel X >= 4) && ctrl


;====================================================================
; Main Standing Special

;
; Fwd Dash
[State -1, FwdDash]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && ctrl  && prevstateno != && random <
triggerall = (statetype = S) && enemynear, p2dist X >= 50
triggerall = Var(20) != 3 && NumHelper(25) = 0 && p2bodydist x > 50
trigger1 = enemynear, movetype != A && enemynear, numproj = 0 && enemynear, statetype != L
trigger2 = enemynear, statetype = L && random <= && enemy, numproj = 0

;====================================================================
; Stand, Crouch, Jump / Punch, Kick - NORMAL (only 3 punches/kicks)
;====================================================================

;
; Standing basics
;
; Punches: , ,
; Kicks: , ,
;
;crouch Strong punch (launcher)
[State -1, Crouch launcher]
type = ChangeState
value =
triggerall = var(59) && ctrl && random <
triggerall = StateType != A && MoveType != H && RoundState = 2 && !IsHelper
trigger1 = p2bodydist X <= 20 && (enemynear, anim = ) && (StateNo = ) && movehit
trigger2 = p2bodydist X <= 20 && (enemynear, statetype != A) && Random = [,]
; Stand Light Punch
[State -1, Stand Light Punch]
type = ChangeState
value =
triggerall = (statetype = S) && var(59) && p2statetype != L && RoundState = 2
trigger1 = ctrl = 1
trigger1 = (enemynear, p2dist x <= 60 && enemynear, movetype != A && Random <= )

;
; Stand Medium Punch
[State -1, Stand Medium Punch]
type = ChangeState
value =
triggerall =(statetype = S) && var(59) && p2statetype != L && RoundState = 2

; (chain combos)
trigger1 = (stateno = ) && (movecontact >= 1)

;
; Stand Hard Punch
[State -1, Stand Hard Punch]
type = ChangeState
value =
triggerall = var(59) && p2statetype != L && RoundState = 2
triggerall = statetype = S

; (chain combos)
trigger1 = ((stateno = ) || (stateno = )) && (movecontact >= 1)
trigger2 = ctrl = 1
trigger2 = (enemynear, p2dist x <= 60 && enemynear, movetype != A && Random <= )

;
; Stand Light Kick
[State -1, Stand Light Kick]
type = ChangeState
value =
triggerall =(statetype = S) && var(59) && p2statetype != L && RoundState = 2
trigger1 = (enemynear, p2dist x <= 60 && enemynear, movetype != A && (Random <= && random >)) && ctrl

;
; Stand Medium Kick
[State -1, Stand Medium Kick]
type = ChangeState
value =
triggerall = var(59) && p2statetype != L && RoundState = 2
triggerall = statetype = S

; (chain combos)
trigger1= (stateno = ) && (movecontact >= 1)

;
; Stand Hard Kick
[State -1, Stand Hard Kick]
type = ChangeState
value =
triggerall = var(59) && enemynear, statetype != L && RoundState = 2
triggerall = statetype = S
; (chain combos)
trigger1 = ((stateno = ) || (stateno = )) && (movecontact >= 1)
trigger2 = ctrl = 1
trigger2 = (enemynear, p2dist x <= 60 && enemynear, movetype != A && Random <= )

;
; Crouching basics
; Punches: , ,
; Kicks: , ,
;
; Crouch Light Punch
[State -1, Crouch Light Punch]
type = ChangeState
value =
triggerall = var(59) && statetype = C && RoundState = 2 && ctrl
trigger1 = (enemynear, p2dist x <= 60 && enemynear, movetype != A && (Random <= && random >))

;
; Crouch Medium Punch
[State -1, Crouch Medium Punch]
type = ChangeState
value =
triggerall = var(59) && statetype = C && RoundState = 2 && ctrl

; (chain combos)
trigger1 = (stateno = ) && movecontact

;
; Crouch Hard Punch
[State -1, Crouch Hard Punch]
type = ChangeState
value =
triggerall = var(59) && statetype = C && RoundState = 2

; (chain combos)
trigger1 = (stateno = ) && movecontact

;
; Crouch Light Kick
[State -1, Crouch Light Kick]
type = ChangeState
value =
triggerall = var(59) && statetype = C && RoundState = 2 && ctrl
trigger1 = (enemynear, p2dist x <= 65 && enemynear, movetype != A && (Random <= && random >))

;
; Crouch Medium Kick
[State -1, Crouch Medium Kick]
type = ChangeState
value =
triggerall = var(59) && statetype = C && RoundState = 2 && ctrl

; (chain combos)
trigger1 = (stateno = ) && movecontact

;
; Crouch Hard Kick
[State -1, Crouch Hard Kick]
type = ChangeState
value =
triggerall = var(59) && statetype = C && RoundState = 2

; (chain combos)
trigger1 = (stateno = ) && movecontact

;
; Air basics
; Punches: , ,
; Kicks: , ,
;
; Air Light Punch
[State -1, Air Light Punch]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && stateno != && statetype = A && ctrl
trigger1 = p2dist X < 60 && (p2dist Y > -3 && p2dist Y < 3)

;
; Air Medium Punch
[State -1, Air Medium Punch]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && stateno != && statetype = A

; (chain combos)
trigger1 = (stateno = ) && movecontact

;
; Air Hard Punch
[State -1, Air Hard Punch]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && stateno != && statetype = A

; (chain combos)
trigger1 = stateno = && movecontact

;
; Air Light Kick
[State -1, Air Light Kick]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && stateno != && statetype = A

; (chain combos)
trigger1 = (stateno = ) && (movecontact = 1)

;
; Air Medium Kick
[State -1, Air Medium Kick]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && stateno != && statetype = A

; (chain combos)
trigger1 = (stateno = ) && movecontact

;
; Air Hard Kick
[State -1, Air Hard Kick]
type = ChangeState
value =
triggerall = var(59) && RoundState = 2 && stateno !=
triggerall = statetype = A && ctrl

; (chain combos)
trigger1 = stateno = && movecontact

;
;
; Air combo
[State -1, ChangeState]
type = ChangeState
triggerall = Var(59) && StateType = A
trigger1 = (StateNo = [,]) && (MoveContact)
value = IfElse(StateNo = ,,IfElse(StateNo = ,,))
persistent = 0

[State -1, ChangeState]
type = ChangeState
triggerall = Var(59) && StateType = A
trigger1 = (StateNo = [,]) && (MoveContact)
value = IfElse(StateNo = ,,)


this is basically universal for every marvel/capcom character. only 1 part which could be not compatible is super jump. it uses value= here, but some characters may use value= or a completely different one. so you might need to change it (if you not sure what im talking about, just put mugen in debug mode when testing character's new AI, and if you get an error messages "character changed to invalid state " you will need to search this "" in the second text segment, and replace it with a proper super jump value for this character. if you dont know or cant find this proper value, just completely remove super jump part from 2nd text segment, this one:
Spoiler:
 

;Super Jump
[State -1, Super Jump]
type = ChangeState
value =
triggerall = (StateType != A) && Var(59) && random <
trigger1 = (StateNo = ) && (MoveHit = 1)
trigger2 = (enemynear, Vel X >= 4) && ctrl


so, thats it for basic AI. in the next message i will describe how to put in AI specials/hypers


Last edited by BigPimp on January 28th , pm; edited 6 times in total

candido, yolomate and Splash like this post

Back to top Go down
View user profile
BigPimp



Posts :
Join date :
Age : 30
Location : Russia

Quick AI patch tutorial Empty
PostSubject: Re: Quick AI patch tutorial   Quick AI patch tutorial EmptyJanuary 28th , am

this part is a little more difficult, since it requires more of a personal touch
basically, there are 2 templates, 1 for specials, 1 for hypers. make sure you understand and can perform tutorial from the 1st message, before going to this one

so, here is a template for hyper:
Spoiler:
 

; mega beam
[State -1, megaBeam]
type = ChangeState
value =
triggerall = power >= && var(59) && ctrl && p2bodydist x >
triggerall = StateType != A && MoveType != H && RoundState = 2
trigger1 = enemynear, numproj = 0 && enemynear, movetype != A && random <


for it to work, you need to put it somewhere after [statedef -1] (just like 2nd text segment in 1st tutorial)
preferably, i would suggest to put if AFTER AI guard states. just search for "Main Standing Special" in that 2nd text segment from the 1st tutorial. thats where you need to put you custom AI hypers and specials

but thats not it. as you may know, specials and hypers are not as universal, as basic moves. in each special and hyper you will need to edit at least 2 lines. 1st line is the most important, it refers to which hyper/special character will use. im talking about "value=" line. usually capcom/marvel character hypers are coded under values. you will need to find exact correct values for each hyper for your character and edit value line for each hyper template you have copy-pasted. so if, lets say, character has 3 hypers, 1st is , 2nd is , 3rd is , the code segment for working hypers will be:

Spoiler:
 

; mega beam
[State -1, megaBeam]
type = ChangeState
value =
triggerall = power >= && var(59) && ctrl && p2bodydist x >
triggerall = StateType != A && MoveType != H && RoundState = 2
trigger1 = enemynear, numproj = 0 && enemynear, movetype != A && random <

; mega beam
[State -1, megaBeam]
type = ChangeState
value =
triggerall = power >= && var(59) && ctrl && p2bodydist x >
triggerall = StateType != A && MoveType != H && RoundState = 2
trigger1 = enemynear, numproj = 0 && enemynear, movetype != A && random <

; mega beam
[State -1, megaBeam]
type = ChangeState
value =
triggerall = power >= && var(59) && ctrl && p2bodydist x >
triggerall = StateType != A && MoveType != H && RoundState = 2
trigger1 = enemynear, numproj = 0 && enemynear, movetype != A && random <


now, the second line you will need to edit in this template is "p2bodydist x > ". basically it refers to, at what distance character AI will be able to use this hyper. edit it accordingly (meaning you want projectle hypers to be used from the distance, and close up hypers from upclose)

so, thats pretty much it. the only other line you might want to edit is "StateType != A". it means that character AI cannot use this hyper while in the air. you need to replace it with "StateType = A" if you coding a hyper, which can be used ONLY in the air. or remove "StateType != A && " completely, if we talking about a hyper which can be used BOTH from the air and from the ground. (in most cases those hypers still have different states, because of different animations, so you will probably just need to copy-past a separate template for air version of the same hyper)

putting in AI specials is pretty much the same, you just need to use this template instead:
Spoiler:
 

[State -1, beam]
type = ChangeState
value =
triggerall = var(59) && ctrl && p2bodydist x >
triggerall = StateType != A && MoveType != H && RoundState = 2
trigger1 = enemynear, numproj = 0 && enemynear, statetype != A && random <


also. a little additional note here. "random < " refers to how often character will spam this special/hyper, the higher the number, the more often it will try to perform it. hypers will require power though, so just leaving them all at is good enough in most cases
and you can also add any custom triggers for any more complicated/unique specials/hypers. but that basic code provided by AvX/Project X template is good enough for most cases


Last edited by BigPimp on January 28th , am; edited 4 times in total

candido and Splash like this post

Back to top Go down
View user profile
Shining

Shining

Posts :
Join date :
Age : 41
Location : Italy

Quick AI patch tutorial Empty
PostSubject: Re: Quick AI patch tutorial   Quick AI patch tutorial EmptyJanuary 28th , am

Interesting, useful post I will try in my two face
He needs AI

Back to top Go down
View user profile
candido

candido

Posts :
Join date :
Age : 22
Location : Philippines

Quick AI patch tutorial Empty
PostSubject: Re: Quick AI patch tutorial   Quick AI patch tutorial EmptyJanuary 28th , am

Very helpful for some people who'd like to make full game. Maybe in the future I will and will definitely use this as guide Very Happythanks Bigpimp cheers
Back to top Go down
View user profile
crosspotts

crosspotts

Posts :
Join date :
Age : 29
Location : GLEN BURNIE maryland

Quick AI patch tutorial Empty
PostSubject: Re: Quick AI patch tutorial   Quick AI patch tutorial EmptyJanuary 28th , pm

Archive this page some where here

Back to top Go down
View user profile
Sponsored content




Quick AI patch tutorial Empty
PostSubject: Re: Quick AI patch tutorial   Quick AI patch tutorial Empty

Back to top Go down
 

Quick AI patch tutorial

Back to top 
Sours: https://mugenmultiverse.forumotion.com/tquick-ai-patch-tutorial

Thread: 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 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 =
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 =
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 = < State no. of the animation you want the CPU to perform
triggerall = roundstate = 2 < Trigger during the fighting phase of the round "Round OneFight"
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 = ), 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 = < State no. of the animation you want the CPU to perform
triggerall = roundstate = 2 < Trigger during the fighting phase of the round "Round OneFight"
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 < < 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 = < State no. of the animation you want the CPU to perform
triggerall = roundstate = 2 < Trigger during the fighting phase of the round "Round OneFight"
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 < < 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 = && movehit< Trigger it in a combo when in stateno. and the move hit the opponent
trigger3 = stateno = && animtime = 0<--chain it to stateno. 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!

Sours: https://mugenarchive.com/forums/

Tutorial mugen ai

Someone to rob to have enough for a new dose. and much more. Moral aspect. Once I looked in the encyclopedia, we turn out to be perverts with Katena. Although, in my opinion, nonsense.

MI MUGEN Tutorial - How to add Ai patch to the Characters

Suddenly she jerked violently and froze. Who's first. I whispered in her ear. Let Volodya try first, she answered in a broken whisper. I pulled back and he climbed onto my wife.

Similar news:

Began to speak something in her ear. This caused a fit of indignation in me. Now I recognized this fat man. Yes, it was he who quarreled with her then in the office. Is this her husband.



725 726 727 728 729