Tips & Techniques 6 Random Numbers and Random Motion Alice.

Slides:



Advertisements
Similar presentations
AliceWhileLoop1 While Loop in Alice Stephen Cooper Wanda Dann Randy Pausch Barb Ericson Oct 2009.
Advertisements

CS320n –Visual Programming Class-level Methods and Inheritance – Part 1 Mike Scott (Slides 4-3-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger.
Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
Parameters Alice.
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Introducing While loops (and random numbers too) Alice.
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
Alice in Action with Java Chapter 5 Random Numbers.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Fall 2007ACS-1805 Ron McFadyen1 Functions and if-else A function is a collection of statement, similar to a method, but a function is defined to return.
Creating an Animation Program Alice. Step 1: Design Decide on the problem to be solved Design a solution We will use a storyboard design technique, commonly.
CS320n –Visual Programming Functions Mike Scott (Slides 6-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Execution Control with If/Else and Boolean Functions Example: Single Condition Alice.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Creating An Animation Program Alice Web Design Section 8-4.
Execution Control with If/Else and Boolean Functions
Execution Control with If/Else and Boolean Functions Sec 52 Web Design.
Execution Control with If/Else and Boolean Questions Part 1 Alice.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Tips & Techniques 4 Visible and Invisible Objects Alice.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Writing Our Own Functions Alice. Functionality A function receives value(s), performs some computation on the value(s), and returns (sends back) a value.
What we will do today Learn about functions in Alice.
Functions Alice.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Variables and Functions Alice. Naming is Important If you get a new pet one of the first things you do is name it Gives you a way to refer to the new.
Functions Sec 8-11 Web Design. Objectives The Student will: Understand what a function is Know the difference between a method and a function Be able.
Programming: Simple Control Structures
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Variables & Conditions.
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Repetition: Definite Loops Sec 53 Web Design. Objectives The Student will: Understand loops and why they are used Understand definitive loops Know how.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Programming: Simple Control Structures Sec 46 Web Design.
Parameters Alice. A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Tips & Techniques 4 Visible and Invisible Objects
Functions Sec 51 Web Design.
While: Indefinite Loops
Functions Sec 8-11 Web Design.
Programming: Simple Control Structures
Class-level Methods Alice.
Repetition: Definite Loops
Programming: Simple Control Structures
Parameters and World-level methods
Programming: Simple Control Structures
Repetition: Definite Loops
Programming: Simple Control Structures
Repetition: Definite Loops
Functions Alice.
Programming: Simple Control Structures
Functions Alice.
Tips & Techniques 4 Visible and Invisible Objects
Programming: Simple Control Structures
Creating An Animation Program
Class-level Methods and Inheritance
Functions Alice.
Functions Alice.
Presentation transcript:

Tips & Techniques 6 Random Numbers and Random Motion Alice

Random Numbers Random numbers are used in certain kinds of computer programs Examples: security for web applications encryption for satellite transmissions gaming programs scientific simulations In this session, we will look at examples of how to use random numbers in animations

Built-in functions Alice provides World-level built-in functions for generating random numbers.

Demo Ch06Lec3PenguinRandomMoves Concepts illustrated in this example The random number function returns a floating point value between 0 and 1. A different range of values can be obtained by using the minimum and maximum parameters. The integer only option allows selection of either floating point or whole numbers.

Random 3D Motion In the previous example, the penguin moves in only one direction. In some animations, we want an object to move to a random location in 3D. We call this random 3D motion. For example, the goldfish in this world is to swim in a random motion, where the fish can move in any direction.

Six possible directions Of course, six move directions are possible forward, backward, left, right, up, down In this example, we can eliminate backward because goldfish do not swim backward. To simplify the code, we can take advantage of negative numbers. For example, this instruction actually moves the goldfish right:

Storyboard Only three move instructions are needed: up (will move down if the random number is negative) left (will move right if random number is negative) forward (no backward motion) Two parameters (min, max) will be used to restrict the motion of the fish to a nearby location-- to look like swimming. randomMotion Parameters: min, max Do together fish moves up a random number distance fish moves left a random number distance fish moves forward a random number distance

Demo Ch06Lec3GoldfishRandom3DMotion Concepts illustrated in this example A random movement in 3D space is accomplished by three simultaneous move instructions. In this example, the minimum distance of the move forward instruction is 0 (the goldfish always moves forward). To call the randomMotion method, min and max values are sent as arguments to the parameters

Assignment Read Tips & Techniques 6, Random Numbers and Random Motion