Stepwise Refinement -- A procedure calls another procedure

Slides:



Advertisements
Similar presentations
Love Lifted Me Click here to play The slides advance automatically with the words.
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.
Class-level Methods Chapter 6. Class-level Method Is specific to a class of objects We can give a class new abilities/methods Only involves this one class.
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.
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Don Slater Wanda Dann
Implementation with procedural methods. Recall: Step 3 Write statements (code) – a few steps at a time, not the entire program at once! Problem Statement.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Built-in Functions & Arithmetic Expressions.
Alice Methods and Classes. Methods and Classes Methods – Coordinated sequence of instructions carried out when requested (e.g. move, turn to, etc.) Class.
Don Slater Wanda Dann
SETTING UP CAMERA VIEWS LESSON Setting camera views using objects, based on a lesson by Bella. Adventures in Alice Susan Rodger Duke University July 2013.
Repetition Structures
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
Programming in Alice Chapter 2. Today’s Agenda Designing a Program Writing Methods Executing Instructions Simultaneously Comments Tips for Setting Up.
Exploring Events. Try this Start Alice and create a blank world using the grass template. Add an instance of a BlueBallerina. Add an instance of a PinkBallerina.
Programming in Alice Chapter 2 Part 2. Events Editor Identifies what method is executed (run) when the “Play” button is hit 2.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,
Methods Tutorial: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 9, 2008.
METHODS!.  A method is a sequence of instructions or behaviors that will be carried out when requested.  You can use them to create new methods so that.
Creating An Animation Program Alice Web Design Section 8-4.
Lights Camera Action! Part 2: Controlling Light in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2009.
Today’s Agenda 1.Collect Pre-Lab 4 2.Alice Programming Assignment Storyboards 3.Classes 4.Objects 5.Methods 6.Assign pair programming teams and meet upstairs.
Class-level Methods Chapter 6 part 1. Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of.
Motion and Rotation. 3 Dimensional Space  An Alice object o Is located in a 3D world, positioned at (x, y, z) o has 3 dimensions o height, width, depth.
Don Slater Wanda Dann Joint Operations Copyright 2012 Wanda Dann, Don Slater All rights reserved.
Poses Tutorial Alex Boldt Under the direction of Professor Susan Rodger Duke University July 2015.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
CS329e – Elements of Visual Programming Implementing Programs Mike Scott (Slides 2-2)
Variables & Random Number Generation.  A penguin is playing arctic basketball. The penguin has a basketball and will push the basketball toward.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Lists Tutorial By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Classes, Objects, and World-level Methods Alice. Larger Programs As you become more skilled in writing programs, you will find that programs quickly increase.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Mathematical Expressions, Conditional Statements, Control Structures
Don Slater Wanda Dann Copyright 2012 Wanda Dann, Don Slater All rights reserved.
3D Animation Concepts CS0007 George Novacky. Overview Creating a new world (slides 5 – 13) Remembering camera position (slides )
Alice 3.0 A Guided Tour Mike R-D YRDSB. Agenda General Walkthrough of Alice 3.0 Loops, Variables, Threads Methods / Properties Arrays Misc.
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Functions, Loops, and Parameters.
Repetition Structures Chapter 5 Part The While Instruction  Combines Loop and the condition that is also used in If/else statements  The loop.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Joint Motion Copyright 2014 Wanda Dann, Don Slater All rights reserved.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
An Introduction to Programming Using Alice 2.2, Second Edition Chapter 7 Recursive Algorithms.
Unit 2 Programming in Alice & Java 1. Day 1: Learning to Program  Objective: Understand the need for step-by-step logic; Basic working of a computer.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Setting Up the Initial Scene. Problem Solving in Alice Set up the initial scene in a new world The princess example Setting up the initial scene.
Beginning Animation. Storyboard An Invitation to Dinner 1.Marlin and Dory (two small fish) are swimming and talking. 2.A shark (Bruce) swims up behind.
Jonathon Kuo Under the Direction of Dr. Susan Rodger
Programming in Alice Chapter 2.
Setting Up the Initial Scene
Teaching Characters to Walk: Learning Methods, Part 1
Getting started in Alice
Making Objects Move in Unison: Using Lists
Introduction to Events
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Programming using Alice 3
Introduction to.
Making Objects Move in Unison: Using Lists
Memory Matching Challenge
Class-level Methods Alice.
Class-level Methods and Inheritance
Presentation transcript:

Stepwise Refinement -- A procedure calls another procedure

A curupira is playing soccer in the rainforest A curupira is playing soccer in the rainforest. The curupira has a soccer ball and will kick the soccer ball toward a pond in the forest. Each kick causes the soccer ball to move forward a random distance. If the curupira gets the soccer ball in the water, the curupira does a dance, otherwise he disappears, shocked that he didn’t succeed. The Curupira (Portuguese pronunciation: [kuɾuˈpiɾɐ]) is a mythological creature of Brazilian folklore. This creature blends many features of West African and European sprites but was usually regarded as mischievious. His name comes from the Tupi language kuru'pir, meaning "covered in blisters". According to the legend, this creature has bright red/orange hair and resembles a man or a dwarf, but its feet are turned backwards. – excerpted and edited from http://en.wikipedia.org/wiki/Curupira 2

Problem solving step 1 Download and open the world: CurupiraSoccerSetup.a3p

Problem Solving step 2 Design an algorithm Do in order curupira runs to soccer ball curupira kicks the soccer ball a random distance If soccer ball is in the water, curupira dances else curupira disappears

Problem Solving step 3 Implementation translate algorithm into code, one line at a time Do in order curupira runs to the soccer ball curupira kicks the soccer ball a random distance …

Decomposition Recall Decomposition -- take a complex procedure and break into smaller, simpler actions Do in order curupira runs to the soccer ball curupira kicks the soccer ball a random distance … runToObject Do together curupira performs running motion curupira moves forward to the ball

Problem runToObject Do together There is no running motion procedure for the curupira runToObject Do together curupira performs a running motion curupira moves forward distance to the <target>

Stepwise refinement Stepwise refinement: create another procedure & call it from this procedure myFirstMethod Do in order curupira runs to the soccer ball curupira kicks the soccer ball a random distance … runToObject Do together curupira performs running motion curupira moves forward to the ball runningMotion

Algorithm runningMotion Do in order Do together curupira right leg turns forward curupira left leg turns backward curupira right leg turns backward curupira left leg turns forward

Video: 14. Create a procedure This video illustrates the steps documented in slides 11 -12. Videos/14.CreateAProcedure.mp4

Open Curupira class document Select Curupira from the class menu in the code editor

Declare a new procedure Select Add Procedure… and name it runningMotion

Comment

Translating algorithm to code By default, actions are for this (entire) curupira Do in order Do together curupira right leg turns forward curupira left leg turns backward curupira right leg turns backward curupira left leg turns forward

Video: 15. Selecting subpart joints This video illustrates slide 16 Videos/16.SelectingSubparts.mp4

Select a joint in the skeleton Click on the instance menu Select an appropriate joint for the subpart In this example, select the hip because the leg subpart turns at the hip

Complete procedure Now add the code Remember the Do Together!

Working our way back up… myFirstMethod Do in order curupira runs to the soccer ball curupira kicks the soccer ball a random distance … runToObject Do together curupira performs running motion curupira moves forward distance to the <target> Create runToObject procedure and add call to runningMotion runningMotion Do together curupira right leg turns forward curupira left leg turns backward … We have completed runningMotion procedure

Implement runToObject Click on Curupira tab Click on Add Procedure… Name it runToObject 1 Class panel 2 This is an alternative way to add a new procedure to a class, using the class panel 3

Add comment Call runningMotion

Test runToObject Return to myFirstMethod in the Scene class

Test – call from myFirstMethod Do in order curupira runs to the soccer ball curupira kicks the soccer ball a random distance … Testing: Call runToObject from myFirstMethod runToObject Do together curupira performs running motion curupira moves forward distance to the <target> runningMotion Do together curupira right leg turns forward curupira left leg turns backward …

Call runToObject in myFirstMethod After we have defined the new procedure, runToObject… 3. 1. 2. … we need to call it somewhere in our program Select curupira in the instance menu Drag the runToObject tile into myFirstMethod in the editor Click on Run