YesNoOk
avatar

How accurate is Prevstatno? (Read 685 times)

Started by Bannana, January 01, 2013, 06:35:45 am
Share this topic:
How accurate is Prevstatno?
#1  January 01, 2013, 06:35:45 am
  • ***
  • Lacking any sort of resolve
    • USA
    • www.geocities.jp/doubletrend_zeta/entry.html

  • Online
I've been coding AI recently and I've noticed that even with all my triggers limiting when and where to attack the AI still enjoys spamming a few moves in succession. All knock the opponent down so there's no point for the AI to ever spam them in succession.

For example, one of the attacks spammed is a launcher meant to bring the opponent toward you if they get too far away. All the AI needs to do is use it once and then it can fight again, but the AI uses it three times in a row, making it ineffective. If the already launched target gets hit immediately, they don't come close and just drop to the ground, which defeats the purpose of the attack.

I thought Prevstateno would work to prevent this, so my state looked more like this:

Code:
type = ChangeState
value = 1010
triggerall = Var(29) > 0
triggerall = statetype != A
triggerall = abs(P2bodydist X) > 150
triggerall = random < var(30)*0.6
triggerall = Prevstateno != 1010
trigger1 = ctrl

But it hasn't changed anything all that much, so I'm wondering how accurate the trigger actually is. Elecbyte warns about it being inaccurate, but I thought it would at least change the pattern a bit.

Does Prevstateno take into account that after an attack the state changes to 0 and ignores it, or does it count 0 as a previous state?

im buggin out man
Buriki One
Re: How accurate is Prevstatno?
#2  January 01, 2013, 06:41:11 am
  • *****
  • Most dangerous person in Mugen
    • USA
    • caddie.smeenet.org
It's probably going back to state 0 and then doing the attack again.

hjk

Re: How accurate is Prevstatno?
#3  January 01, 2013, 06:51:58 am
  • ****
  • Watch my fro grow as you go, go, go, go, go.
    • Afghanistan
What Caddie means is "you're sort of doing it wrong."

Although prevstateno has like a 20% of triggering itself incorrectly (for every creation save Rajaa's it would appear), your character has probably gone back to state 0, then into another state just after that (like 20[walk], 10[crouch, etc.) which would mean that your prevstateno has now switched to being state 0 instead of 1010.
In this context, you need to use your prevstateno when you know your character will be spending an extended amount of time in the state that follows 1010.

The real remedy that you seek in this situation is decreasing your random trigger.
LOL, Caddie's the man!! ;)

I'm as real as the runnin, I just happen to rap, Nigaas London, Japan, and i'm scared of dat tap.

I suggest extending my banning, cuz when I come back, it's gonna be hell. You think I was annoying before, oh man, it's on now :)
hjk vs. 99% of MFG. I will win.

RIP Poo Bear Tell my Dead Homie isson, for the year my partner.
Last Edit: January 01, 2013, 10:01:44 am by hjk
Re: How accurate is Prevstatno?
#4  January 01, 2013, 06:58:23 am
  • ***
  • Lacking any sort of resolve
    • USA
    • www.geocities.jp/doubletrend_zeta/entry.html

  • Online
I expected to find out that it was true that it counted 0.

But I understand, though I'm now wondering why I didn't realize that Prevstateno really is only good for custom states it seems.
Thanks for the clarification guys.

im buggin out man
Buriki One
Re: How accurate is Prevstatno?
#5  January 01, 2013, 07:30:07 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
prevstateno will only look at the previous state.

If you're in 200 and then go to 0, prevstateno returns 200. If you go back to 200, prevstateno returns 0.

As for your AI code. That's not at all restrictive.

triggerall = abs(P2bodydist X) > 150
triggerall = random < var(30)*0.6

150 distance away and some random value for random? I don't know what you wind up with there. What value does var(30) take?

Not even SLIGHTLY restrictive enough for decent AI to behave itself. As it's a launcher, your AI should do it then follow up with the jump, or whiff and choose something else, if it's spamming this your random value is too high and nothing else gets a look in.

triggerall = p2dist Y> -60 ;(about head height or round floor level)
triggerall = random < 50

Random values should be really low. Random < 500, reevaluated each tick, that's a 50% chance per tick, so you have a logical 100% chance over 2 ticks. Random < 100, that's a logical 100% chance over 10 ticks. Only when you drop properly low does random chance really work, otherwise your least restrictive triggers just take effect over and over again.

Prevstateno only returns the PREVIOUS state. Not previous states from any further back than the last changestate.


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: How accurate is Prevstatno?
#6  January 01, 2013, 07:43:58 am
  • ***
  • Lacking any sort of resolve
    • USA
    • www.geocities.jp/doubletrend_zeta/entry.html

  • Online
Oh, I see.  I've been looking at this in the wrong way entirely.

var(30) was meant to be for the scaling of the AI level, where the higher the difficulty the more the character would use the move, but now I see how the random backfired on me completely.

And, yeah, there weren't that many triggers on that one. Maybe I shouldn't have brought that part up when I was going to use that example. Most of my AI commands with tons of triggers aren't spammed, only a few are, and I failed to realize that was basically one of the reasons why.

And lastly, what prevstateno essentially would do for me is that if I was last in 1010 and changed back to 0, it would recognize 1010 as the previous state? So the issues were basically me not coding the triggers well, not so much prevstateno.

im buggin out man
Buriki One
Re: How accurate is Prevstatno?
#7  January 01, 2013, 09:42:10 am
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/
The real problem with prevstateno lies in the hitstates. Other problems are from programmers overlooking little things.
Re: How accurate is Prevstatno?
#8  January 01, 2013, 10:42:43 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Quote
var(30) was meant to be for the scaling of the AI level, where the higher the difficulty the more the character would use the move, but now I see how the random backfired on me completely.
Using var(30) for AI level is the correct way, the incorrect part was probably the values you assigned for it.
A distribution of values that work well for me for the 8 difficulty levels would be something like : 2,6,11,16,24,36,55,75,120 (+/- some depending on the character), and as a general rule, I never go over the 120-200 range for the maximum difficulty because it's not going to make the AI any stronger, but instead more predictable and likely to use the same moves all the time.

Prevstateno works properly, the problem is when the AI is idle it might enter additional states, most likely crouching, jumping and walking, and this will change the prevstateno.

hjk

Re: How accurate is Prevstatno?
#9  January 01, 2013, 11:21:10 am
  • ****
  • Watch my fro grow as you go, go, go, go, go.
    • Afghanistan
First let me demonstrate how flawed prevstateno can be:
http://www.youtube.com/watch?v=A5uRVYn-TP4&feature=youtu.be
I deleted all of the AI, and replaced it with these two lines (unless there is extra coding in another place I didn't look)
I didn't tamper with anything else
Spoiler, click to toggle visibilty


Pay attention to the codes BTW:
- First of all, Dhalsim should incessantly loop
- Code 1 has "ctrl"; it won't break gethits or other states
- Code 2 does not have ctrl; it should break gethits and other states
- Code 2 should always cause a loop.
- Code 1 is not allowed to activate when the AI's stateno = 0; 0 is the state that 1000 changes to when the animation completes itself
- Code 2 can trigger in any state as long as stateno = 1000 was the previous state
- Code 1 is only out of random <= 30; highly unlikely to repeat (I would hope LOL)
- In video, Dhalsim is clearly breaking hitstates ala Code 2
- In the video, Dhalsim clearly breaks his loop
- Conclusion = Crap, prevstateno is seriously fucked up


I have a theory. This video demonstrates how the Default AI (walk, run, jump, etc.) can royally fuck any coding that you give a character. In the past I thought that whenever crap like this happened, it was because triggers were overriding one another, but what if all of this is simply caused by the Default AI overrides, which are themselves disrupted by our codes? That could be the case.

For those of you with questions. I uploaded Dhalsim here:
http://www.sendspace.com/file/aiyu1e
LOL, Caddie's the man!! ;)

I'm as real as the runnin, I just happen to rap, Nigaas London, Japan, and i'm scared of dat tap.

I suggest extending my banning, cuz when I come back, it's gonna be hell. You think I was annoying before, oh man, it's on now :)
hjk vs. 99% of MFG. I will win.

RIP Poo Bear Tell my Dead Homie isson, for the year my partner.
Last Edit: January 01, 2013, 11:40:32 am by hjk
Re: How accurate is Prevstatno?
#10  January 01, 2013, 11:56:30 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Quote
- Code 2 does not have ctrl; it should break gethits and other states
The ignorehitpause=1 is missing from it. If a state change happens during the hitpause (which does happen in standard hit states) then prevstateno will no longer return 1000 so by the time Code 2 could activate, prevstateno is not 1000.

Example :
Code:
;---------------------------------------------------------------------------
; Stand get-hit (shaking)
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 5000, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + GetHitVar(animtype)

[State 5000, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5000, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5000, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5000, 5] ;State type gets set to aerial if getting hit up
type = StateTypeSet
trigger1 = Time = 0
trigger1 = GetHitVar(yvel) != 0 || GetHitVar(fall)
trigger2 = Pos Y != 0
statetype = a

[State 5000, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 5000, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5000, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

[State 5000, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5001 ;Stand get-hit (knocked back)

[State 5000, 7]
type = ChangeState
trigger1 = HitShakeOver
value = 5030
As you can see, this is the state active during the hitpause, but as soon as the hitpause ends (Hitshakeover), the state changes to another one. It's the same for all the other common hit states. So prevstateno will be 5000 when the hitpause is already over.

Quote
- Code 2 should always cause a loop.
Not if the AI is jumping or crouching. The sequence is like this :

1. Current State : 1000, Prevstateno =0
2/a. Current State : 1000, last tick of the attack, prevstateno=0
2/b. Current State : 0, attack ended, prevstateno=1000. State -1 has already been checked for this tick before 2a, so Code 2 won't trigger.
2/c. Hardcoded AI jumps, so state changes to 40. Stateno=40, prevstateno=0. This happens between ticks
3. When process reaches state -1, Current state=40, Prevstateno=0.

hjk

Re: How accurate is Prevstatno?
#11  January 01, 2013, 12:12:30 pm
  • ****
  • Watch my fro grow as you go, go, go, go, go.
    • Afghanistan
cmd read from top to bottom trumps that code.
Nah, that's not it.
My negligent ass forgot to remove the "ctrl" on the changestate which allows the default AI jump, walk, etc. to trigger. Dammit, now I have to rerecord this whole thing using a different character. :omg:

Quote
- Code 2 does not have ctrl; it should break gethits and other states
The ignorehitpause=1 is missing from it. If a state change happens during the hitpause (which does happen in standard hit states) then prevstateno will no longer return 1000 so by the time Code 2 could activate, prevstateno is not 1000.

Spoiler, click to toggle visibilty
As you can see, this is the state active during the hitpause, but as soon as the hitpause ends (Hitshakeover), the state changes to another one. It's the same for all the other common hit states. So prevstateno will be 5000 when the hitpause is already over.
I don't think so. I'll think about this more when I wake up, but:
- If that was the case then the freeze in state 1000 should never happen, if I know my stuff well enough. In the video Dhal clearly went from state 5000 back to 1000 on several occasions. You'd have to explain the inconsistency first, wouldn't you?
- And if that were the case, then Dhal would be in state 5000 after state 1000 which would mean he should always immediately go back to state 1000 upon entering 5000. As far as I saw, that was exactly the case.
- And the hitpause lasts for more than 1 tick, more than 2 ticks, more than 3 ticks, etc. He's still in 5000 which makes prevstateno = 1000, meaning he should always revert back (as he did).

Quote
- Code 2 should always cause a loop.
Not if the AI is jumping or crouching. The sequence is like this :
1. Current State : 1000, Prevstateno =0
2/a. Current State : 1000, last tick of the attack, prevstateno=0
2/b. Current State : 0, attack ended, prevstateno=1000. State -1 has already been checked for this tick before 2a, so Code 2 won't trigger.
2/c. Hardcoded AI jumps, so state changes to 40. Stateno=40, prevstateno=0. This happens between ticks
3. When process reaches state -1, Current state=40, Prevstateno=0.
Whoa, whoa. Lost me. "Before 2a"?
But how does that explain it occurring at all, though?

Edit:
Okay, I understand.
LOL, Caddie's the man!! ;)

I'm as real as the runnin, I just happen to rap, Nigaas London, Japan, and i'm scared of dat tap.

I suggest extending my banning, cuz when I come back, it's gonna be hell. You think I was annoying before, oh man, it's on now :)
hjk vs. 99% of MFG. I will win.

RIP Poo Bear Tell my Dead Homie isson, for the year my partner.
Last Edit: January 01, 2013, 12:30:23 pm by hjk
Re: How accurate is Prevstatno?
#12  January 01, 2013, 05:45:10 pm
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Quote
- And the hitpause lasts for more than 1 tick, more than 2 ticks, more than 3 ticks, etc. He's still in 5000 which makes prevstateno = 1000, meaning he should always revert back (as he did).
No ignorehitpause=1 on Code 2 means it will never be checked until the entire hitpause is over. So it can't take effect either.
However, I realize I was wrong on this, because although it can't trigger during the hitpause, it WILL trigger when it is over before the character can leave state 5000. (State -1 is processed before 5000 and hitshakeover won't trigger until the hitpause is over in which case the state -1 code also becomes active and will take priority)

