Randomize two variables with no repetition

Get help using Construct 2

Post » Wed Jun 25, 2014 2:12 pm

How do I randomize two variables with, let's say two values without any repetition? For example, I have both A and B variable, which I'm going to set 0 and 1 for each other, whereas I need to avoid the A and B to set to 0 and 0 / 1 and 1 respectively. Sorry if this is obvious to you.
B
23
S
9
G
3
Posts: 114
Reputation: 3,794

Post » Wed Jun 25, 2014 2:17 pm

Creating a random number you use random(1,1000) << This is to create a random number between 1 and 1000.
It will also create for instance 234,3049. So to round it down you use round(random(1,1000)). I hope this helps you more with what you're trying to do.
B
6
S
1
Posts: 73
Reputation: 571

Post » Wed Jun 25, 2014 2:20 pm

Here's an example where when you press "S" on your keyboard the text changes to a random number between 1 and 1000.
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 73
Reputation: 571

Post » Wed Jun 25, 2014 2:26 pm

So you want to toggle them (more/less)
if A=0 then B=1
if A=1 then B=0
?
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Wed Jun 25, 2014 2:31 pm

I'm not quite sure what you're trying to do other than give them random numbers. Please gie me more detail on what you're trying to do.
B
6
S
1
Posts: 73
Reputation: 571

Post » Wed Jun 25, 2014 2:42 pm

I'm taking a wild guess here at exactly what you want..

Create an Array with the values that are the 'pool' of numbers to choose randomly from. Each time you choose 2 (or whatever) random numbers from this list (by index) remove them from the Array (using delete), so they cannot be repeated in further choices.

I'm using this technique when choosing where to spawn enemies, when there is a fixed number of 'zones' in which to spawn, and I don't want any spawning on the same zone.

If what you really want is just 0 and 1 as in your example, then there are simpler ways.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Jun 25, 2014 2:49 pm

Here's a example to illustrate this situation:

Assume I have excess numbers of apple and orange, which I will randomly choose four of them to put in four baskets respectively, in the form of 2 apples and 2 oranges exactly.

I've just tried my best to explain it, but I think it's related to permutation or combination.
B
23
S
9
G
3
Posts: 114
Reputation: 3,794


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests