Can I get your number? By Melissa Dalis Professor Susan Rodger Duke University June 2011.

Slides:



Advertisements
Similar presentations
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Advertisements

Space Man Sam: Grammar Mistakes By Aleis Murphy Duke University, Under the direction of Professor Susan Rodger July 2010.
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 3: Billboards, Events, Sounds,
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Rodger Duke University, July 2008.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
Alice Learning to program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Princess & Dragon Part 4: Breathing Fire—Adding Effects to Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
1 Quiz Template: Click on the match By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 2009.
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
Animated Charting Using the Alice Bar Chart Template World By Elizabeth Liang under the direction of Professor Susan Rodger Duke University December 2010.
Making a Book Report in Alice by Jenna Hayes Under the direction of Professor Susan Rodger Duke University, June 2010.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Distributing (Fun + Learning): The Distributive Property By: Peggy Li Under the direction of Professor Susan Rodger Duke University, June
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Making a Timer in Alice.
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
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.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Alice Pong Recreating Pong in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2010.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Distributing (Fun + Learning): The Distributive Property By: Peggy Li Under the direction of Professor Susan Rodger Duke University, June
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Distributing (Fun + Learning): The Distributive Property 1 Peggy Li Under the direction of Professor Susan Rodger Duke University, July 2011.
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Ready, SET, go! By Melissa Dalis Professor Susan Rodger Duke University July 2011.
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July 2013 Updates.
Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
Skater World: Part Four By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1, 2009.
Headshots in Alice Duke University Professor Susan H. Rodger Gaetjens Lezin July 2008.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
By Melissa Dalis Professor Susan Rodger Duke University June 2011
Skater World: Part Four
Changing Color, Using Text Objects, and Random Selection in Alice
Let's Race! Typing on the Home Row
Skater World: Part Three
Making Objects Move in Unison: Using Lists
How Tall Are You? Introducing Functions
Headshots in Alice Duke University Professor Susan H. Rodger
Making Objects Move in Unison: Using Lists
under the direction of Professor Susan Rodger
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

Can I get your number? By Melissa Dalis Professor Susan Rodger Duke University June 2011

Overview This tutorial will teach you how to build a world that animates the process of random digit dialing to collect a random sample. We’ll dial a certain number of the phone numbers, identify that number with a person in a population, and look at the end results. Programming concepts covered include arrays, billboards, loops, variables, events, random numbers, and other basic Alice concepts.

Adding objects Create a new world with the grass background. Let’s sample from the 919 area code in North Carolina, but you can change this later. Add a 3D text object from the object gallery that says “919-” and drag it to the top middle of the screen, and make sure you leave room for the rest of the number! In the object tree, rename 3D Text to phoneNumber.

Adding a billboard We want there to be instructions when the player plays the world. Make sure you’ve downloaded instructionsBillboard from the website. Click File, Make Billboard, and find instructionsBillboard. Move and resize instructionsBillboard so that it covers most of the screen.

Make sure you understand these instructions and how 2 aliceLiddells, for example, would represent 2 people in the 919 population with aliceLiddell’s demographics (blonde hair, blue eyes, young age, etc.)

Adding 10 people Find instructionsBillboard in the object tree, and go to its properties tab. Change isShowing to false. Find the People folder in the object gallery. Add the 10 people mentioned in the billboard: aliceLiddell, bikeKid1, bob, boy, euripides, iceSkater, kelly, pj, randomGirl2, and randomGuy1.

Putting people into a list Find the Visualizations folder in the object gallery, and select listVisualization. This listVisualization will allow us to have the people stand side by side on a line, each on his own square. Click new item until you have items 0-9. Click on the arrow next to each of the None’s select the people in the order that you added them.

In the object tree, rename listVisualization to allPeople. Move and turn allPeople so that it is in the middle of the screen facing forward. Resize the people (especially the ice skater) so that their heights look realistic.

Hide everything, show instructions In allPeople’s properties, change isShowing to false. For each of the people in the object tree, go to their properties tab and set isShowing to false. Do the same for phoneNumber. Set instructionBillboard’s isShowing to true.

Creating an event The instructions say that when the user presses enter, the game will start. Go to world’s properties and click create new variable. Name the variable “start” and make it type boolean with starting value false. In the Events section (top right corner), click on create new event and select When a key is typed. Change any key to enter, and Nothing to start (in world’s properties), and set start to true.

Writing world.my first method We’re going to start with the instructions up, and they’ll be removed when the user presses enter. Drag a While into the method, and select true. Drag start (from world’s properties) onto true. Click the arrow next to world.start, and select logic, then not start. From instructionsBillboard’s properties tab, drag isShowing into the method and select false.

At the top of the method, click create new variable, name it numPlays, set the type to Number, and set the value to 0. Drag numPlays into the method, and select set value, then 1, for now. From the world’s functions panel, drag ask user for a number onto the 1, select other, and type “How many people do you want to randomly select from the 919 population?” In phoneNumber’s isShowing (in its properties panel) into the method, and select true.

