Can Random Function Exclude Certain Number Within Its Range?

Get help using Construct 2

Post » Tue Jan 13, 2015 4:10 am

lets say floor(Random(1,10))

Then, somehow I want to exclude number 5 and 8 from it's randomness since the beginning
B
10
S
5
Posts: 220
Reputation: 1,464

Post » Tue Jan 13, 2015 5:45 am

If your range is that small, might as well use choose(1,2,3,4,6,7,9,10)
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Tue Jan 13, 2015 6:02 am

there's a certain situation which requires the randomness in small range. The problem is when you can't use the number that has been used. If the value has been used, the variable gets randomize again.
Now, if the available number is getting fewer, let's say only 9, it would take time before the random function hit that number.

But if I can exclude some numbers, it will solve the problem.
B
10
S
5
Posts: 220
Reputation: 1,464

Post » Tue Jan 13, 2015 7:21 am

I see - this problem has been brought up here several times, I think I recently saw it asked again... Try this? https://www.scirra.com/tutorials/315/ge ... duplicates
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Tue Jan 13, 2015 7:32 am

I did this sample once for some else asking a similar question. Hope it helps.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 35 guests