Weighted Random?

Get help using Construct 2

» 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
82
S
42
G
13
Posts: 270
Reputation: 13,689

» 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
62
S
20
G
57
Posts: 1,077
Reputation: 36,531

» Tue Dec 27, 2016 8:17 am

You need my Not Quite Random plugin, @Unconnected.
Learning other engines, but C2 still rocks.
B
81
S
22
G
96
Posts: 2,470
Reputation: 58,357

» Tue Dec 27, 2016 5:13 pm

@colludium that's amazing. Great plugin.
B
62
S
20
G
57
Posts: 1,077
Reputation: 36,531

» 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!
Learning other engines, but C2 still rocks.
B
81
S
22
G
96
Posts: 2,470
Reputation: 58,357

» Tue Dec 27, 2016 6:26 pm

just a thought...

randomTriangle.capx
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

» Tue Dec 27, 2016 6:39 pm

Nice job bending, bender!
B
82
S
42
G
13
Posts: 270
Reputation: 13,689

» 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
62
S
20
G
57
Posts: 1,077
Reputation: 36,531

» 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,867