YesNoOk
avatar

AI coding? (Read 714 times)

Started by sgn15, October 11, 2010, 08:45:58 am
Share this topic:
AI coding?
#1  October 11, 2010, 08:45:58 am
  • ***
i saw this video but i still dont get it to work
http://www.youtube.com/watch?v=iCi9Tta1_Bk

i used his codes and tried to make a group of codes for example state 200

[state -1, Standing Light Punch]
.
.
.
.
.

then i made an AI version like he did in the video

[State -1, Stand Light Punch AI]
type = ChangeState
value = 200
triggerall = command = "x"
triggerall = command != "holddown"
trigger1 = statetype = S
trigger1 = ctrl

i used this method in many states
then i tried it in watch mode the char AI still sucks

so is there a better tutorial for AI coding?

i want my char's AI to charge then attack. because right now my char always charging even if power is already full
Re: AI coding?
#2  October 11, 2010, 09:45:23 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Labeling it "stand light punch AI" doesn't make it AI. You could label it "hyper mega kick" when it was in fact a taunt and it would have no effect on the move itself. It's JUST an identifier to make debugging easier.

In winmugen AI involves setting a variable in such a way that a human is incapable of doing. In 1.0 AI means using the AIlevel trigger (easier and 100% more reliable)

Once you know the AI is on (or have detected it) you can then trigger moves on that variable/value rather than command.

For example, my AI variable is var(59) and if it is 1 my AI is turned on

[mcode][state -1]
type = changestate
triggerall = var(59) = 1 && roundstate = 2
trigger1 = ctrl
trigger1 = statetype != A
trigger1 = random < 80 && p2dist X< 90
value = 200[/mcode]

That is basic and what AI should look like. You'll note there is no command in there. I have also used Random to decrease how much it happens and p2dist to prevent it being thrown out if p2 is too far away.

Also, if the dude in the video told you to do what you've actually done, please don't use any more of his videos.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

2OS

Re: AI coding?
#3  October 12, 2010, 05:27:56 am
  • ****
  • Ich schicke dich zur HOELLE ! ¡ ! ¡
    • Egypt
    • deuceovspadez.webs.com/
If the dude in the video told you to do what you've actually done, please don't use any more of his videos.
^ Disregard this


I learned AI from that particular video, actually watch the entire thing and take your time, you'll eventually get it

The little bit that I learned from this video enabled me to do variant adjustable AI levels with WINmugen [ Which I'm still using cos 1.0's sound system disappoints the everloving shit out of me ]








Part of the video says to make a fuckload of ""Impossible commands"" [ 35 to 50 will do ]


Spoiler: AI Commands (click to see content)

Then, make a variable using those commands


Spoiler: AI Variable (click to see content)

THEN start creating your AI


Spoiler: Powercharge for AI (click to see content)


EDIT — With Mugen 1.0 you can skip the first two spoilers [ Holy shit right ? ], but only if you choose to [ You probly will ], since my own personal AI Code and Levels are more complex than average, I choose not to use this feature / method / w.e


You'd first need to add or edit a line in your .DEF

[Info]
name          = "Name"
displayname   = "DisplayName"
versiondate   = 10/11/2010
mugenversion  = 1.0
author        = "2OS"
pal.defaults  = 1,2



Spoiler: Powercharge for AI ( Mugen 1.0+ Only ) (click to see content)


[ 052012 ] Inazumachi 181/256  /  deviantART   /  2OS Grafphicsxz  Dead Anims ( Orochi/Mizuchi )  /  608's FX Volume 3
Last Edit: October 12, 2010, 05:43:20 am by 2OS
Re: AI coding?
#4  October 12, 2010, 06:46:30 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Couldn't watch it i was at work. As such it was IF it told him to do that. As it didn't he can continue can't he.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: AI coding?
#5  October 12, 2010, 07:21:09 am
  • ***
im coding for winmugen btw, not 1.0

2os, i used your first 2 spoilers to replace bovery23's codes (impossible commands and AI variable)
then for power charging, its like this?
my charging is state 8000
Quote
[State charging]
type=changestate
value=8000
triggerall=var(9)
triggerall=statetype!=a&&ctrl
triggerall=power!=powermax
triggerall=enemy,vel x<2||enemy(enemy,teammode=simul),vel x<2
triggerall=enemy,numproj<=0||enemy(enemy,teammode=simul),numproj<=0
triggerall=p2movetype!=a
trigger1=p2dist x>=175

