introduction to alice
play

Introduction to Alice Alice is named in honor of Lewis Carroll s - PDF document

3/18/13 CS101 Lecture 20 Introduction to Alice Alice is named in honor of Lewis Carroll s Alice in Wonderland Slides Credit: Joel Adams, Alice in Action With thanks to John Magee for his guidance about these materials Alice A modern


  1. 3/18/13 CS101 Lecture 20 Introduction to Alice Alice is named in honor of Lewis Carroll ’ s Alice in Wonderland Slides Credit: Joel Adams, Alice in Action With thanks to John Magee for his guidance about these materials Alice � A modern programming tool � 3-D graphics � 3-D models of objects � Animation � Objects can be made to move around the virtual world (a video game or simulation implemented in 3-D) � Two kinds of animations: � Movie: passive user watches the animation � Interactive: active user clicks on mouse, types a key on keyboard … � Actions of user are called events 1

  2. 3/18/13 Demo: Getting started � Starting Alice � Load and run a world � FairyCourt(movie) � HelicopterSimulation(interactive) � First program: Alice and WhiteRabbit welcome us to their world (movie) Getting and Running Alice � Alice software is freely distributed � Downloading Alice � Go to the website: http://www.alice.org � Click the link Get Alice 2.3 � Click download link specific to your operating system � Save Alice.zip (or Alice.dmg ) to your PC � Installing and running Alice � Extract Alice from Alice.zip (or Alice.dmg ) file � Create desktop shortcut (alias) to Alice.exe � Double-click Alice icon to launch Alice application 4 2

  3. 3/18/13 The Alice Tutorials (continued) Go through the tutorials to learn the basics of Alice 5 Program Design � We don’t start with writing program code, very much the same as filmmaker don’t start with filming, rocket scientists don’t start with building rockets � We start with design! � Design is very important and affects the correctness and efficiency of the solution � Design needs to revised, improved… Alice in Action with Java 6 3

  4. 3/18/13 Algorithms � An algorithm is a sequence of steps to solve a problem or perform a task � Example algorithms: � Driving directions � Cooking instructions � Installation instructions � Algorithms for search of records in phonebook, database, web… � Algorithms for displaying, editing, animating pictures… � The flow of a user story in an animation � Algorithms are generally not tied to programming languages � Their implementations are Alice in Action with Java 7 User Stories � Contain � Basic description of what happens when program runs � Nouns in story (Alice, the White Rabbit) correspond to objects � Verbs correspond to actions, responses to messages � Chronological flow describes the sequence of the actions When the program begins, Alice and the White Rabbit are facing each other, Alice on the left and the White Rabbit on the right. Alice turns her head and then greets us. The White Rabbit also turns and then greets us. Alice and the White Rabbit introduce themselves. Simultaneously, Alice and the White Rabbit say “ Welcome to our world. ” Alice in Action with Java 8 4

  5. 3/18/13 Program Design � For a given user story � plan scenes and shots � Scene: a piece of the story usually set in one location � Shot: part of scene told with camera in one position � Create storyboards Alice in Action with Java 9 Transition Diagrams � Link the multiple storyboard-sketches � In a movie, transition diagram is a linear sequence � In the first Alice program, there will be 7 actions Alice in Action with Java 10 5

  6. 3/18/13 The Flow of User Story A numbered sequence of objects and actions 1. Alice turns her head toward the user 2. Alice greets the user 3. The white rabbit turns toward the user 4. The white rabbit greets the user 5. Alice introduces herself 6. The white rabbit introduces himself 7. Simultaneously, Alice and the white rabbit say “ Welcome to our world. ” Alice in Action with Java 11 Programming Implementation in Alice � Templates provide a basic world environment � Sample program is based on the “ grass ” Template � Areas in the Alice window � Menus: includes File , Edit , Tools , and Help � Buttons: includes Play , Undo , and Redo � Object tree: lists all world objects; e.g., ground � Details area: includes properties, methods, functions � World window: displays graphic objects in a program � Editing area: includes editing space and controls � Events area: contains actions responding to events Alice in Action with Java 12 6

  7. 3/18/13 Programming Implementation in Alice (continued) Alice in Action with Java 13 Program Style � Change program display styles in Preferences � How to access Preferences dialog box � Click the Edit menu � Click the Preferences choice � Selecting a display style in Preferences dialog � Click next to “ display my program ” in General tab � Select a style � Style recommended for course: Java Style in Color Alice in Action with Java 14 7

  8. 3/18/13 Program Style (continued) (We are aware of a problem with this setting. It ’ s ok to keep it as Alice style.) Alice in Action with Java 15 Demo: A new world � Create a new world � File  New � Choose template 8

  9. 3/18/13 Objects � An " object " is � any thing that can be identified as unique from other things � How is an object unique? � has a name � has properties: � width, height, color, location � can perform actions (methods): � associated actions it can perform � tasks it can carry out Object Parts � Objects may be composed of parts 9

  10. 3/18/13 Class � Objects are categorized into classes peter Person paul mary spike Dogs � Each object is scottie an instance of the class. fluffy � All objects in a class have similar properties and generally can perform the same tasks. Adding Objects to Alice � Class: blueprint for an object � How to populate Alice world with objects � Click Add Objects button in world window � Locate class specifying the object in the Alice Gallery � Right-click class and select “ Add instance to world ” � Objects in sample world: aliceLiddell and whiteRabbit � Naming conventions for objects and classes � Class: capitalize all words; e.g., AliceLiddell � Object: capitalize all but first word; e.g., aliceLiddell � Objects can be renamed from the object tree Alice in Action with Java 20 10

  11. 3/18/13 Demo: Adding objects Galleries � Classes (3D models) are found in the galleries � Local gallery (installed with the software) � Minimum or complete options � Web gallery 11

  12. 3/18/13 Adding Objects to Alice (continued) Alice in Action with Java 23 Demo: Saving a world � Writing and testing an animation is an intense load on the computing system – a crash can occur. � Best solution: � save your world every 15 minutes � (Or at least every half hour) � also save to a backup system (for example, a zip disk or memory key) 12

  13. 3/18/13 Accessing Object Subparts � Bounding box: encloses any Alice object � Impact of selecting an object in the object tree � Bounding box is drawn around object in world window � Details area adapts to the selected object � First action to program: Alice turns head to user � First set of programming steps � Select + sign next to aliceLiddell in object tree � Select + sign next to neck subpart � Select head (bounding box is drawn, details change) � Drag doInOrder control to top of editing window Alice in Action with Java 25 Accessing Object Subparts (continued) Alice in Action with Java 26 13

  14. 3/18/13 Accessing Object Subparts (continued) Alice in Action with Java 27 Sending Messages � Alice programs rely on sending messages to objects � Objects ’ methods deliver actions in response to messages � Programming Alice ’ s head to turn � Select Alice Liddell ’ s head in the object tree � Scan through the methods in the details area � Click on pointAt() � Drag pointAt() to the editing area and drop it � Specify camera as the target Alice in Action with Java 28 14

  15. 3/18/13 Sending Messages (continued) Alice in Action with Java 29 Testing and Debugging � Bug: error interfering with normal program functions � Debugging: process of removing program bugs � Click the Play button to test Alice Liddell application � Alice Liddell ’ s head will turn toward the user Alice in Action with Java 30 15

  16. 3/18/13 Testing and Debugging (continued) Alice in Action with Java 31 Coding the Other Actions � say() message � Displays dialog for an object � Text can be customized by selecting other… � Task: complete first Alice Liddell application � Add Alice Liddell ’ s initial greeting � Point the white rabbit to the user � Have Alice Liddell introduce herself � Have the white rabbit introduce himself � Customize messages by selecting from more… � Example: adjust fontSize of message text to 25 Alice in Action with Java 32 16

  17. 3/18/13 Coding the Other Actions (continued) Alice in Action with Java 33 Statements/Instructions � Statement/instruction: a line or control structure in a program that executes (is carried out by computer at runtime) � Program: a set of instructions that tell the computer what to do � Basic format of a line in an Alice program � object.message(value); more... � Control structures manage other statements � Example: doInOrder contains other statements Alice in Action with Java 34 17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend