YesNoOk
avatar

Glitchy AI problem (Read 628 times)

Started by Javier, May 06, 2019, 02:06:19 am
Share this topic:
Glitchy AI problem
New #1  May 06, 2019, 02:06:19 am
  • avatar
  • *
    • USA
I'm currently making an AI for a character that uses the default AI,but for some reason,it is almost always stuck in a state.No matter what i code,it doesn't seem to make the ai work properly.
The code:
[StateDef -1]
;-----------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------

[State -1]
type = varset               
triggerall = (roundstate = 2) && (var(59) <= 0)
   trigger1 = command = "AI_1"
   trigger2 = command = "AI_2"
   trigger3 = command = "AI_3"
   trigger4 = command = "AI_4"
   trigger5 = command = "AI_5"
   trigger6 = command = "AI_6"
   trigger7 = command = "AI_7"
   trigger8 = command = "AI_8"
   trigger9 = command = "AI_9"
   trigger10 = command = "AI_10"
   trigger11 = command = "AI_11"
   trigger12 = command = "AI_12"
   trigger13 = command = "AI_13"
   trigger14 = command = "AI_14"
   trigger15 = command = "AI_15"
   trigger16 = command = "AI_16"
  trigger17 = command = "AI_17"
v = 59
value = 1

;Guard
[state -1,changestate]
Type = changestate
triggerall = (ROUNDSTATE = 2) && var(59) <= 0
triggerall = (ctrl) && P2MoveType = A && statetype = s
 triggerall = facing < enemy,facing
trigger1 = movetype != H
trigger1 = (p2bodydist x <= 75) && (random = [200,600]) && (vel x < 0)
 trigger2 = (p2bodydist x <= 75) && (random = [800,1000]) && (vel x > 0)
   trigger3 = (p2bodydist x <= 75) && (random = [400,700]) && (vel x = 0)
   trigger4 = (anim = [0,21])
   trigger5 = (prevstateno > 5000) && (random < 200)
   value = 120

;Turn
[State -1]
type = changestate
triggerall = (ROUNDSTATE = 2) && var(59) <= 0 && pos Y = 0
triggerall = facing < enemy,facing
trigger1 = animtime = 6
trigger1 = movetype != H
value = 5


;Move Forward
[state -1, changestate]
type = changestate
triggerall = var(59) != 0
Triggerall = P2bodydist x >= 10
trigger1 = movetype != h && movetype != a  && pos Y = 0
trigger1 = stateno != 21
trigger1 = random <= 30
trigger1 = animtime = 36
trigger1 = movetype != H
value = 20

;Move Backward
[state -1, changestate]
type = changestate
triggerall = var(59) != 0
trigger1 = movetype != h && stateno != 200 && pos Y = 0
Triggerall = P2bodydist x <= 18
trigger1 = random <= 30
value = 21
;run backward
;[state -1]
;type = changestate
;;triggerall = var(59) != 0 && roundstate = 2
;trigger1 = frontedgebodydist < 20
;trigger1 = p2bodydist x >= 12 && random = 50
;value = 105
;Dodge
[state -1,changestate]
Type = changestate
triggerall = (ROUNDSTATE = 2) && var(59) != 0
triggerall = ctrl && (statetype = s)
trigger1 = (p2bodydist x <= 75) && (random = [200,899]) && (vel x < 0)
 trigger2 = (p2bodydist x <=75) && (random = [800,899]) && (vel x > 0) && pos Y = 0
trigger1 = movetype != H
triggerall = facing < enemy,facing
  trigger1 = movetype != h && movetype != a
 trigger3 = (p2bodydist x <= 50) && (random = [400,899]) && (vel x = 0)
   trigger4 = (anim = [0,21])
triggerall = statetype != l
   trigger5 = (prevstateno > 5000) && (random < 150) && (prevstateno != 254)
   value = 254

;ATK 1
[State -1]
   type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (statetype = S) && pos Y = 0
   trigger1 = ctrl
   trigger1 = (movetype != h) && (movetype != a)
trigger1 = p2bodydist X <= 30                               
   trigger1 = random <= 35                               
   value = 200

;ATK 2
[State -1,punch]
 type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (statetype = S) && pos Y = 0
   triggerall = statetype != l
trigger1 = movetype != h && movetype != a
 trigger1 = p2bodydist X <= 40                 
   trigger1 = random <= 35                                   
   value = 210

;ATK 3
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (statetype = s)  && pos Y = 0
   triggerall = statetype != l
 trigger1 = movetype != h && movetype != a
trigger1 = p2bodydist X <= 40                 
   trigger1 = random <= 20                                 
   value = 230

;ATK 4
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0) && pos Y = 0
   triggerall = (Ctrl) && (Statetype = s)
   triggerall = statetype != l
 trigger1 = p2bodydist X <= 40
 trigger1 = movetype != h && movetype != a    ;
 trigger1 = random <= 26                                   
 value = 220

;ATK 5
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0) && pos Y = 0
   triggerall = (Ctrl) && (Statetype = s)                         
 trigger1 = movetype != h && movetype != a
triggerall = statetype != l
trigger1 = p2bodydist X <= 150                 
   trigger1 = random <= 30                                   
   value = 6000

;ATK 6
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0) && pos Y = 0
   triggerall = (Ctrl) && (Statetype = s)
     trigger1 = movetype != h
triggerall = statetype != l
trigger1 = movetype != a
 trigger1 = p2bodydist X >= 10                 
   trigger1 = random <= 22                                   
   value = 1200


;ATK 7
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H && movetype != a
                        triggerall = statetype != l
 trigger1 = p2bodydist X >= 15               
   trigger1 = random <= 25                                   
   value = 1000

;Jump
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a
trigger1 = movetype != H
 triggerall = statetype != l
Trigger1 = statetype = s                       
 trigger1 = p2bodydist Y <= 1000                 
   trigger1 = random <= 10                                 
   value = 41

;Sword Projectile
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
triggerall = statetype != l
Trigger1 = statetype = s 
 trigger1 = p2bodydist x >= 15                 
   trigger1 = random <= 26                                   
   value = 1100

;Lie down get-up
[state -1]
type = Changestate
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Statetype = L)
trigger1 = movetype != H
Trigger1 = statetype = l                         
trigger1 = anim = 5120 && animelem = 10           
   value = 5000

;Call Newbie
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x >= 5                 
   trigger1 = random <= 30                                 
   value = 6100

;Brick Shooting
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
Trigger1 = statetype = s
 trigger1 = movetype != H       
 trigger1 = p2bodydist x >= 15                 
   trigger1 = random <= 15                                   
   value = 3050
triggerall = power > 1000
;Brick Shooting
[state -1]
type = ChangeState
   triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
Trigger1 = statetype = s
 trigger1 = movetype != H       
 trigger1 = p2bodydist x >= 15               
   trigger1 = random <= 15                               
   value = 2999
triggerall = power >1000
;Erik.Cassel
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x >= 5                 
   trigger1 = random <= 30                                 
   value = 6300
ctrl = 1
;Forward throw attempt
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x <= 20               
   trigger1 = random <= 32 || prevstateno = 5120 || prevstateno = 5000 || inguarddist                                 
   value = 800
ctrl = 1
;call Builderman
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x >= 5                 
   trigger1 = random <= 30                                 
   value = 6400
ctrl = 1
;call Telamon
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x >= 5                 
   trigger1 = random <= 30
ctrl = 1                                 
   value = 6200

;Gun Laser
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x >= 12                  ,
   trigger1 = random <= 32                                   
   value = 3200
triggerall = power > 1000
;hyper brick shoot
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x > 2                 
   trigger1 = random <= 34                                   
   value = 1004
triggerall = power > 1000
;Rocket Launcher
;[state -1]
;type = changestate
  ;triggerall = (roundstate = 2) && (var(59) != 0)
   ;triggerall = (Ctrl) && (Statetype = s) && movetype != a  && pos Y = 0
;trigger1 = movetype != H
;Trigger1 = statetype = s                       
 ;trigger1 = p2bodydist x >= 12                 
  ; trigger1 = random <= 29                                 
   ;value = 3020

;glitch cancel
[state -1]
type = changestate
  triggerall = (roundstate = 2) && (var(59) != 0)
   triggerall = (Ctrl) && (Statetype = s) && movetype != a && pos Y = 0
trigger1 = movetype != H
Trigger1 = statetype = s                       
 trigger1 = p2bodydist x >= 12                 
   trigger1 = random <= 34                                 
   value = 1004
triggerall = power > 750

;guest glitch thing cancel
;[state -1]
;type = ChangeState
;triggerall = (roundstate = 2) && (var(59) != 0)
;Trigger1 = ctrl
;Trigger2 = anim = 6000                                                       
 ;  value = 5020
;ctrl = 1
 
;jump
[state -1]
type = changestate
trigger1 = var(59) != 0
trigger1 = p2bodydist y > 15000 && p2bodydist x  < 37
triggerall = random <= 15
value = 41

You probably see some states that normally are never included in other ais,and it's because they fix certain glitches with the ai.
Is there something wrong with the code that i didn't notice or something?
Last Edit: May 31, 2019, 09:21:33 pm by Javier
Re: Glitchy AI problem
#2  May 06, 2019, 04:49:25 pm
  • *****
  • Shame on you!
    • USA
(var(59) <= 0)
and
var(59) != 0

You probably want to change the top one to the bottom one.
Also, what state does it always switch to?
vVv Wheat Stage Released vVv
Re: Glitchy AI problem
#3  May 08, 2019, 07:53:53 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Turn isn't a state. Its only an animation. Don't code that let mugen handle it. Itll happen automatically if you have ctrl. At other times you want to manage it in the attacks not code for it.

Ie take out the changestate for turn. You're going to a non existent 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.
Re: Glitchy AI problem
#4  May 10, 2019, 03:19:51 am
  • avatar
  • *
    • USA
The states the AI gets stuck in are:
254(Almost guaranteed after use)
6000
47
40
800
210
The ai also doesn't immediately activate when each round starts.
Last Edit: May 10, 2019, 03:36:53 am by Javier
Re: Glitchy AI problem
#5  May 11, 2019, 04:15:44 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Do you get stuck in those states? Have you done what i suggested before with turn. Its not a state.

Also. No the ai won't be instant. You're using the command style activation where you wait for the default ai to choose that command. If you want instant make sure you're using 1.0+ and use the ailevel trigger.


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: Glitchy AI problem
#6  May 12, 2019, 05:00:25 am
  • avatar
  • *
    • USA
no
yes
ok
And i tried this code thinking that it would give the ai control of the character after a bit if it was still in the animation
[state -1]
type = ctrlset
trigger1 =  anim = [200,220] || anim = 40 || anim = [800,810] || anim = 6000 ||anim = 47 && gametime % 500 && ! movetype = a || ! movetype = h 
value = 1
but it caused a mugen error instead,depite the fact that no errors were detected in fighter factory,so it was a bust.
Re: Glitchy AI problem
#7  May 13, 2019, 07:46:38 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Mugen doesn't like the [  ] things unless they're on the end of a line or enclosed in normal (  ) brackets.

Also should be movetype !=a && movetype != h. Yours won't actually work.


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: Glitchy AI problem
New #8  May 13, 2019, 04:02:52 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
"Gametime % 500" is always true, you might as well just write "1" since it returns an integer value.
Assuming you want there to be a 1 in 500 ticks chance of triggering, add "= 0" like I am showing below.  Because every 500 ticks it will return 0.

Also the && and && statement I think you want to be one whole condition, yes?  Need to wrap this whole thing in parenthesis.
And like Cyanide said about the [ ] statements... wrap w/ parenthesis.

[state -1]
type = ctrlset
trigger1 =  (anim = [200,220]) || anim = 40 || (anim = [800,810]) || anim = 6000 || (anim = 47 && gametime%500 = 0 && movetype != a) || movetype != h
value = 1

Last Edit: May 13, 2019, 04:37:43 pm by altoiddealer