Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Loop without 2 successive identical values

Hi there,

Does anybody know a way to avoid the repetition of the previous value in a random loop ?

I guess that a script could help by saving the latest value and comparing with the current value in the loop, but how can I do that ?

Thanks in advance,

Gérard

Comments

  • Additional information about the context:

    The purpose is to run a continuous loop containing a sequence of several sketchpads and show one of them randomly at each pass. Each sketchpad is identified by a value in a variable and the selection is made by the conditional statements of the sequence, based on the randomly selected value of the variable.

    It is of course possible to fix a pseudo-random sequence of values in the table, but the idea here is to limit the list of values to the number of sketchpads and make a real random selection on that list at each pass. This is simple and easy but there is a constraint of not showing the same sketchpad twice one after the other. Replication is allowed, but not in direct successive passes.

    Cheers,

    Gérard

  • Hi Gérard,

    i am not sure what your sequence shall look like.

    Here is a code for a script that controls for first and second order sequences. What i did in the script was that i set a pool of items. Then i draw 'randomly' one item after the other from this pool to the sequence. This was not completely random, but based on some restrictions. In the end, i check for some other restrictions. If the sequence fits, i take it. If it does not fit, i start a new sequence by drawing from the pool again.

    The idea is to to create a sequence that matches your restrictions in advance (preparation phase). This can be done for each participant uniquely or you use the same order for all participants. The latter is even easier and can also be done manually.

    You may adapt the inline_script for your purpose.

    Stephan

  • Hi Stephan,

    Thank you very much. This script is inspiring and allowed me to adapt the program.

    Cheers,

    Gérard

Sign In or Register to comment.