Re: Detecting Infinite Loops
i don't think so, since infinite loops freeze your app so you really can't run anything outside of that loop that would check
what you could do as prevention is:
1. add a condition to an On Loop condition that'll cancel the loop if it exceeds a value it should never meet
2. (works on more than just fastloops) use min() with one parameter being the number of loops that should run, and the other being the maximum (so with a fastloop, it'd be like: Start Loop: "50-objects"; min(total objects, 50) )
Re: Detecting Infinite Loops
Just use:
+On Loop
+Loopindex( "Loop" ) < 1000
I, personally, do not want this fixed because I use it as a cheap alternative to the Crasher object. Plus it's Java supported!
Re: Detecting Infinite Loops
I know Fast Loops would mess you guys =]
I'm talking about Loops not the function "Fast Loops"
When you put something like:
If 'Global Value A' = '1' Do
Add 1 to Counter
It will add 1 to counter infinetelly until the value changes... It won't freeze the app =] but it will make it lag like hell depending on whatever is looping. Sometimes even crash it like it was happening with me.
The question is: There's is any way to find if an condition is happening all the time? In every app cicle?
Re: Detecting Infinite Loops
Most of the time that's a desired function. E.g. I use plenty of "always" conditions.. in fact LOTS AND LOTS of them. Never had performance problems. You just shouldn't do intensive stuff in events that happen a lot.
Re: Detecting Infinite Loops
I don't use intensive stuff with always conditions... It just happens sometimes by mistake, like happened with me that day. To help with this, since it is a mistake and I don't know where exactly is the problem, I was wondering if there was a faster/easier way to find "always conditions".
Re: Detecting Infinite Loops
To test, you can do this:
ALWAYS
--- Make player visible
YOUR CONDITION
--- [action]
--- [action]
--- Make player invisible
If the player remains invisible forever, then the condition is still running. If not, then it has evidently stopped. This gives you a nice visible debugging sign to look for.
Another good trick for debugging is change the framerate to 5 or 10fps. This way it's a lot like stepthrough and you can see each phase of the events on a frame by frame basis.
Re: Detecting Infinite Loops
Yeah, that would work if you know that the problem is with the Player Object. But when you have a 300+ lines project and Crashs or slows are happening, is kinda hard to know where exactly the "always" condition is happening.
Note that "always" is not the "Always" function of MMF, like "loop" is not the "Loop" function of MMF either. =P I think that many ppl are getting messed with these names.
The frame rate would work for visible objects thanks, but for stuff like MMF2 Params setting the max object to X on each app cicle, wouldn't... =/
Would be good though that MMF2 could detect if an specific condition is happening on each loop of the app, that would probally solve the problem. Just a opnion. ^^
Re: Detecting Infinite Loops
I'm surprised nobody has pointed out that you are asking, in effect, "Does my program halt?". It is well known that there is no program that always does this.
The proof is as follows. Suppose there was one, call it H. So it is a program with two parameters: A program (in number form, possible as clearly countable) p and an input i. H(p,i) = "halt" if it halts and "loop" otherwise.
Now define T(x) = 0 if H(x,x) = "loop" and T does not halt otherwise. Say T is represented by the integer t.
Consider T(t). It can neither halt nor loop.
Not any help to your problem but might be interesting none the less..
Re: Detecting Infinite Loops
Re: Detecting Infinite Loops
Interesting? Yeah.
Did I understand? No.