Presentation is loading. Please wait.

Presentation is loading. Please wait.

Alice in Action with Java Chapter 5 Random Numbers.

Similar presentations


Presentation on theme: "Alice in Action with Java Chapter 5 Random Numbers."— Presentation transcript:

1 Alice in Action with Java Chapter 5 Random Numbers

2 Alice in Action with Java2 Random Numbers Certain kinds of applications need random numbers –simulations –games –encryption utilities use random numbers to create a code for scrambling the data being encrypted –programs that test other programs sometimes generate random sets of data

3 Alice in Action with Java3 Random Numbers in Alice The world has two functions –random number by default the function returns a number between 0 and 1 You can tell the function to use a different range by selecting more and then fill in the minimum and maximum values You can also specify integers only –choose true x% of the time

4 Alice in Action with Java4 Random Motion You could make an alice object move a random distance in a random direction with a –do together move forward/backwards by a random amount move up/down by a random amount move left/right by a random amount

5 Alice in Action with Java5 Choose true If you have an action that needs to happen some percentage of the time there is a world function to use Select choose true from the world's methods –select a per cent value


Download ppt "Alice in Action with Java Chapter 5 Random Numbers."

Similar presentations


Ads by Google