Public Service Announcement Movies made with the Alice Programming Language A Real World Engineering Project for Computer Science and Computer Engineering.

Download Report

Transcript Public Service Announcement Movies made with the Alice Programming Language A Real World Engineering Project for Computer Science and Computer Engineering.

Public Service Announcement
Movies made with the Alice
Programming Language
A Real World Engineering Project for
Computer Science and Computer Engineering
Motivation (1)
Computer animations are used everywhere in entertainment and
advertisement.
A public service announcement (PSA) is a type of advertisement, but
one with a social mission. It can raise awareness to an important
issue, stimulate the change of public attitudes, or rally people to act
toward a good cause.
Typical PSA themes include:
Public safety (e.g. how to avoid identity theft, the perils of underage
drinking),
Public health (e.g. promoting self-exams for breast cancer, avoiding H1N1
contamination),
Education (e.g. promoting reading programs, teaching vocabulary),
Civic duty (e.g. participating in governmental elections),
Environmental awareness (e.g. reduce/reuse/recycle programs, avoiding
watershed pollution).
2
Motivation (2)
In this project you will:
• Work with a team to produce an animated PSA using Alice, a visual
programming language.
• Learn to use technology for communication and also receive an
introduction to computer programming, a highly desirable
professional skill.
• Put in practice the engineering design process, a frame of
reference for how we practice our profession.
• Have the opportunity to put together a visually interesting message
of your own choosing, which can have a strong impact on society.
• Your PSA can be used by a producer as an animated storyboard to
create a live action movie, or yet be used directly in media (such as
TV or the Internet).
3
The Alice Programming Language
• You’re working with a real, object-oriented programming
language.
• It’s visual, in the sense that your programs can produce
animations and also in the sense that you don’t have to type
much.
• Alice works in an integrated development environment (IDE),
where you do all the programming and execution of your
code.
• Assignment A0: Tutorials – Complete Tutorial 1 and Tutorial 4,
trying to work as independently as you can. You may want to ask a
few questions to colleagues and to your instructor, though.
There is no deliverable for this assignment.
4
Abstraction (1)
Think of how most of us just *use* a car; we don’t all
care to build it or to know how all its systems work.
What we care about is what we need to do to get the
car to do what we want it to do.
We abstract, i.e. hide, the details of how it works
behind the interface we use to give it commands.
• You’ve seen that the Alice works with constructs called “objects.”
• In Tutorial 1, when you see the IceSkater in Alice, it’s not the real
thing, obviously. It’s a representation which retains only the most
important details of a real IceSkater: the looks, the movements, etc.
• The IceSkater object is an abstraction. It helps you concentrate only
on the aspects of a real one which are interesting to you.
5
Abstraction (2)
Although the Alice IceSkater has many details, they only go so
far (we don’t model her socks, for instance, because they
don’t matter to our animation of her movement).
The object tree on the side shows that the IceSkater is
composed of other objects – Clothes, ThighL, ThighR, etc.
Clicking on each node marked with + expands to its
subcomponents.
Points to note: An object can be contained inside another
object. This allows for the construction of complex objects
with many subparts, but which exist as a cohesive whole.
You can’t easily tack pieces together to build new Alice
objects, but you can augment an existing object’s
properties, methods, and functions.
Later on, if you make copies of your augmented object, the
copies will carry all your modifications.
6
Abstractions in Alice Programming (1)
Every object in Alice has properties, methods, and functions:
Properties describe characteristics, think of them as a kind of memory,
the state of the object. We can leave them as they are by default, we
can change them before an animation starts, and we can change
them in the course of an animation.
Properties have types: they can be a number,
a piece of text (String), a Boolean (true of
false), among other possibilities.
Example problem: Create an Alice world, add a Chicken object to it and go to
its properties. Add a new property (variable) so that the chicken can remember
how many roads it has crossed. You must give this variable an appropriate
name, choose the right data type, and give it an initial value. Drag the variable
into World.my first method and describe what happens.
7
Abstractions in Alice Programming (2)
Methods represent actions that the Alice object can perform. Think of
them as “verbs” which might be followed by grammatical direct or
indirect object and/or adverbs (modifiers).
Example problem: Open an Alice world, add a beachball object and a
basketball object far from each other. Go to the beachball’s methods and drag
move onto the programming pane, which says World.my first method. You’ll
have to choose a direction and a distance for the movement. These are
“parameters” to the method move, which modify the action. Note that forward is a
relative notion – investigate how the methods turn to face and orient to change
what an object sees as forward. Next, add to the program also move to so that
you can make the beachball go where the basketball is. Experiment with other
motion methods like turn, roll, etc. Note that you can combine motions using the
do together construct. Contrast the results of the two code snippets below.
8
Abstractions in Alice Programming (3)
Functions represent computations that the object can perform. Think
of them as “questions.” You could ask an object “what is your
distance to this other object?”, or “what is your height?”, or yet, “are
you above this other object?” A function can encapsulate a
mathematical computation and always return some type of result
(answer).
d
r
f
f(d, r) = d / (2*pi*r)
Example problem: Create a function for a
beachball object that computes how many
revolutions it will do when rolling without
slipping over a distance of d meters (d and r,
the radius of the ball are input parameters to
this function. Create an animation where this
enhanced ball object rolls without slipping
across a distance of d meters. Hint: create a
method with one parameter, which combines
turning f(d,r) revolutions and moving d
meters in a do together.
9
Key Objects to Note
Every Alice world comes with a few standard objects:
• World – the most important of all. It’s built by composition and
serves as a container for all the objects that you use in an
animation.
• Camera – shows what you see in the animation.
• Light – the source which illuminates the scene.
• Ground – what you build everything upon.
Start the Alice IDE and click on the add objects button. Explore the
objects that appear in the Local Gallery and drag any 4 or 5 which
you’d want to add to the world. You can’t go wrong here, so just pick
a few.
10
Working with Light
• Left-click on the light in the object tree, then go to it’s properties.
• Try changing the color of your light source by selecting different
values for it’s color variable.
• Note that this changes the current state of the light source statically,
that is, in the scene set up before the animation starts to execute.
During an animation, you can change color dynamically, what is
much more interesting. Let’s try that out with a program.
• Drag the color attribute into World.my first method and select blue.
• Repeat this dragging and now select orange.
• Press the play button to run the animation and notice what happens.
• Go back to the program and click on more in one of the light set
color to line. Choose a value for duration. Repeat with the other
line and run the animation again. Notice what happens.
11
Making a Scene
Alice gives you libraries of objects for
building animations, as you’ve already
seen.
Click on the add objects button. Notice the
link to Home where the arrow indicates
in this figure. Click on it and discover that
there are two rich object galleries: Local
and Web. Explore them by browsing
inside the folders and learning what
objects are there for your use.
12
Assignment A1: Alice at Home
• Create an Alice world that contains a grass field.
• Look for Alice and the White Rabbit in the galleries and add them to
the scene. Position them close to the camera and have them face
each other. Add other decorations to the scene to create an “Alice in
Wonderland” type of look.
• Look for a small bird and place it on Alice’s left shoulder. When you
go into “add objects”, make sure to select the “quad view” radio
button, which will let you see the scene from 4 angles. Ensure that
the bird really rests on Alice’s shoulder.
• Save your world to a file named with your last name, first initial, and
“-A1”. For instance, Eric Clapton’s file would be saved as:
claptonE-A1.a2w
This is the deliverable for the assignment.
13
Congratulations!
• You’ve just started to work like an engineer.
• Engineers follow a 10-step design process, which we’ll
discuss throughout this project.
• The first step is to “identify the problem”, which you completed
by understanding the assignment.
• Another step is to “establish design criteria, goals, and
constraints.” The specifications in the assignment give you
goals and constraints.
• Yet another step is to “identify potential solutions”. Does your
scene meet all the specs? Beware: if doesn’t, it is not a real
solution! At the same time, there are many possible scenes
that can be satisfactory.
14
Camera Work
Movies shot with a stationary camera, without any zoom, can
be less interesting that those with some kind of creative
camera movement. You can use the movement methods for
“camera” to create interesting changes in perspective.
Example problem: Load your A1 world then use the
camera’s directional controls to position it at an angle you like. Click
on add objects, then on more controls, and finally on drop dummy
at camera. Expand the Dummy Objects folder in the object tree and
make note of the name of the object just created (Dummy, in this
case). The dummy marks the coordinates of the camera’s location.
Move the camera to a very different location and repeat the process.
Now, select the camera object, go to methods, and click on create new
method. Name this method focus on and give it two parameters of type object.
Complete the implementation as on the left.
Finally, invoke this method twice in World.my
first method: the first time, use Dummy for
location, and Alice for point; the second time
use Dummy2 and White Rabbit, respectively.
15
Control Structures (1)
Alice gives you the three standard programming languages
mechanisms (and a little more):
1. Sequencing: By default, “lines” of the program execute one after
the other.
2. Selection: The if/else construct allows the program to choose
between the execution of two different blocks of code based on the
evaluation of a logical expression.
3. Repetition: The constructs loop and while cause the repeated
execution of a block of code.
Alice also gives you the do together construct, which causes the
concurrent execution of the individual commands within a block of
code. The do in order construct allows for the sequential execution
of a block of code nested inside do together.
16
Control Structures (2)
Example problem: Replicate the scene and the
program in the figure on the right. Execute the
program and observe what happens.
Note that if is followed by a call to a function of
bunny, which returns a Boolean value (true or
false).
Change the value of the parameter in the call to
the bunny’s resize method on the first line to 5.
Rerun and observe how the animation changes.
Do you understand now how to use the if/else
construct?
17
Control Structures (3)
Example problem: Starting from the same scene set
up in the previous slide, replicate program A on the
right. Note that if is followed by a call to a function of
bunny, which returns a Boolean value (true or false).
Change the value of the parameter in the call to the
bunny’s resize method on the first line to 5. Rerun and
observe how the animation changes.
Now, replicate and run program B and compare this
execution with what you saw for A.
Both the loop and the while constructs cause
the repetition of the call to the cow’s walk
method. Why are these constructs, which
serve similar purposes, written so differently?
What explains the different results produced
by the two programs?
Program A
Program B
18
Preparing for the Big Show
• To prepare you for the larger team project, we need to
introduce you to more serious programming with Alice.
• We need you to form teams of 3 or 4 people to work together
in a preliminary assignments and later in the project.
• In order to get everyone ready and to promote individual
accountability, there will be components of the assignments
for each student to tackle on their own.
• There will also be team components to get you used to
working together.
• Pay attention to components of the assignments to
understand whether they are individual or group work.
19
Assignment A2: Rock Concert
You will build a short animation, a movie that shows a rock
concert.
Each member in your team will construct two components
individually: a musician playing an instrument and a member
of the audience doing a simple dance routine.
The team will later combine people’s components into a single
Alice world: a movie with a soundtrack and some “fancy”
camera work. This will teach you the skills you need to make
a great PSA later. It gives an opportunity for your team to
learn to work together.
The descriptions of the components of the assignment are as
follows.
20
A2 Individual (1)
• Click on add objects and go to the web gallery. Find the folder for
Environments and in there the concert stage object – add it to
your world.
• Return to the gallery and find the People folder. Choose someone
who might look like a rock star and put the object on the stage.
• Find the Musical instruments folder in the gallery and pick one
instrument to give to your musician. Position it appropriately so that
your rock star can play it.
You will have to adjust the pose of the person to hold the musical
instrument.
• Go to the object tree, select the person object and start clicking on
the “+” signs you see for that person. This will expand into the
movable parts within that person’s body.
21
A2 Individual (2)
• Select one part of the object to adjust and right-click on it. Put the
cursor on the methods menu which appears.
• Experiment with the methods move, turn, and roll. Note that for
each method, you might need to select one or more modifiers, which
are method’s parameters.
• Every time you adjust the position on one part of a musician’s body,
you are calling or invoking a method.
• Experiment with the methods and parameters options to adjust the
pose of your musician so that they appear to hold the instrument you
gave them.
• Go back to the people folder in the gallery and choose someone
who could be in the concert audience.
• Place that person in the world facing the musician on stage. Adjust
that person’s pose so that they look like they are dancing.
22
A2 Individual (3)
• Your world should now have a musician with instrument on stage
and one audience member facing the stage.
• Time to start on the animation. First of all, though, you need to learn
to make new methods.
• Complete Tutorial 3 before continuing. If you have already started
the Alice IDE, you start the tutorial from the Help menu. Go to
Help->Tutorial and select “Tutorial 3: Defending Naptime.”
• Take a moment to look at the program for Tutorial 3, when you
complete it. Notice how the story is organized around short
sequences, which correspond to methods of the World object.
• Keep this structure in mind so that you create your animations
around similar top-down organization.
23
A2 Individual Deliverables
• Create a method in your musician called animate. It must have a
sequence of movements that make the musician look like playing
the instrument. No need to make it super complex.
• Create an animate method in the audience member. This method
should encapsulate a simple dance; e.g. pump arms in the air twice,
jump up, and come down.
• In World.my first method, create a loop like:
• Run the world to test your animations and
adjust as you see fit.
• Right-click on each of your characters to save object to a file. Use
names like: claptonE-A2-audience.a2c and
claptonE-A2-musician.a2c
• Save your Alice World to a file named:
claptonE-A2.a2w
24
A2 Individual Work Specifications
1.
2.
3.
4.
5.
6.
7.
You have two objects: a musician and an audience person.
Both of your objects contain a method named animate.
The animate for the musician is a single run though a sequence of
movements that make it look like she’s playing the instrument. It’s been
tested to conform to what you want to have.
The animate for the audience person is a single run through a dance
routine. It’s been tested to conform to what you want to have.
Your person objects and chosen musical instrument are placed
appropriately in a world that contains a concert stage object.
Your World.my first method contains a loop that iterates infinity times; its
body contains calls to the animate of both your characters.
You have three files, two .a2c containing one character each, and one
.a2w containing your world and program.
25
The Engineering Design Process
So far, all your Alice programs were very short and simple. As you develop
more complex projects, you need a systematic method. Engineers work with a
process created to tame this complexity. You will start practicing it with your
team.
1. Identify the problem
2. Research and gather data
3. Establish design criteria/goals/constraints
4. Identify potential solutions
5. Analyze potential solutions
6. Develop and test models
7. Select the best alternative
8. Communicate and specify for implementation
9. Implement and/or commercialize
10. Perform post-implementation assessment
26
Software and Engineering (1)
If you were to simply throw lines of code together and bang on the program until
it works that would make you a ‘hacker’, not a software engineer. To work as a
bona fide engineer, you need to follow the systematic approach of the EDP
outlined in the previous slide.
1.
Identify the problem: The programming problem is spelled out clearly for
you. It’s still up to you to understand it completely. Ask for clarifications
where they are needed; brainstorm with your colleagues.
2.
Research and gather data: You may have to work harder at digging
deep into the problem. Talk to the client, analyze what knowledge is
missing and go after it. Collect all information you need.
3.
Establish design goals/criteria/constraints: Enumerate what objectives
you must achieve, the constraints you must observe, an objective list of
points that will indicate how well a solution meets expectations.
27
Software and Engineering (2)
4.
Identify possible solutions: There are many ways to construct a
program to meet some goal. You might come up with one or more ideas
to develop: save them to decide later which one to expand.
5.
Analyze potential solutions: Look at your solutions in the light of your
goals, constraints, and criteria. You’ll be able to junk immediately anything
that doesn’t meet all goals or that violates constraints. If assign points to
how well the solution meets each specific criterion, you’ll be able to
compute a numeric score for each solution. The solutions which have the
highest scores possibly have the best potential.
6.
Develop and test models: You can write a program top-down,
concentrating on the larger aspects first (and on structure) and leaving
details to be fleshed out later. This can be used to see if your programs
(solutions) are as good as your analyses indicated.
7.
Select the best alternative: By now, you have enough material to
choose the solution that seems to be the best.
28
Software and Engineering (3)
8.
Communicate and specify for implementation: The real world
gives you open ended problems and often only a partial lists of
specifications. The engineer must enumerate the specifications
which will guide the development of the program. This involves
communicating with the client so that all parties agree on what
needs to be built.
9.
Implement and/or commercialize: This is when programming
talent is put to the test. The program is fully fleshed out, tested by
the developers and then tested by independent parties. Bugs will
be found and corrected, before it’s given out for commercialization
or public use.
29
Software and Engineering (4)
10.
Perform post-implementation assessment: How well the
process worked can only be determined by the analysis of the final
product. No program is so perfect that it has no room for
improvement. This assessment gathers information that the
engineer can use in a future version of the program. Depending
on the degree of success of the solution, the engineer might
iterate the whole process or only part of it. With programs, the final
users will often find more bugs and suggest different or additional
functionality.
With your Alice animations, the audience will show you what
needs to be expanded, or cut, or done differently.
30
A2 Team Work (1)
• Get together with your team and bring all your individual files.
• Choose one team member’s Alice world to work with.
• Going to File->Import, add each team member’s characters to the
world, one at a time. Adjust each object’s location as you like, but
put musicians on stage facing the crowd, and audience members
facing the stage.
• Create a loop similar to the one used to test individual work, but
containing method calls to animate all musicians and audience
members.
• Run the combined animation to test it. If all went well with individual
work, this should work right away.
31
A2 Team Work (2)
• Using a program like Audacity, clip an mp3 song of your choosing
down to 30 seconds or so.
• In Alice, select the ground object and drag it’s play sound method
into World.my first method. Choose to import a sound file, that is,
your mp3 clip.
• Think carefully about where you should place this method call in
your program so that the song clip plays along with the animation.
• Run your animation, which now has a soundtrack, and watch it as a
group. Discuss how you can make the camera move around so that
your have a more interesting movie.
• Create an animate method for the camera object and add a call to
this method to the loop in your World.my first method. The effect of
animate should be to have the camera cycle through two or more
positions and orientations.
32
A2 Team Work Deliverables
1. With your group, go through the previous two slides for group work
on A2 and develop what you perceive is the list of the specifications
for this work. Save this to a document file labeled with your team’s
name and ‘-A2-specs’ and turn it in. (EDP step 8)
2. Create one single program to satisfy the specifications your
created. Save it to an Alice world labeled with your team’s name
and ‘-A2.a2w’; for instance: teamA-A2-a2w.
3. After implementing, testing, and debugging your program (which
integrates individual contributions from all team members and adds
some more code), watch it as a team. Brainstorm on what you
would have done differently, what you would change in a future,
improved version. Organize and document these ideas to turn in as
a file labeled with your team’s name and ‘A2-post’. (EDP step 10)
33
The Road Ahead
By now, you have learned quite a bit of object-oriented programming
and practiced the EDP to a small extent.
Watching the final program that yours and other teams in your class
have created for A2, you can begin to realize the potential of Alice
programming for creating animations.
So far, the development of your programs was strictly guided by the
assignments. From now on, you will work on a project, which is very
open ended. You will need select the theme (or message) for your
PSA, create an interesting way to call attention to and deliver your
message, and apply your skills to produce the animation.
The project will be developed in five phases described as follows.
34
Phase 1: Proposal
• Write a proposal describing the idea that your team will use for the
project. You don’t have to specify in detail what the animation will
show. Instead, you should describe the topic that you will address
and the goal you hope to accomplish with your movie.
• Follow a memo format, such as:
35
Phase 2: Design (1)
Write a design document for your movie. You should have a top-down
description that lists the scenes and within each scene, each specific shot.
Structure your work around methods of the World object to be called in
sequence from World.my first method, such as: scene1.shot1,
scene1.shot2, scene1.shot3, scene2.shot1, scene2.shot2, …
Scene 1: Environment
Shot 1: Overview of forest
Shot 2: Zoom in to look at animals
Shot 3: Turn camera toward river
Scene 2: Urban
Shot 1: Overview of cityscape
Shot 2: Zoom into junkyard
…
For each active object, list the
methods that you will need to
implement.
Scene 1 active objects and methods:
- bunny: hop distance d
- bee: fly around
- deer: graze
…
Your implementation doesn’t have to follow every detail in this plan, what
means you are allowed to change things, as long as you stay on the topic
proposed in Phase 1.
36
Phase 2: Design (2)
Constraints: (given to you, but need to appear in document)
• Total length of the animation: between 30 seconds and 1 minute.
• Audio: animation must not be silent, must not use just Alice’s built in
sounds; must have background music and/or narration.
• One or more objects must use these constructs at least once: new
method, new function, loop, while, do together.
Goals/Criteria: (your team defines and includes in document)
• List of goals you will achieve with the project.
• A simple rubric to evaluate how well your possible solutions meet the
goals of the project.
Evaluation:
• Brief description of 3 movie ideas that might meet your proposal.
• Discussion of how your rubric (criteria) indicated which one is the best
to implement.
37
Phase 3: Implementation
Create an Alice program that realizes your design and agrees with constraints
as one single file containing the animation and soundtrack. Your team will
need to define whether you all work together or whether you will divide up
the work. Be careful, though: objects augmented by individual work can be
exported and then imported into a common team world, but multiple entire
worlds cannot be imported into a single one.
Phase 4: Presentation
The team presents the PSA to the rest of the class. A team member introduces
the team, the topic, and the goal of the movie. Next, the movie is shown. Team
spends 5 minutes describing how the work was done, shares stories about the
conceptual work, the implementation of the Alice program, lessons learned, and
technical challenges. The team and the individual team members will make an
effort to be professional. Each team member will participate actively in this
presentation.
38
Phase 5: Report
The final component of the assignment is a written report. It must be
organized into sections; at a minimum it must contain:
• An introduction to the topic, including a persuasive argument calling
attention to the social impact expected of the PSA (material used in
the Phase 1 proposal).
• The final design of the animation, which corresponds to the
implementation of the PSA. This is necessary as the Phase 2 design
may have changed.
• A conclusion including the identification of the lessons learned plus
a post-implementation assessment based on the team’s evaluation
and on the perceived reaction from the presentation.
39
Societal Impact
The final judgment on how well your animation works to deliver a message
would depend on complex surveys of the public after some considerable
time following the first presentation of the PSA. A careful observation of how
your instructor and classmates react to what your team constructed can go
a long way.
As evidenced by experiences of the Ad Council (http://www.adcouncil.org/), a
well-constructed PSA can be instrumental in educating the public or in
calling attention to important societal causes.
What you produce for this project can be either a final product or the seed in
the development of a live action movie. Apply yourself and do your very
best. If you’re confident in what you produced, at the end of the process,
you can post your PSA online to spread your message (on YouTube, for
instance) or even pass it to along someone who might produce a more
refined version based on your animated screenplay.
40