Alice in Action with Java Chapter 5 Random Numbers.

Slides:



Advertisements
Similar presentations
Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly.
Advertisements

Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
Building Java Programs
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Parameters Section 8-8 Web Design. Objectives The student will: Understand what a parameter is Understand how to use a parameter in Alice Understand how.
4.1.2: What Does the Unit Circle Tell Me?
Introducing While loops (and random numbers too) Alice.
CS320n –Visual Programming Random Numbers and Random Motion (Slides 6-3) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for slide ideas.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 5 Interactive Programs.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming - Putting Together the Pieces.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 12 – Craps Game Application: Introducing Random.
©2004 Brooks/Cole Chapter 6 Methods and Scope. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 A Method Can Be Viewed as a Black Box To use a.
f has a saddle point at (1,1) 2.f has a local minimum at.
Functions and Conditionals in Alice 1 Stephen Cooper Wanda Dann Barb Ericson September 2009.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
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.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Discrete Distributions The values generated for a random variable must be from a finite distinct set of individual values. For example, based on past observations,
Chapter 4: Loops and Files
Random numbers in Alice 3. Create world, add character (“Red” in this example) Dragged walk tile to right onto Run method. Click on “??? “ part of Tile.
For Wednesday No new reading Complete WebCT quiz.
Understanding Randomness
D ATA A NALYSIS Histogram Second Generation Third Generation First Generation.
Writing Our Own Functions Alice. Functionality A function receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Functions Alice.
Events (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Methods and Data Programming with Alice and Java First Edition.
Simulation is the process of studying the behavior of a real system by using a model that replicates the system under different scenarios. A simulation.
Simulating Experiments on the TI Section Starter Use the random integer generator in your calculator to choose an SRS of 5 students from.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
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.
The Monty Hall Simulation
1 CS151 Introduction to Digital Design Chapter 1 Lecture 3.
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 2 Creating Your First Animation (An Introduction to Programming)
1.3 Graphs of Functions Equations are mathematical ___________________________. ______________________ are what make the sentences true. A ________________.
Georgia Institute of Technology More on Creating Classes part 1 Barb Ericson Georgia Institute of Technology Oct 2005.
Repetition: Definite Loops Sec 53 Web Design. Objectives The Student will: Understand loops and why they are used Understand definitive loops Know how.
1 MATERI PENDUKUNG TIPE DATA Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Random Numbers RANDOM VS PSEUDO RANDOM. Truly Random numbers  From Wolfram: “A random number is a number chosen as if by chance from some specified distribution.
Chapter 6—Objects and Classes The Art and Science of An Introduction to Computer Science ERIC S. ROBERTS Java Objects and Classes C H A P T E R 6 To beautify.
Greatest Integer Function
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Adding and Eating Worms Mrs. C. Furman August 23, 2010.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Computer Science Up Down Controls, Decisions and Random Numbers.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Recap: If, elif, else If <True condition>:
Parameters Section 8-8 Web Design.
Functions Sec 51 Web Design.
DO NOW: Write this down Textbooks covered by TUESDAY NEW for MP3:
Functions Sec 8-11 Web Design.
Random number generators
Functions Alice.
Chapter 1-Lesson 1 Position and Motion Vocabulary
X y y = x2 - 3x Solutions of y = x2 - 3x y x –1 5 –2 –3 6 y = x2-3x.
More on Creating Classes
Functions Alice.
Functions Alice.
Functions Alice.
Presentation transcript:

Alice in Action with Java Chapter 5 Random Numbers

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

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

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

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