Repetition Everywhere Assessment David Yan Under the direction of Susan Rodger

Download Report

Transcript Repetition Everywhere Assessment David Yan Under the direction of Susan Rodger

Repetition Everywhere
Assessment
David Yan
Under the direction of Susan Rodger
Duke University
June 2015
Challenge Overview
•This assessment is designed to cover BDE
events in Alice. It should take about 20 minutes
to complete this assessment.
•Before completing this assessment please
complete: “Repetition Everywhere” and “Lights
Camera Action! Part 3: BDE Events.”
•You will need to know how to use while loops
in addition to creating events.
Starter World
•Open the BDE_assessment.a2w world.
•You see that a few methods have already been
provided for you: camel.eatTumbleweed,
tumbleweed.tumble, and snake.slither.
•You do not have to edit any of these methods.
•Your world.my first method should not contain
any code.
•The objects (camel, snake, smallCactus,
tumbleweed, and squirrel) have already been
placed for you.
Goal
•Your goal is to convert loops and method code
in Alice to BDE events.
•The world should begin with the tumbleweed
saying “tumble time” then rolling toward the
squirrel. Once the tumbleweed is within a meter
of the squirrel, the squirrel should call the camel
for help. The camel should then come and eat
the tumbleweed. The snake should say “Ahhh
my cover is blown” and slither away.
Methods explained
•camel.eatTumbleweed – this method tells the
camel to eat the tumbleweed
•tumbleweed.tumble – this method tells the
camel to tumble towards the squirrel
•snake.slither – this method tells the snake to
first say “Ahhh my cover is blown” then slither
away from the scene
world. my first method
•Your world. my first method should not contain
any code to start.
•You will fill in the code for this method yourself.
•First, you should have the tumbleweed say
“Tumble Time”
•Then, you should write code that has the
tumbleweed tumble toward the squirrel until it
is a meter away (Hint: consider a while loop).
•Next, the camel should move in and eat the
tumbleweed and thus save the squirrel.
world. my first method
•Your world. my first method should look like
this:
world. my first method con’t
•Now run your world and observe what
happens.
•Next we will be translating these methods to a
BDE event.
Creating the BDE Event
•Go to events and drag in a new BDE event
block. Be sure to choose the “while something is
true” event.
•Be sure to consider the order in which the
events ran in the method space when thinking
about which events to place in the Before,
During, and End spaces.
•(Hint: Your while condition should not change)
Begin
•Your begin
statement should
have the
tumbleweed saying
“Tumble Time.”
•Consider the first
method that was
called in the method
space of this
program when
During
•The “During” block
should contain a
method that tells the
tumbleweed to tumble
toward the squirrel
until they are a certain
distance apart.
•Hint: again consider
the order of the
methods in world. my
End
•The “End” block of
your BDE should
contain a method that
has the camel
approach the
tumbleweed and eat it.
•Hint: consider the
order of the methods
in world. my first
method.
When
•You will notice that in world. my first method,
we created an if-statement that had the snake
slither away when the tumbleweed is eaten
(tumbleweed opacity is 0%).
•We will recreate the same effect in the Alice
event space.
•To begin, drag a new “While Something is
True” block into the Alice event space.
•However, right-click that block and select
“change to” then “When something becomes
When con’t
•The “When something
becomes true” block
functions very similarly
to a “If true”
statement.
•We want to create the
condition in the event
space that when the
tumbleweed is eaten,
the snake should slither
Final Result
•Now, disable all the code in your world. my first
method window and run only the code found in
your event space.
•To confirm that everything is correct, go to this
link and see if your program functions the same
as the one in video at this link:
•If it is the same, then YOU HAVE COMPLETED
THE CHALLENGE!!
•CONGRATULATIONS!!