1 / 40

Alice Workshop

Alice Workshop. Implementation Algorithm  Code World.my first method Control blocks Statements (methods, data, more). Next Step. Problem Statement. Understand the problem. Test the code. Design a solution. Implement the design. Load World.

hoshi
Télécharger la présentation

Alice Workshop

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods, data, more)

  2. Next Step Problem Statement Understand the problem Test the code Design a solution Implement the design

  3. Load World • Why start with a standard world for active learning? • Load from: Presentations/Worlds 3-GoodVibrationsSetUp.a2w

  4. Do in order By default, statements in the code are performed in order, but you can also create a Do in order code block.

  5. Control Statements • Alice has two fundamental control statements • Do in order • perform the actions in sequence • Do together • perform the actions simultaneously

  6. First action statement

  7. 1. Select object • Start by selecting an object in the object tree (or click on the object in the scene)

  8. 2. Select methods tab • Tabs • Properties  values of object properties • Procedures methods that perform an action • Functions methods that return a value • In the details panel

  9. 3. Find method tile • Scroll down in methods tab

  10. 4. Drag-n-drop Select data from drop-down menu… “turn to face” needs a target object

  11. Next Step Problem Statement Understand the problem Test the code Design a solution Implement the design

  12. Play (Run) • Click the Play button

  13. World.my first method • When Play button is clicked, the world’s my first method is executed

  14. 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…

  15. Next action • Actually, several actions

  16. 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

  17. 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

  18. Create a new method

  19. Name the method • Name should begin with a lowercase letter and have no spaces (use camelCase, if needed)

  20. garfield.vibrate • New method tile and editor tab

  21. Number pad • Select “other” for number pad entry

  22. Duplicate • Hold Ctrl(Alt on Mac) and drag statement down to create a duplicate

  23. Modify • Click drop-down menu to select a different (argument) value

  24. Test Warning???

  25. Call the method • Alice must be given an instruction to perform the actions defined in the method.

  26. Test Does the action performed by garfield appear to be a vibration? Why or why not?

  27. 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

  28. Loop • Drag in Loop control tile and select “5 times”

  29. Loop control block • Drag code statements into the Loop control block • A block of program code that repeats a counted number of times.

  30. Test Does the action performed by garfield appear to be a vibration? Why or why not?

  31. 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

  32. Import sound • World properties panel

  33. Imported file, timing

  34. Do together • Drag in do together code block

  35. Play sound

  36. Nested control blocks • Do in order inside do together

  37. Test • Are sound and vibration in sync?

  38. Wait • Useful for synchronizing sound and action

  39. Save • Be sure to save the world every half-hour, or so…

  40. Textbook • More information • Coding • Chapter 2, Section 2

More Related