A fair prize

ChallengeChance

A mystery box in your game should give a prize about half the time. This script tests the box 100 times, but the chance is wrong.

What should happen

  1. The script opens the box 100 times.
  2. About half the time there is a prize.
  3. So the log says a number near 50.

What happens now

The log says a number near 10. The chance is 1 in 10. Players would open box after box and get nothing.

The chance nowTriesThe sumPrizes we expect
1 in 10100100 ÷ 1010

How to fix it

Work out which chance gives about 50 prizes in 100 tries.

You wantTriesThe sumSo the chance is
About 50100100 ÷ ? is 501 in ?

Then change the script:

  1. Press Code, at the top left of the code box, if it is not picked already.
  2. Find the line if a 1 in 10 chance.
  3. Change the 10 to your answer.

No problems detected

Goals0 of 1 passed

  • A prize about half the time: 35 to 65 out of 100: not checked yet

Press Play and make every goal pass. A goal is checked when its moment in the game comes.

Test it

Press Run. The goal under the code box gets a tick when the prizes are between 35 and 65.

Why not exactly 50? Because chance never gives exactly what we expect. The test leaves a margin, like you did with your jumps.

Make every goal and every test pass to finish this section.