How do I change random odds?

Get help using Construct 2

Post » Mon Aug 11, 2014 1:19 am

Hi everyone,

Sorry I am messaging from my phone so I can't do screenshots.

I am using the action-
Set Instance Variable To = choose 1,2,3

In order to return a random number, 1, 2 or 3.
However if I would like the number 2 to come up more often, could I write it as-
Choose 1,2,2,3
Or even
Choose 1,2,2,2,2,3

Thank you
B
9
S
2
Posts: 56
Reputation: 668

Post » Mon Aug 11, 2014 2:38 am

Yes
ImageImageImage
B
71
S
21
G
231
Posts: 3,694
Reputation: 129,364

Post » Mon Aug 11, 2014 4:16 am

But what if I want to make it like 99% chance to hit 0 and 1% to hit 1? Do I have to write 0 for 99 times or is there a better way?
B
18
S
4
Posts: 87
Reputation: 1,199

Post » Mon Aug 11, 2014 4:47 am

Yes Daniel, that would happen. And that's a good question...
B
33
S
9
G
3
Posts: 493
Reputation: 4,042

Post » Mon Aug 11, 2014 4:59 am

Then you do int(random(100)), and check if the value is 0. If not then treat it as 1.
ImageImageImage
B
71
S
21
G
231
Posts: 3,694
Reputation: 129,364

Post » Mon Aug 11, 2014 5:27 am

@danielbishop56 @Remus B
How I'd do it for probability with chance:

Case study:
A=10% chance
B=30% chance
C=60% chance

Capx:Updated below
Last edited by DuckfaceNinja on Mon Aug 11, 2014 6:55 am, edited 2 times in total.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Mon Aug 11, 2014 5:35 am

Thank you!
B
18
S
4
Posts: 87
Reputation: 1,199

Post » Mon Aug 11, 2014 6:55 am

@Remus B
Update: Showing probability draw difference from infinite sample and definite sample
Probability.capx

For infinite sample, the result may vary because the sample is infinite.
For definite sample of 100, no matter how many time you draw 100, you'll get A=10, B=30, C=40
You do not have the required permissions to view the files attached to this post.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924


Return to How do I....?

Who is online

Users browsing this forum: amazingdream, lordsas, mekonbekon and 66 guests