Quote
- If that was the case then the freeze in state 1000 should never happen, if I know my stuff well enough. In the video Dhal clearly went from state 5000 back to 1000 on several occasions. You'd have to explain the inconsistency first, wouldn't you?
Actually, I guess this is the source of your inconsistency instead :
Code:
triggerall = statetype != A
At least what I see on the video is
-get hit on ground : he can and does break out of state 5000
-get hit in air : he can't break out and falls down
(The AI does keep jumping around)

But yeah, lots of inconsistency in hit states, for example, how is the state even working when the lines don't have ignorehitpause on them. The changeanim in state 5000 for example that sets anim 500x. It isn't supposed to work without ignorehitpause=1 but it does, so that state is probably a hardcoded exception to the "don't process without ignorehitpause=1" during hitpause rule.
So yeah, common hit states have a bunch of hardcoded stuff associated with them that you normally wouldn't know about.

Oh, and if he gets hit the same tick as when he finished the attack and changed out of state 1000, he won't restart it either because it goes 1000->0->5000 in the same tick, just like when the hardcoded AI changes the state.
Re: How accurate is Prevstatno?
#13  January 01, 2013, 05:55:29 pm
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/
Code:
[state -1, AI Jump]
type = changestate
value = 1000
triggerall = ailevel
triggerall = statetype != A
trigger1 = prevstateno = 1000

[state -1, AI Jump]
type = changestate
value = 1000
triggerall = ailevel
triggerall = statetype != A
triggerall = stateno != 0
trigger1 = p2bodydist x >= 0
trigger1 = ctrl
trigger1 = random <= 30

Works how it's supposed to work. Repeats state 1000 forever.

Edit:

Aside from basic movements like jumping, crouching, and walking (thoseare out of the contorl of any AI). But that's easily solvable with a variable that reads states when not in common states. Just place the variable directly in every state and you should be fine.

      Posted: January 01, 2013, 06:02:23 pm
Keep in mind that negative states are read BEFORE the characters current state, so they aren't the best places to use prevstatenos for AI because AI are random and will change their minds within the 1 tick it takes for negative states to read the current state of the character.

Eh. I usually solve these things when I get to them in the code. =p
Last Edit: January 01, 2013, 06:02:45 pm by Rajaa

hjk

Re: How accurate is Prevstatno?
#14  January 01, 2013, 07:36:42 pm
  • ****
  • Watch my fro grow as you go, go, go, go, go.
    • Afghanistan
Let's not over-complicate this: I strongly advise you all to watch this vid in its entirety
http://www.youtube.com/watch?v=cUsXyOq1Cng&feature=youtu.be

Notice:
- I took ctrl out of the changestate in statedef 1000
- I replaced the changstate value 0 (stand), with 240 an attack without ctrl
- Notice the effect this had on Dhalsim. It effectively made the loop indefinite
- Notice also that at time over, and even at roundstate = 3 he continues the loop
- Notice at 3:07 I finally do manage to break him with Ryu; you can explain that away all you want, you'd first have to tell me why it was so consistent at first
- My conclusion, prevstateno has like an 80%-85% guarantee of activating, but not 100%


(State -1 is processed before 5000 and hitshakeover won't trigger until the hitpause is over in which case the state -1 code also becomes active and will take priority)
Bingo

Spoiler, click to toggle visibilty
Actually, I guess this is the source of your inconsistency instead :
Code:
triggerall = statetype != A
At least what I see on the video is
-get hit on ground : he can and does break out of state 5000
-get hit in air : he can't break out and falls down
(The AI does keep jumping around)
No offense, but that's not what happened. But the video above should demonstrate that the real issue was simply me leaving "ctrl" at the end of statedef 1000 in the cns. When I eliminated that, it worked pretty much perfectly.


But yeah, lots of inconsistency in hit states, for example, how is the state even working when the lines don't have ignorehitpause on them. The changeanim in state 5000 for example that sets anim 500x. It isn't supposed to work without ignorehitpause=1 but it does, so that state is probably a hardcoded exception to the "don't process without ignorehitpause=1" during hitpause rule.
So yeah, common hit states have a bunch of hardcoded stuff associated with them that you normally wouldn't know about.
On another note, sometimes we get too preoccupied with what's supposed to happen in Mugen vs. what actually happens.


Oh, and if he gets hit the same tick as when he finished the attack and changed out of state 1000, he won't restart it either because it goes 1000->0->5000 in the same tick, just like when the hardcoded AI changes the state.
I'm mainly focused on him getting hit during the attack and I'm focusing on prevstateno lacking ctrl. But, I executed this incorrectly the  first time, but fixed it in the video above.


Spoiler, click to toggle visibilty
Works how it's supposed to work. Repeats state 1000 forever.
Edit:
Aside from basic movements like jumping, crouching, and walking (thoseare out of the contorl of any AI). But that's easily solvable with a variable that reads states when not in common states. Just place the variable directly in every state and you should be fine.
I've experimented with this a few times, but sometimes, like 10% of the time Mugen doesn't process it properly.



      Posted: January 01, 2013, 06:02:23 pm
Keep in mind that negative states are read BEFORE the characters current state, so they aren't the best places to use prevstatenos for AI because AI are random and will change their minds within the 1 tick it takes for negative states to read the current state of the character.
Eh. I usually solve these things when I get to them in the code. =p
That's great news. So there is really a reliable way to suppress the default AI.
Can you tell me what order things are processed in as in state -1, state -2, etc.? I still don't know what the order is  --;
LOL, Caddie's the man!! ;)

I'm as real as the runnin, I just happen to rap, Nigaas London, Japan, and i'm scared of dat tap.

I suggest extending my banning, cuz when I come back, it's gonna be hell. You think I was annoying before, oh man, it's on now :)
hjk vs. 99% of MFG. I will win.

RIP Poo Bear Tell my Dead Homie isson, for the year my partner.
Re: How accurate is Prevstatno?
#15  January 01, 2013, 09:07:07 pm
  • ***
  • Lacking any sort of resolve
    • USA
    • www.geocities.jp/doubletrend_zeta/entry.html

  • Online
Quote
var(30) was meant to be for the scaling of the AI level, where the higher the difficulty the more the character would use the move, but now I see how the random backfired on me completely.
Using var(30) for AI level is the correct way, the incorrect part was probably the values you assigned for it.
A distribution of values that work well for me for the 8 difficulty levels would be something like : 2,6,11,16,24,36,55,75,120 (+/- some depending on the character), and as a general rule, I never go over the 120-200 range for the maximum difficulty because it's not going to make the AI any stronger, but instead more predictable and likely to use the same moves all the time.

Ah, that makes so much more sense, seeing how I think my numbers went beyond 200 at some point.


And once again, many thanks guys, this is really good information.

im buggin out man
Buriki One
Re: How accurate is Prevstatno?
#16  January 02, 2013, 12:31:47 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Quote
- Notice at 3:07 I finally do manage to break him with Ryu; you can explain that away all you want, you'd first have to tell me why it was so consistent at first
Of course it's consistent. You are putting two determined state machines against each other. Both are essentially doing this :
"X time after I start this attack, the other guy gets hit. When the other guy gets hit, X time after that, I get hit. When I get hit, I start the attack." So they always get hit 2X number of ticks after the start of the attack by the projectile from the other one. That means a constant point of the animation. X is a constant value because they aren't knocked back from the hit, aren't moving, and the projectile is always fired at the same point of the animation and travels at a constant velocity.

Now, when you fight against him using Ryu, X is not a constant, and there is no such loop. He gets hit whenever you want, and not 2X time after the projectile. So while 2X was obviously not equal to the length of the move in state 1000, when you were jumping over the fireball and hitting him, you did manage to hit him at that tick, so what I explained before happened.
In this case, he went from state 1000 to 420, then the tick ended, clsn was processed, he got hit, entered state 5000, and then the next tick stated. At this point, prevstateno was already equal to 420, not 1000.

Quote
Can you tell me what order things are processed in as in state -1, state -2, etc.? I still don't know what the order is 
It's this :

I. State -3. If there is any changestate activated, skip the rest of state -3, but don't process the new state yet. (don't process statedef either.). This state is skipped if the character is in a custom state.
II.State -2. Same as above for changestates here. However, changestates in -3 don't skip state -2. This means that in state -2, your Stateno triggers will return the new state number, even though the statedef for that state is not processed yet (meaning if you changed into state 1000 from 5000 then Stateno will return 1000 BUT Movetype will return H, the last movetype you had before the state change.)
III. State -1. Same applies as for the above two.
IV. The current State's Statedef if it hasn't been processed yet since the entering of the state.
V.The current State.
VI. If the current state contains a Changestate, and it activates, then go to IV after that changestate is processed.
VII. If the Movetype=H and we got hit during the previous tick, take damage equal to the damage done by that attack. If there is an active binding, apply the position. (Bindtoparent, etc)
VIII. Collisions are checked. If there was a hit, the character is changed to the appropriate hit state (5xxx).
IX. Any hardcoded changes, such as AI walking, etc. happen, then proceed to I and start the next tick. This is what I usually refer as "between ticks"

Note that most of this is not documented, and is purely based on experience. A lot of it is counter-intuitive, too.

By the way, the "safe" way to avoid AI interference would be to put changestates that change out of normal states when an attack is over into state -3. Unfortunately no one does that. Not even Elecbyte. Even though not doing it will mean the character spends a tick in state 0 which is wasted because state -1 processing is already over when it is entered.
Last Edit: January 02, 2013, 12:35:12 am by Seravy

hjk

Re: How accurate is Prevstatno?
#17  January 02, 2013, 01:33:08 am
  • ****
  • Watch my fro grow as you go, go, go, go, go.
    • Afghanistan
Quote
- Notice at 3:07 I finally do manage to break him with Ryu; you can explain that away all you want, you'd first have to tell me why it was so consistent at first
Of course it's consistent. You are putting two determined state machines against each other. Both are essentially doing this :
"X time after I start this attack, the other guy gets hit. When the other guy gets hit, X time after that, I get hit. When I get hit, I start the attack." So they always get hit 2X number of ticks after the start of the attack by the projectile from the other one. That means a constant point of the animation. X is a constant value because they aren't knocked back from the hit, aren't moving, and the projectile is always fired at the same point of the animation and travels at a constant velocity.
I'm not concerned with the projectile, but let me move on to the next part of your post.

Now, when you fight against him using Ryu, X is not a constant, and there is no such loop. He gets hit whenever you want, and not 2X time after the projectile. So while 2X was obviously not equal to the length of the move in state 1000, when you were jumping over the fireball and hitting him, you did manage to hit him at that tick, so what I explained before happened.
In this case, he went from state 1000 to 420, then the tick ended, clsn was processed, he got hit, entered state 5000, and then the next tick stated. At this point, prevstateno was already equal to 420, not 1000.
And this is precisely what I was hoping you wouldn't say.
Now I've got to code a hitdef to hit Dhalsim only when he's in 240 then rerecord that for the sake of the point.... I'll do it in a few days after I clean my HD


Quote
Can you tell me what order things are processed in as in state -1, state -2, etc.? I still don't know what the order is 
It's this :

I. State -3. If there is any changestate activated, skip the rest of state -3, but don't process the new state yet. (don't process statedef either.). This state is skipped if the character is in a custom state.
II.State -2. Same as above for changestates here. However, changestates in -3 don't skip state -2. This means that in state -2, your Stateno triggers will return the new state number, even though the statedef for that state is not processed yet (meaning if you changed into state 1000 from 5000 then Stateno will return 1000 BUT Movetype will return H, the last movetype you had before the state change.)
III. State -1. Same applies as for the above two.
IV. The current State's Statedef if it hasn't been processed yet since the entering of the state.
V.The current State.
VI. If the current state contains a Changestate, and it activates, then go to IV after that changestate is processed.
VII. If the Movetype=H and we got hit during the previous tick, take damage equal to the damage done by that attack. If there is an active binding, apply the position. (Bindtoparent, etc)
VIII. Collisions are checked. If there was a hit, the character is changed to the appropriate hit state (5xxx).
IX. Any hardcoded changes, such as AI walking, etc. happen, then proceed to I and start the next tick. This is what I usually refer as "between ticks"

Note that most of this is not documented, and is purely based on experience. A lot of it is counter-intuitive, too.
And with this hjk felt like a noob once more. Sheesh.
So if I code my states using state -3, that should mean that I shouldn't have to worry as much about the Default AI run, walk, jump, etc.?
Edit:
Okay, I'll try it.

By the way, the "safe" way to avoid AI interference would be to put changestates that change out of normal states when an attack is over into state -3. Unfortunately no one does that. Not even Elecbyte. Even though not doing it will mean the character spends a tick in state 0 which is wasted because state -1 processing is already over when it is entered.
Genius. You're my new [E]. It's as if you guys are omniscient.
LOL, Caddie's the man!! ;)

I'm as real as the runnin, I just happen to rap, Nigaas London, Japan, and i'm scared of dat tap.

I suggest extending my banning, cuz when I come back, it's gonna be hell. You think I was annoying before, oh man, it's on now :)
hjk vs. 99% of MFG. I will win.

RIP Poo Bear Tell my Dead Homie isson, for the year my partner.
Re: How accurate is Prevstatno?
#18  January 02, 2013, 04:34:49 am
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/
Place AI changestates in statdef 0 - 40. Problem solved? Haven't tested. Don't see why that wouldn't work.
Re: How accurate is Prevstatno?
#19  January 02, 2013, 09:51:30 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Place AI changestates in statdef 0 - 40. Problem solved? Haven't tested. Don't see why that wouldn't work.
Because as soon as state 10-40 are entered, prevstateno value is already changed. It works for preventing the AI from doing stuff (I do this to prevent my AI from jumping, for example), but not from changing prevstateno.
Re: How accurate is Prevstatno?
#20  January 02, 2013, 09:55:42 am
  • ******
  • I hang out tough. I'm a real boss.
    • USA
    • litotichues.com/
Re: How accurate is Prevstatno?
#21  January 02, 2013, 10:36:37 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress

Because as soon as state 10-40 are entered, prevstateno value is already changed.
Not necessarily.
Oh, you did include 0. Never mind, then it will work. The only problem with it would be the many copies of the AI changestates. Makes updating/tuning the AI harder. This is what you normally use subroutines for, but Mugen doesn't even have that very basic coding concept.

You might need to include more states, like 52, 105, etc, it they set ctrl=1 within them, but if all of those are included, it should work, yes.
Re: How accurate is Prevstatno?
#22  January 02, 2013, 11:25:56 am
  • ***
  • Lacking any sort of resolve
    • USA
    • www.geocities.jp/doubletrend_zeta/entry.html

  • Online
By the way, the "safe" way to avoid AI interference would be to put changestates that change out of normal states when an attack is over into state -3. Unfortunately no one does that. Not even Elecbyte. Even though not doing it will mean the character spends a tick in state 0 which is wasted because state -1 processing is already over when it is entered.
I'm intrigued by this, but I haven't coded in a long time until recently so I'm puzzled by how this works exactly.

So you'd finish an attack and the changestate is in -3 or it leads you to -3?

im buggin out man
Buriki One
Re: How accurate is Prevstatno?
#23  January 02, 2013, 11:30:29 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
State -1 has just been the "convenient" place for AI. I will routinely put it in -3 or -2 rather than the cmd file. I prefer -3, because you can't get any odd shit happening within custom states that way. This is of course assuming you have made rather bad AI but it also avoids people who code their custom states a little incorrectly.


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: How accurate is Prevstatno?
#24  January 02, 2013, 11:40:25 am
  • ***
  • Lacking any sort of resolve
    • USA
    • www.geocities.jp/doubletrend_zeta/entry.html

  • Online
So if someone moved AI to -3 or -2, you wouldn't really see that much change compared to it being parked in -1?

im buggin out man
Buriki One
Re: How accurate is Prevstatno?
#25  January 02, 2013, 11:43:48 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
-2 requires extra stuff to make it actually STOP running. -3 is fine iirc.


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: How accurate is Prevstatno?
#26  January 02, 2013, 11:55:35 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
State -1 has just been the "convenient" place for AI. I will routinely put it in -3 or -2 rather than the cmd file. I prefer -3, because you can't get any odd shit happening within custom states that way. This is of course assuming you have made rather bad AI but it also avoids people who code their custom states a little incorrectly.
That's an option, but I prefer -1 because changestates in -3 will cause trigger inconsistency during the entire evaluation of -2 and -1. So I only use changestates in -3 or -2 for stuff like resurrections or similar rare cases. I don't know if there is any code in any of my characters that would fall victim to this trigger inconsistency, but it's better to avoid the risk.
About the trigger inconsistency, an example, let's say you have something like

[State -1]
Type=Changestate
Trigger1=Stateno=1000
Trigger1=Movetype=I
...more triggers
value=1010

to activate something during the cooldown of an attack in state 1000. (State 1000 is a Movetype=A state with a Statetypeset for movetype=I on the animelem after the active part of the animation)

Now, if you place your AI into -3, and the AI activates the changestate to 1000 from a movetype=I state to use the attack, this code will trigger before the move in state 1000 even started, because the stateno will be updated to 1000 but the Statedef that sets the movetype isn't processed yet so it still returns I while -1 is processed.

-1 is safe for the AI because there are no other minus states after it, where trigger inconsistency can occur.
Last Edit: January 02, 2013, 11:58:47 am by Seravy
Re: How accurate is Prevstatno?
#27  January 02, 2013, 12:12:41 pm
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
That is a pretty rare situation indeed because that would mean i had coded a cancellation of an attack without allowing for it to complete in the first place.

I see your point, but the way i actually do AI when i bother would not have that occuring at any point. And it hasn't happened so far  ;P


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.