Random+Number+Generators

Warm-up
Play the game: Poke the Penguin

How does the computer decide when the bunny will bite? Is it the same every time? It is a random number of pokes. It is not the same every time.

Random Number Generators
Any good computer game has some randomness in it.

What are some ways to get random numbers in real life?

A computer uses a Pseudo-Random Number Generator to generate a number between 0 and 1. Why is it called "Pseudo-Random"?

Remember: computers can only do what we tell them to. So how do we get computers to "make up" a random number?

The algorithms for creating a random number generator can be quite complicated, but often the algorithm is based on the current time in milliseconds.

Random Numbers in ActionScript
To get a random number in ActionScript, we use Math.random, as in: code format="actionscript3" var myNum:Number = Math.random; code This gives a number between 0 and 1.

What do we do if we want a number between 0 and 10?

What do we do if we want a whole number between 0 and 10?

You try: Make a program that simulates a coin flipping. (Hint: How many possible numbers will you need to pick from?) Try running your program 10 times - how many heads do you get? How many tails do you get?

For more information about picking random numbers visit: @http://www.random.org/randomness/