Handout with hints- week 6

advertisement
Project GUTS
Coding Challenges
Week 6- CS Concept Challenges: Logic, Conditionals, Data Collection, Multiple push and toggle buttons, collisions, graphs, sliders, traits,
breeds, keyboard control, take camera, detection, looping & nested loops, stamp vs. pendown vs. stampgrid, Boolean logic
Names: ____________________________
Description
a. Create a databox to keep track of time.
b. Re-set clock at setup to 0.
39
c. Give turtles a wiggle movement.
d. Use the clock to stop the movement after 500 ticks.
Hint
a. Edit widgets, make a new databox widget called ‘time.’
b. In World page, find the ‘set clock’ block, add it to the
setup code.
c. In Turtle page- use a forever block with forward, left
right and random blocks
d. Use a logic block with a greater than or equal to block
and the clock block to create an equation.
a. Add a push button for “hide databox” and another for
“show databox”.
b. & c. Use the push buttons to hide the clock databox and
show it again as the program is running.
a. Edit widgets, make a new push button widget called
‘hide databox’ and another new push button widget
called ‘show databox’.
b. Use a new ‘when….pushed’ block and add the ‘hide’
block inside this new block.
c. Repeat the above steps but for ‘hide.’
a. use 2 ‘create-do’ blocks, one for each color.
41
a. Create many agents of 1 breed, giving them 2 different
colors.
b. Use the collision block to make them change colors.
c. Make a graph that keeps track of the number of agents
of each color.
d. Make push buttons to hide and show the graph.
42
a. Have three push buttons,
b. one to add one agent, another to add two agents and
separate them, and another to add three agents and
separate them.
c. Have the agents draw a shape.
a. Edit widgets to add new push buttons.
b. Use 3 setup blocks, one for each amount of agents to
add.
c. This can be done in the Turtle page with a forever block
or on the World page with a 4th setup block.
40
b. Collision is a gray detection block.
c. First, create a graph widget, then edit the series to track
the colors. Add the graph code blocks in a forever block
d. See info for Coding Challenge #40.
Verified
Project GUTS
Coding Challenges
43
44
a. Create a slider, call it ‘angle with 0-360 range’.
b. Create a few turtles with pen down that wiggle.
c. Use the slider to change the agents’ Wiggle.
Create 2 breeds, 1 animal agent that moves around, the other a
breed (‘food’) that does not move. As the animal agent moves it
loses energy, when it ‘eats’ the food it gains energy. If the animal
agent’s energy gets too low, it dies. Add a graph & data box to
track the animal agent’s energy.
a. edit widgets, add a new horizontal slider widget
b. World page- setup to create turtles with a pendown. Turtle page
for the forever block to have them move- forward, left & right
degrees with random.
c. use a slider block instead of the random amount of degrees.
Energy is a trait that you must create by editing the breeds-> add a
trait.
This is like an ecosystem model.
Use the above model to view the model from the perspective of
the animal agent AND use keyboard controls to move it around
Spaceland to ‘eat.’
You can only have 1 agent. Use the ‘take camera’ block when it is
created and in the forever block use a logic block to create the code
for ‘if the left arrow is pushed, left degrees …’
Repeat this for the other directions (left, right, forward, back)
46
Create two breeds that wiggle around the world. Then, have 1
breed chase the other when they get within 20 steps.
Use detection blocks.
47
Make the breed being chased in the above project run away when
the chasing agent gets within 10 steps.
Similar code as above but moving in the opposite direction.
48
Use 1 agent to make a shape using a push button widget (not a toggle). Have the agent move to a slightly new position and/or angle to repeat
the pattern, like a spirograph. Include a “yield” block so the repeated drawing is visible.
49
Make a model with a coloring agent that uses the blocks, Stamp, Pendown & Stampgrid to color the terrain. Change the size of the coloring
agent to see the effect on each of these procedures. Make a moving agent that reacts to terrain color, and see whether its reaction depends on
which type of block is used to color the terrain. In the description box of your project, describe the difference between these three coloring
blocks and how you were able to ‘prove’ it.
50
Create 10 agents of a single breed and give the agents a new trait called age. Scatter the agents randomly along the left hand edge of
spaceland, facing the right edge. Set the agents’ color to one specific color, set their size to a random 1-4, and set their age to a random
10. Put the pen down. Copy this create block twice to create 10 agents with all the same traits except that each group of 10 is a different
specific color (to 30 total agents of 3 different colors). Create push buttons (not toggle) to make the Boolean logic commands that make the
agents move based on their traits. Make separate buttons for each of the Boolean commands (one with a simple Boolean, one using an
“and”, one using an “or”, one using a “not” or “not equal”) and one that combines all these possible Boolean commands.
45
Download