for a normal attack its like this?   [i removed all commands as cyanide stated]

Quote
[State -1, Stand Light Punch AI]
type = ChangeState
value = 200
triggerall=var(9)
trigger1 = statetype = S
triggerall=statetype!=a&&ctrl
triggerall=enemy,vel x<2||enemy(enemy,teammode=simul),vel x<2
triggerall=enemy,numproj<=0||enemy(enemy,teammode=simul),numproj<=0
triggerall=p2movetype!=a

for button mashing attacks, i did the same and added the "trigger1 = time >= 10 && stateno = 203 && movecontact" style for button-mashing but when i tried my char in watch mode it only uses the first attack (of button mashing attacks)

for attacks with power requirements i added the power requirement then i tried my char in watch mode it can spam the special attack (which has power requirements) even if the power is 0,
Last Edit: October 12, 2010, 07:53:04 am by sgn15
Re: AI coding?
#6  October 12, 2010, 08:03:07 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Does it do what you want it to? That's really the important question. His code is functional but that's just for one attack and MIGHT not be what you want to achieve.

You still need the impossible commands to turn the AI on. That's what it's for. If you don't have them then var(9) is never 1 unless you put it there manually, at which point you lose control of the character. Rewatch the video, do the whole thing from start to finish and pay attention.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

2OS

Re: AI coding?
#7  October 12, 2010, 08:29:01 am
  • ****
  • Ich schicke dich zur HOELLE ! ¡ ! ¡
    • Egypt
    • deuceovspadez.webs.com/
Yea the charging looks good to go


You're gonna wanna stop the charging with some opposite conditions tho [ You'd put this one IN the charge state itself, you'd also put ""triggerall=!var(9)"" in the changestate that's already there ]


[State stop charging]
type=changestate
triggerall=!var(9) ;;  AI Variable isn't active
trigger1=command!="hold z"&&command!="hold c"  ;; Not holding charge commands
value=0
ctrl=1

[State stop charging AI]
type=changestate
triggerall=var(9) ;;  AI Variable is active
triggerall=statetype!=a&&ctrl  ;; Not in an aerial state and has control [ Control = States where you have actual control ( Walk and Crouch states being examples ) ]
trigger1=power=powermax  ;; Power is at maximum
trigger2=enemy,vel x>2||enemy(enemy,teammode=simul),vel x>2  ;; Players 2 and / or 4 are somewhat aggressive in terms of horizontal speed
trigger3=enemy,numproj>0||enemy(enemy,teammode=simul),numproj>0  ;; Players 2 and / or 4 have existing projectiles on screen
trigger4=p2movetype=a  ;; Players 2 and / or 4 are in an attack state
value=0
ctrl=1


[ 052012 ] Inazumachi 181/256  /  deviantART   /  2OS Grafphicsxz  Dead Anims ( Orochi/Mizuchi )  /  608's FX Volume 3
Re: AI coding?
#8  October 12, 2010, 09:27:17 am
  • ***
im getting confused.
heres all i have done so far

Spoiler, click to toggle visibilty

Spoiler, click to toggle visibilty

Spoiler, click to toggle visibilty

results:
1. when i play as my char, its always moving (without me controlling it) i cant do anything
2. in watch mode, it only does state 200 and power charging repeatedly. it doesnt even walk or jump
Re: AI coding?
#9  October 12, 2010, 09:47:21 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
2OS: You've gone too complicated. He's got no clue at all and all the optimisation and fancy shit is taking over the important things.

Your commands look fine. I would say if he's doing things even under YOUR control you are already using var(9) somewhere else. Your AI variable should be spare and not in use by the character.

[mcode][State -1, Stand Light Punch AI]
type = ChangeState
value = 200
;triggerall=var(9)
trigger1 = statetype = S
triggerall=statetype!=a&&ctrl
triggerall=enemy,vel x<2||enemy(enemy,teammode=simul),vel x<2
triggerall=enemy,numproj<=0||enemy(enemy,teammode=simul),numproj<=0
triggerall=p2movetype!=a[/mcode]

This has no random component and no command, and your AI version has no random either even though it has some combo stuff to it. So whenever all that is true you'll spam state 200. Try my code instead. You will still need a version of this that requires you to press X though.

[mcode][state -1]
type = changestate
triggerall = var(9) = 3 && roundstate = 2
trigger1 = ctrl
trigger1 = statetype != A
trigger1 = random < 80 && p2dist X< 90
value = 200[/mcode]
That says your AI is on (and i've chosen to pick the value 3 rather than just non zero as that's what you've set) roundstate = 2 means the fight portion of the battle rather than intro/winpose. Just a safeguard
ctrl means you mustn't already be doing something
statetype != A means not in the air. You must be in stand or crouch. Good for comboing off crouching moves
The LAST trigger is the one most important to you. Random < 80. This is evaluated every tick and gives a different value no matter how many randoms you have. What i have there is an 8% chance of him doing LP every tick.
The next part of it ensures he only makes use of that 8% chance if P2 is close.

This will create something that works. After you have something that works you put extra things in place like whether P2 is in the air or if he's attacking with a projectile. Stuff that you don't want your character to attack for.

Slow down a wee bit. Nobody really does everything with AI all at once, they do it in bits and confirm the AI is doing the move with the frequency required in the correct situations. Build it up. Get a move activating and then string it round with safeguards and intelligence.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: AI coding?
#10  October 12, 2010, 11:55:29 am
  • ***
im getting confused.
heres all i have done so far

Spoiler, click to toggle visibilty

Spoiler, click to toggle visibilty

Spoiler, click to toggle visibilty

results:
1. when i play as my char, its always moving (without me controlling it) i cant do anything
2. in watch mode, it only does state 200 and power charging repeatedly. it doesnt even walk or jump

k i remove all codes in the 3rd spoiler here and tried cyanide's codes and added the button mashing

Spoiler, click to toggle visibilty

its not doing the button mashing attacks. and for the power charging (i removed the AI now), in the CNS for the power charging i made it so that it cant charge if the power is full like this:

Spoiler, click to toggle visibilty

in watch mode, the char has many instances where it does not do anything at all. it likes to charge its power still (after i made the change in CNS)

btw i still have this and the same for states 201 to 204
Spoiler, click to toggle visibilty
Last Edit: October 12, 2010, 11:58:58 am by sgn15
Re: AI coding?
#11  October 12, 2010, 06:03:08 pm
  • **
    • sites.google.com/site/mugensbestspritersintheworld/
Is there any "free" or open source Ai code or Ai coding tutorial?
Re: AI coding?
#12  October 12, 2010, 06:43:44 pm
  • ****
  • HAHAHAHAHAHAHAHA
    • Chile
Watch for Winane`s one. Pretty nice and gives you a good control over AI activations.
Re: AI coding?
#13  October 12, 2010, 07:42:18 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/

  • Online
Or switch to Mugen 1.0 and use the ailevel trigger.
Re: AI coding?
#14  October 13, 2010, 04:32:16 am
  • ***
Re: AI coding?
#15  October 13, 2010, 05:41:06 pm
  • ****
  • HAHAHAHAHAHAHAHA
    • Chile
Re: AI coding?
#16  October 14, 2010, 03:56:36 pm
  • **
    • sites.google.com/site/mugensbestspritersintheworld/

BC

Re: AI coding?
New #17  October 14, 2010, 05:29:30 pm
  • ****
    • UK
    • www.mugenevolution.co.uk/Forum
If the dude in the video told you to do what you've actually done, please don't use any more of his videos.
^ Disregard this


I learned AI from that particular video, actually watch the entire thing and take your time, you'll eventually get it

The little bit that I learned from this video enabled me to do variant adjustable AI levels with WINmugen [ Which I'm still using cos 1.0's sound system disappoints the everloving shit out of me

That was actually my video I made in 2008 lol, I was learning myself then but as basic as it was it does show you how to program AI into your character. It's not the best tutorial for AI I'll admit that, I'll have to make a better one in the future now I know alot more.
click the image to join my forum ;)
Last Edit: October 14, 2010, 05:33:16 pm by BC