AI sliding problem

Started by Fixer, February 09, 2017, 02:01:26 AM

Previous topic - Next topic

Fixer

I am learning the basics about AI coding and now i have this problem.
My char don't run but it slide instead, any tips?

Code:
[State -1, AI]
type = ChangeState
value = 100
triggerall = roundstate = 2
triggerall = var(59) = 1
triggerall = statetype = S
triggerall = statetype != A
triggerall = statetype != L
triggerall = p2bodydist x >= 20
trigger1 = ctrl = 1

Niitris

If ctrl=1 in StateDef 100, then the AI will keep going into 100. Make sure you have ctrl=0 in that state.

If that's not the problem, then it has to be another Changestate causing it to happen.

Fixer

It don't works man, and it will only be at 100 while the p2bodydist >= 20 is not it?
With 0 in the ctrl the char don't move at all and refuses to execute any other AI command.
Please i need to get rid of this damn slide.

Cyanide

You're allowing it to changestate to 100, while it's already in 100

try adding

triggerall = stateno != 100

to your code. It's not going to be perfect because the AI will probably flick in and out of it, you need to override the state itself to bypass the "holdfwd" triggers when in AI mode.


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.

Fixer

For some reason nothing have changed.
I only want the char to run to the anemy to keep with the combos that i've made once it don't have any ranged attack.
This is the only way to code the AI to run?
I don't understand why all my others commands works as expeced and i've done by the same way and this have that bug.

Example:

[State -1, fatality 1]
type = ChangeState
value = 3100
triggerall = roundstate = 2
triggerall = roundstate != 1
triggerall = var(59) = 1
triggerall = random < 400
triggerall = power >= 3000
triggerall = statetype = S
triggerall = statetype != A
trigger1 = p2statetype != L
trigger1 = p2bodydist x <= 50
trigger1 = ctrl

This one works fine and it's similar to the RF one.

XGargoyle

Run states have a condition that will end the state if the player is not holding forward. The AI doesn't actually hold the forward direction, and this is why the run stops.
For other attacks, they don't have the condition to keep holding a direction, this why they work fone for the AI.

If you want to fix it, you will need to override state 100 and add a controller only for the AI to stay in the state for some time or to stop when the enemy is at a certain distance, for example...

Also:

Quote[State -1, fatality 1]
type = ChangeState
value = 3100
triggerall = roundstate = 2
triggerall = roundstate != 1
triggerall = var(59) = 1
triggerall = random < 400
triggerall = power >= 3000
triggerall = statetype = S
triggerall = statetype != A
trigger1 = p2statetype != L
trigger1 = p2bodydist x <= 50
trigger1 = ctrl

You could remove the lines in bold, as they are redundant. If roundstate=2 then you don't have to check for a different roundstate.
Too many triggers or useless ones will slow down  mugen and leaves the door open to bugs or unexpected results


XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

Fixer

#6
Thanks man, but in that state i wanted the fatality to e done only in round 2/3 because in the end of round one theres no need for using it once the opponent is almost defeated and that was spending the char's power for "nothing". But i noticed that even using that "triggerall = roundstate != 1" my char STILL using the fatality in the round one. You know why?
PS: I already removed the human command for the AI for that special so thats probably not the problem.
PS2: I used roundno instead for this, i hope it works :)

Also please can someone tell me how to override the state 100?
I am learning mugen coding so i don't know what that means.

altoiddealer

Quote from: Fixer on February 10, 2017, 05:45:07 PM
Also please can someone tell me how to override the state 100?
I am learning mugen coding so i don't know what that means.
Any states in your character's CNS file, will automatically over-write the default ones found in common1.cns

So if you open up common1.cns from your MUGEN installation, and find State 100, you'll see the default run state.

Copy/paste this into your character's CNS file, then adjust the controllers so that if AI is detected, it behaves differently.

So adjust the ChangeState controller.  Here's a basic suggestion, but you can really do anything:
Spoiler: AI stops Running when close to enemy, or if 120 ticks have elapsed (click to show)

[State 100, Change to Stand]
type = ChangeState
trigger1 = !AILevel
trigger1 = command != "holdfwd"
trigger2 = AILevel
trigger2 = abs(P2BodyDist X) < 20 || Time > 120
value = 0


XGargoyle

Quote from: Fixer on February 10, 2017, 05:45:07 PM
But i noticed that even using that "triggerall = roundstate != 1" my char STILL using the fatality in the round one. You know why?
PS: I already removed the human command for the AI for that special so thats probably not the problem.
PS2: I used roundno instead for this, i hope it works :)

It fails because roundstate works in a total different way than you think or try to do


XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

Memo

Put roundno !=1 for the fatalitys so you can do them in final rounds, the ! Makes it
so you cant do it in round 1

Fixer

#10
@altoiddealer thanks for this man, now i understand what is a override and thanks for the code, i'll be using it.
edit: i pasted it in the cns but what about the code in the cmd? how it should looks like?

@XGargoyle i used the roundno and it works fine and now i know exactly what the roundstate do after reading the mugen docs hehe.
@Memo yes, i've used the roundno instead.

altoiddealer

Quote from: Fixer on February 12, 2017, 03:53:55 AM
@altoiddealer thanks for this man, now i understand what is a override and thanks for the code, i'll be using it.
edit: i pasted it in the cns but what about the code in the cmd? how it should looks like?
In case you don't completely understand AI... In a nutshell: AI constantly randomly mashes buttons, insanely fast.

So, the input for every key is registered practically every tick.

So to have any kind of control over that you need to have separate ChangeStates: 1 for player, 1 for AI.

I have something like this in my characters cmd:

[State -1, AI DASH FORWARD]
type = ChangeState
value = 100
triggerall = var(56) ;AILevel registered
triggerall = statetype = S
triggerall = P2MoveType != H
triggerall = Random < 600 ;controls the probability the AI performs the move
triggerall = ctrl
trigger1 = Random < P2BodyDist X

[State -1, PLAYER DASH FORWARD]
type = ChangeState
value = 100
triggerall = !var(56) ;Not AI
triggerall = command = "FF"
triggerall = statetype = S
trigger1 = ctrl


Then as I said earlier, you need code in State 100 to keep the frantic button mashing program from leaving the state.


Fixer

Its still sliding because i must be doing something wrong, i changed the var to 59 because i am using it to change the AI on/off and i am using the AI level activation because it seems to be better than the one with the human impossible commands.

So i changed your code to suit my activation method (i tested with your pure code but it hasn't worked, because of the var i guess).
This works for the AI level activation?

[State -1, AI DASH FORWARD]
type = ChangeState
value = 100
triggerall = var(59)>0 ;AI on
triggerall = random<var(50)*800
triggerall = statetype = S
triggerall = P2MoveType != H
triggerall = ctrl
trigger1 = Random < P2BodyDist X

[State -1, PLAYER DASH FORWARD]
type = ChangeState
value = 100
triggerall = var(59)=0 ;AI off
triggerall = command = "FF"
triggerall = statetype = S
trigger1 = ctrl

And i don't know what to change in the cns code that you send me!? (i think that this should be changed in some way).
Btw i am using the default 1.1 KFM for this, once i get the run forward working i'll be using the code in other char.
It's weird because KFM don't have the common1.cns.


XGargoyle

Common1.cns is located in the mugen/data folder. Copy it to your character 's folder and then modify  state 100


XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

altoiddealer

Quote from: XGargoyle on February 13, 2017, 02:32:49 PM
Common1.cns is located in the mugen/data folder. Copy it to your character 's folder and then modify  state 100
Or open up common1.cns in a text editor (Notepad, FF3's editor, etc)
Find the State 100 block
Copy/paste it into your character's cns
Modify the ChangeState controller in State 100 so that it behaves differently for AI (does not trigger based on input, but instead for factors like time / random < XXX / p2dist / etc)


Fixer

Thanks man, but i've tried everything and it's 50% slide/non-slide the better i've got.
Can you upload an 1.1 KFM with the changes so i can see where is the problem?
Or just the CNSs and the CMD?

XGargoyle

Copy paste  your state  100


XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!

Fixer

Quote from: Fixer on February 13, 2017, 06:22:58 PM
Thanks man, but i've tried everything and it's 50% slide/non-slide the better i've got.
Can you upload an 1.1 KFM with the changes so i can see where is the problem?
Or just the CNSs and the CMD?

I've done that couple of times but it don't works, i get 50% of the times slide and 50% of the times normal run.

inktrebuchet

Copy state 100 from the character and post it here for us to look at.

Fixer

My state 100:
Spoiler (click to show)
;---------------------------------------------------------------------------
;running state
[Statedef 100]
type    = S
physics = S
anim = 101
sprpriority = 1

[State 100, 1]
type = VelSet
trigger1 = 1
x = const(velocity.run.fwd.x)

[State 100, 2] ;Prevent run from canceling into walk
type = AssertSpecial
trigger1 = 1
flag = NoWalk

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 3
value = S40,0

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 7
value = S40,0

[State 100, 3] ;Prevent from turning
type = AssertSpecial
trigger1 = 1
flag = NoAutoTurn

[State 100, 4]
type = ChangeState
triggerall = AILevel>0
trigger1 = time > 30 || p2bodydist x < 30 || p2movetype=A
value = 0
ctrl =1

[State 100, 4]
type = ChangeState
triggerall = AILevel=0
trigger1 = command != "holdfwd"
value = 0
ctrl = 1
;---------------------------------------------------------------------------

My player CMD:
Spoiler (click to show)
;Run Fwd
[State -1, Run Fwd]
type = ChangeState
value = 101
Triggerall = var(59)=0
trigger1 = command = "FF"
trigger1 = statetype = S
trigger1 = ctrl

My AI CMD:
Spoiler (click to show)
[State -1, AI run]
type=changestate
value=101
triggerall = var(59)>0
Triggerall = random<var(50)*700
triggerall = statetype!=A && ctrl
triggerall = p2bodydist y =[-150,0]
triggerall = (stateno!=[101,105])
trigger1=  p2movetype!=A && (p2bodydist x=[150,788])
trigger2= p2movetype=H && p2statetype=A && enemy,vel y>0 &&ctrl && enemy,pos y<-10 &&p2bodydist x>40

This char uses the anim 101 to run i don't know why but i tested in one with anim 100 already.