P1kachu presenʦ: How to program with Geometry Dash! (Part 5)
May 27, 2016 21:51:49 GMT -5
Sp4rks, Safyire, and 4 more like this
Post by [ℙ][✓] P1kachu on May 27, 2016 21:51:49 GMT -5
If you haven't read Part 4 yet, please read it first:
gdforum.freeforums.net/thread/28579/p1kachu-presen-program-geometry-dash
Now we will talk about Random Number Generators! (RNG)
RNGs, which are self-explanatory, generate random numbers.
This might be my most confusing part ever...
First, we must know what probabilities are.
So if you hate math you could go ahead and skip the next section.
Probability is how much of the time, something could happen. It is usually represented by a fraction.
For example, when you toss a coin, there is a 1/2 probability you would get a heads.
To get the probability of something, you must get the number of possible cases you get it, then divide it by all the number of possible cases.
So another example is what is the probability you can get a sum of 7?
You list all the possible cases for this:
(1,6),(2,5),(3,4),(4,3),(5,2),(6,1) There are 6 cases.
And the number of possible rolls you could get is 36.
So the probability is 6/36 = 1/6.
So to get a fair RNG, every number must be equally likely to be chosen.
Now that you know what probabilities are,or you just skipped it...
Time to create an RNG in Geometry Dash!
Although we can't make a true RNG in Geometry Dash, since it cannot generate random numbers itself, we can just use the player's randomness.
First, list all the possible values. You can put any number of numbers you want, but in this example, I will use numbers from 1 to 5.
But listing the numbers will be different for making RNG, unlike variables.
If you want 5 numbers, you will list it like this: 1 2 3 4 5 1 2 3 4
If you want 13 numbers, you will list it like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 5 6 7 8 9 10 11 12
Also put a pointer at 5.
You will know later why we need to put it in that way.
Now set the numbers in Group 1, but not the pointer.
Now make a small obstacle course like an orb jump. I will make it in 0.5x speed, but you can put any speed you want.
Now for the fun part, stacking hundreds of Move triggers on top of each other. ( ͡° ͜ʖ ͡°)
First, put 5 move triggers in a line.
Now, set them all to Group 1, Toggle Trigger checked and Move Time to 0.
For easier understanding, let N be the number of numbers you have in the list.
I bet that a little algebra won't hurt... So in this case, N = 5.
For the first move trigger, set the Move Y to 10(N-1) units. If N = 5, 10(N-1) = 40.
For the rest of the move triggers, set the Move Y to -10 units.
Now stack them on top of each other, but they must have a slight distance apart.
Now duplicate them, stack them on top of each other, they must have a slight distance apart.
Then put them where the orb is.
Now Save and Play and that's it! You have made your own RNG
"How did you know that it is a fair RNG?"
Thank you for reading, I hope you understood all of this. Please like
Now give me a cookie ( ͡° ͜ʖ ͡°)
gdforum.freeforums.net/thread/28579/p1kachu-presen-program-geometry-dash
Now we will talk about Random Number Generators! (RNG)
RNGs, which are self-explanatory, generate random numbers.
This might be my most confusing part ever...
First, we must know what probabilities are.
So if you hate math you could go ahead and skip the next section.
Probability is how much of the time, something could happen. It is usually represented by a fraction.
For example, when you toss a coin, there is a 1/2 probability you would get a heads.
To get the probability of something, you must get the number of possible cases you get it, then divide it by all the number of possible cases.
So another example is what is the probability you can get a sum of 7?
You list all the possible cases for this:
(1,6),(2,5),(3,4),(4,3),(5,2),(6,1) There are 6 cases.
And the number of possible rolls you could get is 36.
So the probability is 6/36 = 1/6.
So to get a fair RNG, every number must be equally likely to be chosen.
Now that you know what probabilities are,
Time to create an RNG in Geometry Dash!
Although we can't make a true RNG in Geometry Dash, since it cannot generate random numbers itself, we can just use the player's randomness.
First, list all the possible values. You can put any number of numbers you want, but in this example, I will use numbers from 1 to 5.
But listing the numbers will be different for making RNG, unlike variables.
If you want 5 numbers, you will list it like this: 1 2 3 4 5 1 2 3 4
If you want 13 numbers, you will list it like this: 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 5 6 7 8 9 10 11 12
Also put a pointer at 5.
You will know later why we need to put it in that way.
Now set the numbers in Group 1, but not the pointer.
Now make a small obstacle course like an orb jump. I will make it in 0.5x speed, but you can put any speed you want.
Now for the fun part, stacking hundreds of Move triggers on top of each other. ( ͡° ͜ʖ ͡°)
First, put 5 move triggers in a line.
Now, set them all to Group 1, Toggle Trigger checked and Move Time to 0.
For easier understanding, let N be the number of numbers you have in the list.
I bet that a little algebra won't hurt... So in this case, N = 5.
For the first move trigger, set the Move Y to 10(N-1) units. If N = 5, 10(N-1) = 40.
For the rest of the move triggers, set the Move Y to -10 units.
Now stack them on top of each other, but they must have a slight distance apart.
Now duplicate them, stack them on top of each other, they must have a slight distance apart.
Then put them where the orb is.
Now Save and Play and that's it! You have made your own RNG
"How did you know that it is a fair RNG?"
When you add up all the numbers in the triggers, you will get 4+(-1)+(-1)+(-1)+(-1) = 0
So when we activate all the triggers in a set of 5, you get 0.
So list all possible values we will get:
(-1)+(-1)+(-1)+(-1) = -4
(-1)+(-1)+(-1) = -3
(-1)+(-1) = -2
(-1) = -1
0 = 0
(-1)+(-1)+(-1)+(-1)+4 = 0
(-1)+(-1)+(-1)+4 = 1
(-1)+(-1)+4 = 2
(-1)+4 = 3
4 = 4
(-1)+(-1)+(-1)+(-1)+4+(-1) = -1
(-1)+(-1)+(-1)+4+(-1) = 0
(-1)+(-1)+4+(-1) = 1
(-1)+4+(-1) = 2
4+(-1) = 3
(-1)+(-1)+(-1)+(-1)+4+(-1)+(-1) = -2
(-1)+(-1)+(-1)+4+(-1)+(-1) = -1
(-1)+(-1)+4+(-1)+(-1) = 0
(-1)+4+(-1)+(-1) = 1
4+(-1)+(-1) = 2
(-1)+(-1)+(-1)+(-1)+4+(-1)+(-1)+(-1) = -3
(-1)+(-1)+(-1)+4+(-1)+(-1)+(-1) = -2
(-1)+(-1)+4+(-1)+(-1)+(-1) = -1
(-1)+4+(-1)+(-1)+(-1) = 0
4+(-1)+(-1)+(-1) = 1
So when we get all the possible event, they are:
-4, -3, -2, -1, 0, 0, 1, 2, 3, 4, -1, 0, 1, 2, 3, -2, -1, 0, 1, 2, -3, -2, -1, 0, 1.
When we get the probability for each event, we have:
0 has 5/25
1 and -1 has 4/25
2 and -2 has 3/25
3 and -3 has 2/25
4 and -4 has 1/25
Since we have 5 for 0, 4 for 4 and -1, 3 for 3 and -2, etc.
Each number will add up to 5/25 = 1/5.
Therefore, each number has the same probability, which makes it fair.
So when we activate all the triggers in a set of 5, you get 0.
So list all possible values we will get:
(-1)+(-1)+(-1)+(-1) = -4
(-1)+(-1)+(-1) = -3
(-1)+(-1) = -2
(-1) = -1
0 = 0
(-1)+(-1)+(-1)+(-1)+4 = 0
(-1)+(-1)+(-1)+4 = 1
(-1)+(-1)+4 = 2
(-1)+4 = 3
4 = 4
(-1)+(-1)+(-1)+(-1)+4+(-1) = -1
(-1)+(-1)+(-1)+4+(-1) = 0
(-1)+(-1)+4+(-1) = 1
(-1)+4+(-1) = 2
4+(-1) = 3
(-1)+(-1)+(-1)+(-1)+4+(-1)+(-1) = -2
(-1)+(-1)+(-1)+4+(-1)+(-1) = -1
(-1)+(-1)+4+(-1)+(-1) = 0
(-1)+4+(-1)+(-1) = 1
4+(-1)+(-1) = 2
(-1)+(-1)+(-1)+(-1)+4+(-1)+(-1)+(-1) = -3
(-1)+(-1)+(-1)+4+(-1)+(-1)+(-1) = -2
(-1)+(-1)+4+(-1)+(-1)+(-1) = -1
(-1)+4+(-1)+(-1)+(-1) = 0
4+(-1)+(-1)+(-1) = 1
So when we get all the possible event, they are:
-4, -3, -2, -1, 0, 0, 1, 2, 3, 4, -1, 0, 1, 2, 3, -2, -1, 0, 1, 2, -3, -2, -1, 0, 1.
When we get the probability for each event, we have:
0 has 5/25
1 and -1 has 4/25
2 and -2 has 3/25
3 and -3 has 2/25
4 and -4 has 1/25
Since we have 5 for 0, 4 for 4 and -1, 3 for 3 and -2, etc.
Each number will add up to 5/25 = 1/5.
Therefore, each number has the same probability, which makes it fair.
Thank you for reading, I hope you understood all of this. Please like
If you recreate a Random(0, 20) using text to display and then attempt to calculate if a number is Random[15, 20] in which case it changes the background, I'll do whatever you want for a week.
Now give me a cookie ( ͡° ͜ʖ ͡°)