Lesson 3 Activity 2 - Bumper Turtles

In this activity, students will learn a few simple commands and then convert their Painting Turtles program into a Bumper Turtles program in which agents respond to their environment.
  • Watch a video on the Bumper Turtles Challenge
  • Read the description of the Bumper Turtles project
  • Learn new CS Concepts (conditionals, expressions)
  • Create your own version of the Bumper Turtles project

Video on the Bumper Turtles Challenge:




Bumper Turtles Challenge
:
Start with the StarLogo Nova model Bumper Turtles starter
This starter model already has a push button called “Paint Landmarks” and some code associated with it. Click on the “Paint Landmarks” push button and see the program execute the code provided.

Note: DO NOT make changes to the “Paint Landmarks” procedure.

Your challenge is to make the turtles react to the landmarks created by the “Paint Landmarks” procedure, following the same rules laid out in the Trailblazer activity.

The rules for turtle movement are:

  • Take one step forward
  • If a turtle is on a RED square, then turn right by 90 degrees
  • If a turtle is on a BLUE square, then turn left by 90 degrees
  • If a turtle is on a BLACK square, then turn right by 180 degrees

Guidelines:

  1. Remix the “Bumper Turtles starter” model
  2. Create 4 turtles 
  3. Have the turtles move forward then check the terrain color they are standing on
  4. Instruct your turtles to react to the landmarks according to the rules in the Trailblazer activity
  5. Test your project to see that it works as expected.

To complete this Challenge, you will need to use some new command blocks in addition to the blocks you used in Lesson 1 and 2.  Watch the video explanations of these blocks. (For more information, refer to the StarLogo Nova Blocks Guide.)

 


New Concepts: conditional branching and booleans



BRANCHING WITH CONDITIONALS
In addition to simple stacks of commands as we did in drawing a flower and painting turtles projects, we can instruct a computer to execute different stacks of commands depending on the circumstance or condition.  For example, we might want to write different behaviors for a coyote agent based on a condition.  If it runs into a rabbit then chase the rabbit BUT if it runs into a mountain lion, run away from the mountain lion. To do this, we use a statement called a CONDITIONAL statement.  It looks like this
      IF (something is true) THEN (do this)

So using our example, our conditional statements would look like this:
    IF (Rabbit nearby) THEN (Chase the Rabbit)
    IF (Mountain Lion nearby) THEN (Run away from Mountain Lion)

The (something is true) part is called a BOOLEAN expression or an expression that evaluates to TRUE or FALSE.
    (Rabbit nearby) could evaluate to TRUE or FALSE
    (Mountain Lion nearby) could evaluate to TRUE or FALSE.

CONDITIONAL STATEMENTS and BOOLEAN expressions work together.  The THEN part of the CONDITIONAL STATEMENT only gets executed if their BOOLEAN expression evaluates to TRUE.

Another type of CONDITIONAL STATEMENT is the IF/THEN/ELSE STATEMENT.  With this kind of statement the THEN part gets executed if the BOOLEAN expression evaluates to TRUE.  The ELSE part gets executed if the BOOLEAN expression evaluates to FALSE. Think about when this might come in handy….  What if you were the coyote and had a rabbit and a mountain lion in front of you at the same time.  How would you use the IF/THEN/ELSE command to make sure you take the right action?


Upload your project:
Post a screen shot of your project and a link to it in your portfolio in the section "SLNova Projects->SL Nova - Intro" under the heading "Bumper Turtles."

Reflections:
Reflect on using Boolean expressions and Conditional statements. Post your reflection to your portfolio in "Reflections->CS Concepts" under the heading "Boolean expressions" and "Conditional statements."