Weighted Random?

Get help using Construct 2

Post » Tue Dec 27, 2016 5:27 am

I know it truly isn't random if it is weighted, I just don't know how else to ask it.
Is there an easy way to do a weighted random between two values?

I have two values and am picking random numbers between them.


Is there a way to have middle numbers be selected more often lower/higher numbers.
(A Triangle on a scatter chart)


If not then is there a way to have higher numbers picked more commonly then lower and vise versa?
( An increasing slope or a decreasing slope on a scatter chart)


I assume this would have to be done with percent some how.

I would like a formula rather than using a ton of conditions, but I will take what is best.
B
67
S
37
G
13
Posts: 241
Reputation: 12,760

Post » Tue Dec 27, 2016 5:38 am

How many numbers? The very easiest (though not the best) way I can think of would just be something dead simple like choose(1,2,2,3,3,3,4,4,4,4,5,5,5,6,6,7)

For something a little more elegant, such as doing random damage based on rolls, check out this post:
random-number-percentage_t84426
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Tue Dec 27, 2016 8:17 am

You need my Not Quite Random plugin, @Unconnected. :)
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,255
Reputation: 46,484

Post » Tue Dec 27, 2016 5:13 pm

@colludium that's amazing. Great plugin.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Tue Dec 27, 2016 6:21 pm

Burvey wrote:@colludium that's amazing. Great plugin.


Thank you. It was a good learning experience and solved a problem I had at the same time! :)
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,255
Reputation: 46,484

Post » Tue Dec 27, 2016 6:26 pm

just a thought...

randomTriangle.capx
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Tue Dec 27, 2016 6:39 pm

Nice job bending, bender! :mrgreen:
B
67
S
37
G
13
Posts: 241
Reputation: 12,760

Post » Tue Dec 27, 2016 6:43 pm

@korbaach That's one thing that I really like about c2. There are lots of different ways to do similar things. Another nice example.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,991

Post » Thu Dec 29, 2016 6:57 pm

Colludium wrote:You need my Not Quite Random plugin, @Unconnected. :)

This will be useful in the future.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857


Return to How do I....?

Who is online

Users browsing this forum: Christmas, tioazis and 21 guests