Create new method: world.dialNumber In the world’s methods tab, click create a new method, and name it dialNumber. Since we are always using 919, we have 7 digits left to make a complete phone number. Drag a Loop into the method, select other, 7, and click show complicated version. Create a new variable randNum of type Number. Drag randNum into the Loop, and select set value, 1.

From the world’s functions tab, drag random number onto the 1. We want random numbers between 0 and 9, and we want integers (you wouldn’t find a number like 4.3 in your phone number)! Click more… next to the 1, select minimum, 0. Click more… again, select maximum, and 10 (In Alice the maximum is never chosen, so it will really just go up to 9). Click more… again, select integerOnly, true.

We want to associate the first digit after the 919 to one of our 10 people in allPeople. Create a world variable called firstNumChosen of type Number. Drag an If/Else into the Loop and select true. Drag index (the counter of the Loop that goes from 0 to 7) onto true and select index ==, then 0. Drag firstNumChosen into the first Do Nothing, select set value, expressions, randNum.

After we add 3 digits to the phone number, we need to add a dash. Drag another If/Else statement below the one you just made and select true. Drag index onto true, select index ==, then 3. Find phoneNumber in the object tree, and go to its properties tab. Drag text into the Do Nothing and select default string, for now.

We want the phoneNumber to keep updating to what it already has. Drag text (again from phoneNumber’s properties) onto default string. From the world’s functions tab, drag a joined with b onto phoneNumber.text, and select other, then type “-”, and change duration to 0. Below the If/Else statement, drag text (again from phoneNumber’s properties), and select default string, for now.

We want the random number we generated to be added to the phone number. Drag text again onto default string. From the world’s functions tab, drag a joined with b onto phoneNumber.text, and select default string, for now. Drag what as a string from world’s functions onto default string, and select expressions, randomNum. To make sure randomNum comes up as an integer, drag int a as a string from the bottom of world’s functions onto randomNum, and select expressions, randomNum. Change duration to 0.

Check to see if your method is correct:

New method: choosePerson Now we want to associate the number we just dialed to a person in allPeople. Create a new world method called choosePerson. Create a new variable personChosen of type Object. Drag personChosen into the method and select set value, camera, for now. Find allPeople in the object tree, and drag items from the top of its properties panel onto camera, select ith item from list, expressions, firstNumChosen.

Keeping track of counts We need to keep track of how many times aliceLiddell, for example has been chosen (remember aliceLiddell represents all people in the 919 population with similar characteristics). Create a new variable in the world’s properties tab called howMany, of type Number, and select make a List, and change List to Array. Click new item 9 times, and set all of them to 0.

Relating allPeople and howMany To understand how and why allPeople and howMany relate to one another, here is a preview of what the final part of the animation will look like. In the picture, the small boy is saying that this is his second time being called. We kept track of the number of times he’s been called in howMany. The boy was item 7 in allPeople, and the number of times he’s been called (2) is item 7 in howMany.

Now we want to make the person at index firstNumChosen of the array show. First, we need to increment that person’s associated howMany by 1 (item 0 in allPeople will match with item 0 in howMany, etc.) Create a new number variable in this method, and name it numTimesChosen. Drag numTimesChosen into the method, and select set value, 1, for now. Drag howMany onto the 1, and select ith item from array, expressions, firstNumChosen. Click the last arrow in the line and select math, +, 1.

Drag howMany into the method, and select set item to, expressions, firstNumChosen, expressions, numTimesChosen, and change the duration to 0 seconds. Drag in a Do together. Find aliceLiddell in the object tree, drag isShowing from her properties into the Do Nothing, and select true. Drag personChosen onto aliceLiddell.

We want the person to say how many times they have been chosen. Drag personChosen into the Do together, select say, Hello, for now. Drag what as a string (from world’s functions) onto Hello, and select expressions, numTimesChosen. Drag int a as a string (from world’s functions) onto numTimesChosen, and select expressions, numTimesChosen.

Check your code:

Collecting more than one sample Go back to world.my first method. Drag a Loop into the bottom of the method, and select expressions, numPlays. From world’s methods, drag dialNumber into the Loop. Below that, drag choosePerson from world’s methods. To reset the number, drag in text from phoneNumber’s properties, select other, and type “919-”, and change the duration to 0.

After the Loop, drag in text again from phoneNumber’s properties, select other, and type “Our sample:”. We want all of the people to show at the end. Drag in a For all in order, select expressions, and allPeople.items. Drag in isShowing from phoneNumber’s properties, and select true. Drag item_from_items onto phoneNumber, and set the duration to 0 seconds.

Person says total # times been called Create a number variable called index with starting value 1, so that we can go through all the people’s indices. Drag item_from_items into the For all in order, and select say, Hello, for now. From world’s functions, drag what as a string onto Hello, and select camera, for now. From world’s functions, drag int a as a string onto camera, and select 1, for now. Drag howMany from world’s properties onto the 1, select ith item from array, expressions, index. Drag in index, and select increment by 1.

Check your code: