Premature trigger stop

Luth

Lex Luthor!
Reaction score
41
I have a simple trigger that runs a simple loop circa 15,000 times. However, it just dies out and quits after around 5k-6k into the loop. Any way around that?
 

corvusHaunt

New Member
Reaction score
96
Run a quick sleep action. Either add an "if" to your loop, seeing if your forloopindex is 5,000;10,000;15,000 whatever, or just use three loops, seperated by a wait.
 

Luth

Lex Luthor!
Reaction score
41
Heh, was just coming back to say I figured out that Sleeping would keep it going. ;) Thx corvus.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Quite frankly, I don't think I want to know what kinda loop requires 15000 iterations...
And, if you hit the trigger execution time limit... there's a reason.
Not to mention that you probably want to go even higher.

Very evil :p
 

Luth

Lex Luthor!
Reaction score
41
I'm not a fan of brute force either, but there are sometimes no other ways. :-/
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
[Off topic]

Did you know?

17 * 42
= (1 * 10 + 7) * (4 * 10 + 2)
= 1 * 4 * 10 * 10 + 1 * 2 * 10 + 4 * 7 * 10 + 2 * 7
= 4 * 100 + (2 + 28) * 10 + 14
= 4 * 100 + 30 * 10 + 14
= 4 * 100 + 3 * 100 + 1 * 10 + 4
= 7 * 100 + 1 * 10 + 4
= 714?
 

corvusHaunt

New Member
Reaction score
96
Yah I totally knew that.

By the way, you made my World Editor crash:
Code:
17 * 42 = (1 * 10 + 7) * (4 * 10 + 2) = 1 * 4 * 10 * 10 + 1 * 2 * 10 + 4 * 7 * 10 + 2 * 7 = 4 * 100 + (2 + 28) * 10 + 14 = 4 * 100 + 30 * 10 + 14 [SIZE=4][B])[/B][/SIZE] = 4 * 100 + 3 * 100 + 1 * 10 + 4 = 7 * 100 + 1 * 10 + 4 = 714?
 

SFilip

Gone but not forgotten
Reaction score
634
> Curious....what are you doing that requires that much looping :confused:
i'm guessing its for vexorian's contest :p
 

martix

There is no spoon
Reaction score
49
Contest, what contest?
Oh, and I really wanna know what this trigger is supposed to do!
 

SFilip

Gone but not forgotten
Reaction score
634

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> I'm guessing it's for Vexorian's contest

All the more reason to stop looping...

If you're hitting time problems at 15000, how long you think it will run with 1000000? What about 1000000000?
 

martix

There is no spoon
Reaction score
49
This is actually more of a mathematical problem, than proggraming one.
Either way, when I go home, if it continues to be more about logic and less proggraming, I might learn JASS well enough to take part in it.
And there is definately a better algorithm, just requires a little bit more thinking.
Edit:
Oh, yeah I finally got it, took some time to remember, but no matter...
Your's is too brute force, you're not trying to crack a password, are you? :)
Its simple anyway, you just have to think a bit!
S=n/2*(2+(n-1)) - this would be your case. And this thing is called arithmetic proggresion. If its that simple then this is no contest at all...
 

emjlr3

Change can be a good thing
Reaction score
395
first off its only lvl 1 of the contest, and second off, once you get integers above that level, like 2500000000, they bug out, so you gotta find some way to work around that, which I have yet to be able to do :(
 

Luth

Lex Luthor!
Reaction score
41
Thats the equation, but you still run into problems, as emj said, with n >=~ MAXINT^.5. I suppose one solution would be to break down n into its factors, but if you're given a prime number >=~ MAXINT^.5 then you're screwed six ways from sunday. :cool:

But, its entirely possible to do; if I can do it, you can. The hardest part is, as stated, working around JASS's limitations.

PS: If you do get a work-around working with the formula that works for ALL number, I'd be very happy to see it. :) [I've since submitted my solution, and have stated for public record as much, so dont worry about me trying to cheat and steal your genius. I'm merely insanely curious as how someone managed to work-around with the equation.]
 

emjlr3

Change can be a good thing
Reaction score
395
a few ppl got it already, Pip, Blue, 1 other i think, but i dont know it yet, I thought I had it, but it ended up not working for me :(

I really am not sure what to do heh
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Haven't really been reading post #9, have you?

It started with multiplying two 2 digit numbers.
And yet, the biggest multiply inside that calculation was 4 times 7, which is half the size.

Some bigger example maybe:

Let's say you want to multiply 1234 by 5678.
Unfortunately, your calculator is from before WWI and refuses to multiply anything, unless it's in the range 0 - 99.

What to do?

Well, you might notice that 1234 is 12 * 100 + 34, and 5678 is 56 * 100 + 78.
Those 4 factors, 12, 34, 56 and 78, are each within 0 - 99.

1234 * 5678
= (12 * 100 + 34) * (56 * 100 + 78)

multiplying it all out, with a bit of grouping back:

= 12 * 56 * 100 * 100 + 12 * 78 * 100 + 34 * 56 * 100 + 34 * 78
= 12 * 56 * 100 * 100 + (12 * 78 + 34 * 56) * 100 + 34 * 78
= 672 * 100 * 100 + (936 + 1904) * 100 + 2652
= 672 * 100 * 100 + 2840 * 100 + 2652

some of the factors in here are too large, and need readjusting:

= 672 * 100 * 100 + (28 * 100 + 40) * 100 + (26 * 100 + 52)
= 672 * 100 * 100 + 28 * 100 * 100 + 40 * 100 + 26 * 100 + 52
= (672 + 28) * 100 * 100 + (40 + 26) * 100 + 52

leading to the final result:

= 700 * 100 * 100 + 66 * 100 + 52
= 7006652

where the actual result is really just writing out the factors one after the other, ignoring the "100"s.

Somewhat longish maybe, but, your 0-99 calc was enough to get the job done!
You may notice that I didn't really do anything with all those "* 100", that's because they are only needed so I remember the correct positions.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top