3.8 Line follower

Today, students create a simulation!
The cat always finds and follows the black line. The cat is not on a predetermined route. It takes environmental input and finds a black line to follow.


OBJECTIVES:

OBJECTIVES: By the end of this lesson students will:

    • recognize that a computer simulation is a behavior model determined by inputs.

    • observe that simulation output is determined by input information.

    • apply IF or IF-ElSE conditional statement

    • observe that if-else yields greater precision.

Demo: If
Press space bar to change backdrops.
Does not work on Back drop 4.

Demo: If-Else
Press space bar to change backdrops.
Works on spicy backdrop 4

TEACHER RESOURCES:

Standards

    • CSTA 2-AP-12: Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.

    • CSTA 2-DA-09: Refine computational models based on the data they have generated.

CSTA

DO NOW:

Students watch the video Computer Simulation (2:06) then discuss:

    • No one animated hair movement on the Pixar movie "Brave". Hair was animated using computer simulation. What does this mean?

    • First the artist looked at how real hair works. They designed a spring system, but the system did not work when she turned her head at high speeds. What did they use as a digital hairspray?

TEACHER GUIDANCE:

Hair was run through a computer simulation to generate it's movement. This simulation uses the physics of how springs work, to replicate movement.

Artists used a core spring to stabilize the hair (digital hairspray) the for high movement shots. Simulations model real world behavior.

Mini-Lesson (5-10 minutes)

Wraparound Slide 9 -24

Computer Simulations reproduce the behavior of a natural system using a computer model. (algorithms and equations)

Simulations model real-world problems safely and efficiently. Simulations models a system, and uses environmental input to determine outcomes.
The outcome is not predetermined. A simulation reproduces natural behavior in a controlled environment.



This lesson is about simulation. The cat will always find and follow the black line.

The cat does not have a predetermined route on the stage. The algorithm does not tell it where to be on the stage.

Rather the algorithm tells it to follow the environmental input and simulate a path whereby the cat finds and follows a black line.

When the black line changes, so does the cat's position on the stage.

Simulations are very powerful, because they allows us to replicate real life scenario's without the need to test them in real-life.

Sometimes simulation can take days to process, crunching all the input data through complex models.


Here are some examples of computer simulations. -Ask students if they can think of others?

    • Animation: An animator animates the 3D model to perform an action such as walking or running. A simulation is then run to animate the cloth and hair which drapes over the model as it moves, using the inputs of friction, gravity and fabric tension.

  • Fluid Dynamics: Simulating the flow of fluid, using the input data of terrain, fluid thickness (viscosity) and volume. This is useful in animation and in simulating flood conditions on the occasion of a levee or Dam breakage.

  • Forecasting water temperature: using specific local meteorological data as input.

  • War games: using terrain and army supply and weapon capability data for each team simulate who the winner is.

  • Cell Biology: using molecules and their states to simulate cell behavior.

Project (20-30 minutes)

Project Guidance:

Before students start to code they should review the completed project with the aid of the student handout.

Students should complete Pseudocode at their table and circle their ideas. e.g. When touching pink should you rotate left or right or move forward?

The starter project for this project is also helpful.

TEACHER GUIDANCE: The spicy challenge will guide students to use a nested If statement. The If-else yields better simulation results for the tight corners. The closeout question asks why does the If-Else work better with corners than the IF. This is a question for all students regardless of whether they have attempted the spicy challenge or not.


Close-Out (5 minutes)

Close-Out (5 minutes)

Discuss the following questions:

    1. What is a Simulation?

    2. Why does the IF-ELSE work better on corners? Handout

Potential Responses

  • Simulations model real-world problems safely and efficiently. Simulations models a system, and uses environmental input to determine outcomes.
    The outcome is not predetermined. A simulation reproduces natural behavior in a controlled environment.


  • If-Else tests one condition per iteration. It allows incremental adjustments to be made each time in the loop, hence making corner detection better.

  • Using four If statements in one loop means that lots of things can update at once, sometimes these offset other changes. ( Less exact algorithm).