Coding Question

Started by SerenityFirefly, January 11, 2011, 07:07:52 PM

Previous topic - Next topic

SerenityFirefly

hey guys. Im starting to get into AI coding and i had a question that you experts can help me on.  I was going through some of other peoples AI coding work and i was wondering when your setting the AI Triggers whats the difference between this:

type = Varset
triggerall = var(59) != 1
trigger1 = command = "CPU1"
trigger2 = command = "CPU2"
trigger3 = command = "CPU3"
trigger3 = command = "CPU4"
trigger3 = command = "CPU5"
trigger3 = command = "CPU6"
trigger3 = command = "CPU7"
trigger3 = command = "CPU8"

and this

type = Varset
triggerall = var(59) != 1
trigger1 = command = "CPU1" || command = "CPU2" || command = "CPU3" || command = "CPU4"
trigger2 = command = "CPU4" || command = "CPU6" || command = "CPU7" || command = "CPU8"

i guess im asking what the "||" means

thanks for your help


2OS

#1
"||" means "Or"

Both methods of coding have the exact same meaning, there is absolute zero difference

SerenityFirefly

thank you...oh sorry one last question.
does a single | mean or as well ?


2OS


SerenityFirefly

so what does a singe | mean.

Thanks again for bearing with my noob questions

Thanks

2OS


Cyanide

I'm also going to ask, are you using mugen 1.0 at all? Because all that requires is

trigger1 = ailevel != 0

for a global AI. Or you can set values to make things harder as it takes from 0-8 as parameters. 0 means not under PC control, 1-8 is the varying levels of difficulty. Much easier and more reliable than the old method. Course that's only if you're using 1.0. If you're not what you have is fine if a bit slow.


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.

SerenityFirefly

Thanks 2OS for that link..and to Cyanide i am using 1.0 and am starting to use the ailevel. I can also use

trigger1 = !ailevel (as well right)

btw thanks you guys. I was reading up on the thread about Ai coding and you guys are providing great tips thanks.

SerenityFirefly

sorry also forgot to ask..now that im using Ailevel i do not have to set the
type = Varset

cause Ailevel is global and be put in human contolled states as
triggerall = !ailevel

and in the AI states as
triggerall = ailevel

2OS

#9
You don't need a varset no, the AILevel trigger is the replacement of the var

So instead of this

type=varset
triggerall=roundstate=2
triggerall=var(59)!=1
trigger1=command = "CPU1" || command = "CPU2" || command = "CPU3" || command = "CPU4"
trigger2=command = "CPU4" || command = "CPU6" || command = "CPU7" || command = "CPU8"
var(59)=1



[State 2OS, Light Punch AI]
value=200
type=selfstate
triggerall=var(59)=1
trigger1=(p2bodydist x=[-50,50])&&statetype!=a&&ctrl
trigger1=enemynear,statetype!=a

You'd replace everything in bold, with a simple AILevel trigger

[State 2OS, Light Punch AI]
value=200
type=selfstate
triggerall=ailevel>=1
trigger1=(p2bodydist x=[-50,50])&&statetype!=a&&ctrl
trigger1=enemynear,statetype!=a


Of course if you're doing variant levels like I do, you'd sort the AILevel accordingly, I personally do 3 levels per project, easy, normal, and hard, so, my set up, is this


[State 2OS, Light Punch Easy AI]
value=200
type=selfstate
triggerall=(ailevel=[1,2])
trigger1=(p2bodydist x=[-50,50])&&statetype!=a&&ctrl
trigger1=enemynear,statetype!=a

[State 2OS, Light Punch Normal AI]
value=200
type=selfstate
triggerall=(ailevel=[3,5])
trigger1=(p2bodydist x=[-50,50])&&statetype!=a&&ctrl
trigger1=enemynear,statetype!=a

[State 2OS, Light Punch Hard AI]
value=200
type=selfstate
triggerall=(ailevel=[6,8])
trigger1=(p2bodydist x=[-50,50])&&statetype!=a&&ctrl
trigger1=enemynear,statetype!=a


You'll note in mugen 1.0's option menu that there is a FUNCTIONING difficulty level setting, 1-2 literally has the word "Easy" next to it, 3-5 "Normal", and 6-8 "Hard"

So if you were to adjust the AI on anything I release, for the most part it'd be JUST like a real game, the setting reflects on how aggressive it is

SerenityFirefly

cool i also assume that if i didnt put anything next to the ailevel ie

triggerall=ailevel

It will be at whatever level you set in the options menu in mugen

2OS

that's the same as ailevel>=1, yaa, or ailevel>0, or ailevel!=0

SerenityFirefly

coolio..i might have some more questions as they come up thanks

SerenityFirefly

hey guys so another question came up.

Im trying to code the AI to randomly throw a projectile. Nothing to complicated for starters. Basically im comfused on how to write it. Let me explain. So i know the value of the animation to start the projectile is 1000, but its 1000 for all three kinds...ie the lp ver shoots it down, the mp goes straight and the hp goes up.  How can you write the AI so that it varies between the three.. I tried just putting in the 1000 like so

[State -1,AI Blast]
type = ChangeState
value = 1000
triggerall = AIlevel
triggerall = roundstate = 2
triggerall = statetype != A
triggerall = !NumProj
trigger1 = ctrl
trigger1 = Command = "QCFx"

now i know i dont really need the command code cause its for AI but i thought that might differentiate between the three if i put the command code for the specific one for the AI to throw. then of course add a random trigger with a value to get it to come out certain amounts of time.

Also using this i only threw out the lp ver

Any help would be appreciated..and let me know if i was not clear

thanks


Cyanide

That's not enough information. Does the LP version always go to state 1000, just because they use the same animation it doesn't mean they use the same state.


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.

SerenityFirefly

Im not to sure where to find that information.  What i did was go into debug and manually throw a lp fireball, and its state is 1000, throw a mp and a hp version and its still 1000. Is the definition of what state does what located in the cns file not the cmd file?

2OS

Quote from: SerenityFirefly on January 14, 2011, 06:41:15 PM
Is the definition of what state does what located in the cns file not the cmd file?
[ Traditionally ] Yes

SerenityFirefly

Ah ha i see..ok so lets say for example that the state of lp fireball was 1000 mp was 1010 and sp was 1020. how would we code that?

Cyanide

Depends, do you want a specific fireball in a specific situation, or do you just want it to randomise between all 3 fireballs in the same situations?

This is basically what AI code is all about. YOU need to decide, we can't actually tell you.


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.

SerenityFirefly

Well i will eventually be writing code to do just specific stuff, but for now im looking just to randomize it just to see it working..then go in later and add more specific parameters.