Random Repetition

This forum is currently in read-only mode.
  • How can I fill a list with numbers from 1-10 with random order but without repeating ?

  • You have to exclude the numbers already picked.

  • but how to do that?

  • Using conditions.

    Set a variable:

    => Set var X = random(10)+1

    Compare that variable to others already seted:

    +If var X == var Y

    => Set var X = random(10)+1

    Use loops to reapeat this until the condition "+If var X == var Y" is wrong.

    Maybe there are another way to do this, but i can't think any other way right now.

  • Thanks for your quick help. It works as it should but it is extreme slow.

    It takes 3-4 seconds for all 10 numbers to be generated.

    If i turn FPS to unlimited it is much much faster.

    Is there a faster way for doing this? I need the numbers on the fly but i dont want to turn off vsync.

  • But you used loops? With loops you can do it in 1 frame.

  • shure but there is a problem using loops on this because i can not use expressions fpr writing the nubers to the variables.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't get it to work. To bad my english is not that good. I try to explain what exactly i want.

    I have an Array with 10 Flields on X axis. For each field i want a number from 1-10 but without repeat used numbers.

    this could look like this: 5,8,2,1,6,9,3,10,4,7

    No double numbers, just the numbers from 1-10 in a random order.

    Could someone please help me out with an working example?

    Thank you so much.

  • Here: mediafire.com/file/18ez6q6i60ibwb7/randomunique.cap

    EDIT oh, shadowlord beat me to it <img src="smileys/smiley36.gif" border="0" align="middle" /> That brings up the question, why I saw his post not before posting mine <img src="smileys/smiley5.gif" border="0" align="middle" />

  • you may trying putting all numers in the array so then apply an loop to radomize the numbers...

    cap

  • Was trying to solve this same problem as simple as possible and looks like all the .cap files are out of date.

    I am trying to create show numbers 1-3 randomly without repeating. Seems pretty simple but I am just getting stuck as my programming skills are not great. Any help is appreciated.

    Here is what I have tried.

    I have set three global variables.

    varX

    varY

    varZ

    On start of layout I am setting each of those...

    System > Set varX to floor(random(3)+1)

    System > Set varY to floor(random(3)+1)

    System > Set varZ to floor(random(3)+1)

    I am then setting text boxes on the layout to display each of the variables.

    What are my next steps to check that all three numbers are different. 1, 2, 3 should show up in a different order each time.

    Any help, explanation, etc. would be greatly appreciated. I am sure there is a much more simple way to approach this. Thanks for the time!

  • Took a stab. It seems to be working properly although I am wondering how to optimize make a lot more efficient as I can't imagine this being the most efficient approach. Any suggestions, improvements, etc. are greatly appreciated. Thanks for the time

    Here is the link to my .capx file via dropbox:

    db.tt/AzLg3meh

  • Thanks so much for the reply but I am on a newer version of C2 and cannot open to have a look at the example. Appreciate your time uploading Jayjay!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)