Random Repetition

For questions about using Classic.

Post » Wed May 23, 2012 8:45 pm

How can I fill a list with numbers from 1-10 with random order but without repeating ?
B
7
S
2
G
2
Posts: 45
Reputation: 1,465

Post » Wed May 23, 2012 9:12 pm

You have to exclude the numbers already picked.
B
22
S
7
G
5
Posts: 90
Reputation: 3,430

Post » Wed May 23, 2012 9:16 pm

but how to do that?
B
7
S
2
G
2
Posts: 45
Reputation: 1,465

Post » Wed May 23, 2012 9:27 pm

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.Metal_X2012-05-23 22:07:57
B
22
S
7
G
5
Posts: 90
Reputation: 3,430

Post » Wed May 23, 2012 10:18 pm

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.
B
7
S
2
G
2
Posts: 45
Reputation: 1,465

Post » Wed May 23, 2012 11:17 pm

But you used loops? With loops you can do it in 1 frame.
B
22
S
7
G
5
Posts: 90
Reputation: 3,430

Post » Wed May 23, 2012 11:23 pm

shure but there is a problem using loops on this because i can not use expressions fpr writing the nubers to the variables.
B
7
S
2
G
2
Posts: 45
Reputation: 1,465

Post » Thu May 24, 2012 8:17 am

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.UnixRoot2012-05-24 08:30:45
B
7
S
2
G
2
Posts: 45
Reputation: 1,465

Post » Thu May 24, 2012 10:35 am

Here you go: http://dl.dropbox.com/u/52670878/example.cap
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Thu May 24, 2012 5:13 pm

Here: http://www.mediafire.com/file/18ez6q6i60ibwb7/randomunique.cap

EDIT oh, shadowlord beat me to it That brings up the question, why I saw his post not before posting mine tulamide2012-05-24 17:14:57
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests