Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm Code World.my first method Control blocks Statements (methods, data, more)
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Next Step Problem Statement Understand the problem Implement the design Test the code Design a solution
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Load World Why start with a standard world for active learning? Load from: Presentations/Worlds 3-GoodVibrationsSetUp.a2w
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Do in order By default, statements in the code are performed in order, but you can also create a Do in order code block.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Control Statements Alice has two fundamental control statements Do in order perform the actions in sequence Do together perform the actions simultaneously
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater First action statement
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 1. Select object Start by selecting an object in the object tree (or click on the object in the scene)
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 2. Select methods tab In the details panel Tabs Properties values of object properties Procedures methods that perform an action Functions methods that return a value
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 3. Find method tile Scroll down in methods tab
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 4. Drag-n-drop Select data from drop-down menu… “turn to face” needs a target object
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Next Step Problem Statement Understand the problem Implement the design Test the code Design a solution
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Play (Run) Click the Play button
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater World.my first method When Play button is clicked, the world’s my first method is executed
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Modify Alice allows some optional information to modify how an action is performed. By default a statement in Alice runs in 1 second. The duration can be changed using more…
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Next action Actually, several actions
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Method? No “vibrate” tile? Method tiles built-in to Alice are simple actions Some models have complex actions defined, e.g., walk For other complex actions, we may create our own
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Decompose How can we create our own “vibrate” method? Decompose a complex action into simple actions garfield.vibrate do together play vibrating sound do in order garfield move up a short distance, quickly garfield move down same distance, quickly
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Create a new method
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Name the method Name should begin with a lowercase letter and have no spaces (use camelCase, if needed)
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater garfield.vibrate New method tile and editor tab
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Number pad Select “other” for number pad entry
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Duplicate Hold Ctrl(Alt on Mac) and drag statement down to create a duplicate
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Modify Click drop-down menu to select a different (argument) value
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Warning???
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Call the method Alice must be given an instruction to perform the actions defined in the method.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Does the action performed by garfield appear to be a vibration? Why or why not?
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Revise Design An object that vibrates is oscillating in a rhythmic repetition We need to repeat the action several times garfield.vibrate do together play vibrating sound repeat 5 times do in order garfield move up a short distance, quickly garfield move down same distance, quickly
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Loop Drag in Loop control tile and select “5 times”
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Loop control block Drag code statements into the Loop control block A block of program code that repeats a counted number of times.
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Does the action performed by garfield appear to be a vibration? Why or why not?
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Revise #2 Play a sound at the same time…. garfield.vibrate do together play vibration sound loop 5 times garfield moves up a short distance, quickly garfield moves down same distance, quickly
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Import sound World properties panel
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Imported file, timing
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Do together Drag in do together code block
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Play sound
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Nested control blocks Do in order inside do together
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Are sound and vibration in sync?
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Wait Useful for synchronizing sound and action
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Save Be sure to save the world every half-hour, or so…
Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Textbook More information Coding Chapter 2, Section 2