# Block Idea: New Random Math Block

### A feature I’d like to see in Hopscotch is:

A different random math block

#### I’d use it for this type of project:

Any project that needs random numbers with chance

#### Here are some examples of Hopscotch code that could be improved if we had this:

Chances ALWAYS chooses the BIGGEST number which gets a bit annoying

#### Here is an example design I’ve made:

I cant make a picture of it soo here
(random () to () chance ()%)

#### I’ve seen something similar in another programming languages, it looks like this:

7 Likes

why do we need the chance?

5 Likes

Intresting… u could achieve this tho?

5 Likes

yeah you could

a math operator with decimals would be nice on the other hand though this could be achieved as well

7 Likes

I second that

6 Likes

It’s perfect for probability. I love the idea.

3 Likes

Based on the JS shown, that can be done exactly the same way like this:

``````Var x = Random (0, 100);
if (x < 50) {

} else {
...
}
``````
5 Likes

With the random block in Hopscotch, it can be done, but it might be easier if there was a block for it?

Just do random 1-100. It should work just as well.

4 Likes

True, but what if they wanted there to be a higher chance for some numbers to be selected than other numbers? Hence probability…

2 Likes

Wdym? Why would you go above 100?

2 Likes

Example: a higher chance that numbers 0-50 will be selected than numbers 51-100…

2 Likes

I see now… This would be beneficial then. But this doesn’t exist in JS the last time I checked?

3 Likes

True, but there is always a way to do probability: via a random number between 0 and 1,000,000 where it does a certain function if the number is in the range specified…

2 Likes

But that isn’t chance. That’s just random with bigger numbers.

1 Like

Just have 2 random functions. This, IMO, is not needed. Put logarithms in the last slot instead.

3 Likes

Like everyone knows how to use log lol

1 Like

The chance in this case isn’t the numbers, it’s the functions that it does. I’ll do an example project and show you what I mean later…

2 Likes

Confusion. Sorry, I’ve been living on 5 hours a sleep on average.

1 Like

So you are saying you want decimals in random? I still don’t understand.

3 Likes

Not really, but that would be cool if it was possible…

1 Like