Calypso Module 4: Pursue and Consume

Learning Goal: this module introduces the Pursue and Consume idiom and the Second Law of Calypso. Using Pursue and Consume, you'll be able to make Cozmo extinguish all the red cubes.

The Pursue and Consume Idiom

"Pursue" means to chase something, e.g., "The police pursued the bankrobber". It can also mean to follow a path to a goal, as in "Mary is pursuing a degree in computer science".

"Consume" means to ingest. For example, the average American "consumes" 250 eggs per year. It can also mean to use up, as in "fire consumed the wood pile". When something is consumed it no longer exists -- at least not in its original form.

The Pursue and Consume idiom tells Cozmo to deal with a series of objects by visiting them one at a time and "consuming" them in some way. For example, suppose Cozmo sees some cubes that are glowing red, and the cubes are set to stop glowing when Cozmo picks them up. The program shown in the flash card below tells Cozmo to pursue each red cube and "consume" it by making it no longer pursuable. In this example Cozmo could do that by picking up the cube, which extinguishes the glow:


Which cube will Cozmo pursue first? (Hint: remember the First Law of Calypso.)

Trying out Pursue and Consume

This experiment can be done either with a real Cozmo or in simulator mode. But it's more fun to use Cozmo.

  1. Start Calypso if it's not already running.

  2. Set up Cozmo with three cubes visible to him, but spaced well apart.

  3. Load the Pursue1.calypso world by clicking on the link. Alternatively, you can download the program to your Documents/Calypso folder; then go to Calypso's Home menu (by pressing the Start button on the controller or the Home button on the keyboard) and select "Load".

  4. Program Cozmo with the Pursue and Consume idiom as shown on the flash card. You will find the "red" tile in the "colors" submenu.

  5. Run the program and see what happens.

Color Filters

Our pursue rule is only interested in red cubes. This is called a color filter. The rule will ignore cubes of other colors, even if they're closer than the closest red one. Try it and see:
  1. Put Cozmo on his charger so he won't move.

  2. Place the cubes in front of Cozmo so he can see them, and vary their distances.

  3. Run the Pursue1.calypso program. Cozmo won't move because he's on the charger, but you can look at the world map to see what he's thinking. You may have to tilt his head so that he can see the cubes.

  4. All three cubes start out red, and by the First Law, the pursue rule picks the closest one. You should see the LOS indicator pointing from Cozmo to the closest red cube. If he weren't on his charger he would be moving toward that cube.

  5. Now right-click on that cube in the world map and change its color to something else, such as blue.

  6. Cozmo should now ignore the cube since it's no longer red. He will refocus his attention on what is now the closest red cube.

  7. Repeat this step, recoloring each cube and observing the results.

  8. What happens if you make a non-red cube be red again?

  9. What happens with the pursue rule when there are no red cubes left (before the "Winner" celebration)?

What Makes An Action "Consuming"?

A consume action is anything that makes an object no longer pursuable. If Cozmo could actually eat a cube, or blow it up, or turn it invisible, then he would no longer see it, so he could not keep pursuing it. The pursue rule would then move on to the next closest cube.

Since Cozmo can't eat or blow up cubes, the next best thing is to change the cube's color so that the pursue rule no longer pays attention to it. In the Pursue1 world he does this by grabbing the cube. The cubes in Pursue1 are programmed to stop glowing when they are picked up. We could also make Cozmo change the cube's color directly, but grabbing cubes is more fun.

Challenge: Can you figure out how make Cozmo change the cube's color directly? (Changing it for him by clicking in the world map doesn't count.)

What Does "Bumped" Mean for Cozmo?

The consume rule begins "WHEN bumped cube". For Cozmo, "bumped" means "got really close to"; he doesn't have to actually bump into the thing. Run the Pursue1 world and you will see that the consume rule is dimmed while Cozmo is approaching a cube; it only lights up when he's right on top of it, meaning he is "bumping" it.

Cozmo can only grab a cube if he is close to it. If he tries to grab a cube that is too far away, the action fails and the DO part of the rule is dimmed. If Cozmo is bumping a cube, we know that he is close enough to grab it.

Optional challenge task: What do you think will happen if we replace the Pursue and Consume rules with this one "impatient" rule?

An Impatient Rule (Doesn't Work):

  1. Replace the two Pursue and Consume rules with the impatient rule above. You can erase rules by putting the pencil on the WHEN tile and pressing the left trigger or hitting the Delete key (function-Delete on a Mac).

  2. Take Cozmo off his charger and position the cubes so he can see them.

  3. Run the program. Where is the LOS indicator pointing?

  4. Is Cozmo moving toward a cube? Explain what's going on.

  5. Is Cozmo grabbing any cubes?

  6. Is the rule dimmed or bright? Why?

  7. Could you grab something if it was out of your reach and you weren't told to go get it?

  8. With the program still running, slide a cube toward Cozmo until it's almost touching him. You may have to gently tilt his head down so he can still see it. What happens when the cube gets really close to him?

Swapping the Rule Order

Let's switch to simulator mode, reload the Pursue1 world, and put the regular Pursue and Consume idiom back. When you run this program, Cozmo goes to the nearest red cube and picks it up (extinguishing it), then goes to the next nearest red cube, and so on. The pursue rule can always run, until there are no red cubes left. The consume rule is dimmed most of the time. When can this rule run? (Answer: it can only run when Cozmo is bumping a red cube.)

If we swap the order of the two rules, we get this program:



What do you think this program will do? Let's try it:

  1. To move a rule in the editor:

    • Put the pencil on the "WHEN" tile, then press the green "A" button to pick up the rule (it will be highlighted in yellow). Now you can use the left stick to move the rule up or down.

    • Caution: do not move the rule to the right (indent it): that would change its meaning.

    • If you're using a mouse, you can drag the rule to its new position by clicking and dragging on the WHEN tile.

  2. Press the Back button (or the Backspace key on the keyboard) to run the program.

  3. Which rule can run (shown by highlighting)? Which rule cannot run (shown by dimming)?

  4. Does this Consume-and-Pursue program behave any differently than the original Pursue-and-Consume version? (The answer should be "no".)

The Second Law of Calypso

The Consume-and-Pursue program behaves the same as the original Pursue-and-Consume version because of the Second Law of Calypso, which says that any rule that can run, will run:


A rule "can run" if its WHEN part is true. It doesn't matter what rules come before it or after it. When we say a rule "will run", we mean the action in its DO part will be attempted. The action could fail, as with the impatient rule that tried to grab a cube that was too far away. But the rule still ran.

In the graphic above we see two versions of the same program: Consume-and-Pursue at the top, and Pursue-and-Consume on the bottom. Cozmo can see the red cube, so he can move toward it, but it's still pretty far away, so he is not bumping it. Thus, in both versions of the program the pursue rule is highlighted and the consume rule is dimmed. The two versions behave the same way.

Does this mean rule order never matters? Not quite. There are situations where rule order does matter, which we'll get to in a later module. But for cases like Pursue and Consume, where the two rules have entirely different actions, the order is not important.

Review and Discovery

Do the Module 4 Review and Discovery activity to review what you've learned.

Next Module

In the next module you'll learn how to make Cozmo talk, play sounds, and express emotions.


Back to Calypso Curriculum overview.


Copyright © 2017 Visionary Machines LLC.