# Non-Deterministic Sequential Loop Problem

Discussion and feedback on Construct 2

### » Sun Jun 22, 2014 4:22 pm

Hello
I have a For Loop that runs without his pack of different animation to multiple objects of the same type operations. The problem is that I need to ensure that the next iteration of For Loop attached is performed when all animations of all objects of the body have the For Loop is closed.

After developing the whole game, I got in this situation in the next iteration of the object depends on the state previous animation or type of the object. If I use Wait, I have not determinism, because I can not guarantee the amount of time the body will use the For Loop iteration.

Any suggestions?
Thank you.
B
4
S
1
Posts: 3
Reputation: 368

### » Mon Jun 23, 2014 2:41 pm

Err... Could you please explain it with more detail, probably with an example I couldn't make out what exactly you are asking for...

For every object, you can have an instance variable, that turns 0 when loop is running and 1 when loop is not running.

Then, after the completion of each loop, you can loop through the objects and count the number of 1's. When none of them is 1, you can do next iteration... I think...
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

### » Mon Jun 23, 2014 3:09 pm

I have something like below in "Loop Event"
Code: Select all
`|---loop 1---|     |---loop 2---|          |---loop 3---|               |---loop 4---|                    |---loop 5---|`

But the problem is that I need the first loop has been executed completely for the next iteration is executed correctly. As the second loop may start is starting parallel to the first loop, the second loop the result will be incorrect as the result of the first loop has not been fully calculated, and therefore, is also wrong.

I need some loop like (sequentially)
Code: Select all
`|---loop 1---||---loop 2---||---loop 3---||---loop 4---||---loop 5---|`

one after one;

But the problem is that I need the first loop has been executed completely for the next iteration is executed correctly. As the second loop may start is starting parallel to the first loop, the second loop the result will be incorrect as the result of the first loop has not been fully calculated, and therefore, is also wrong.

Added two cases where only changed the runtime of these two loops with Wait 1.0.
Suppose that is 1.0 Wait time processing and some other function that may last varying time.

If the loop were sequential, the result would always be correct regardless of the time that each block of the loop had.
As these blocks of shares of loops are executed in parallel, it can not guarantee determinism, ie, the result will always be correct for a given system configuration.

=D

You do not have the required permissions to view the files attached to this post.
B
4
S
1
Posts: 3
Reputation: 368

### » Mon Jun 23, 2014 6:06 pm

The C2 events don t work concurently, having one loop in an event, and another loop the event under it, will make it so the first loop is entirely done before the second (I don't have C2 right now so I cannot open your capx files).
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

### » Mon Jun 23, 2014 6:13 pm

Message: samirtf is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
C2 does not run the loops one after another, waiting for the previous iteration to finish. As a matter of fact, this is not even technically a loop. A loop is usually understood as something that runs to the end and then 'loops'.
B
4
S
1
Posts: 3
Reputation: 368