← All lessonsLESSON 69 lines
LESSON 6 OF 13
RANDOM NUMBERS
Dice, coins and chance.
RNDINTIFcounting
RND(1) gives a random number between 0 and 1 (never quite reaching 1). To get a dice roll, multiply by 6, chop off the decimals with INT, and add 1: INT(RND(1)*6)+1. Multiply by 100 for a number from 0 to 99, and so on.
This is how every game decides whether the Argentines spotted you, whether the shot hit, or which word Hangman picks. Chance plus a loop plus IF is most of game programming.
Type with the keyboard under the screen, or tap the blue screen to use your phone's own keyboard. While a program runs, keys go to INPUT and GET. When it says READY., type a line and press RETURN to run it straight away.