Creating a Scent Model
Objective: Students will learn about tracking items through computer modeling.
Materials: Each student will need
-
A computer with
AgentSheets
-
Three images saved on the desktop. (The students can create their own images as well.)
Images can be downloaded using the following links:
Making a Hound sit in the grass
-
Create new project and save it as "YournameCookie"
-
Define Agent Size: click ok
-
Gallery: click new agent, name it: background
-
Click on background and change the image: click file and import image: pick background.gif
then click done
-
Open up a new worksheet. Title the worksheet anything you want. It should be blank. Cover
the entire worksheet with background. Click on the background image and then go to the
worksheet and click on any part of it. You can do this for each block, but that is tedious.
It would be better to take the rectangle shape and cover the whole worksheet in one motion.
-
Place one hound in the bottom left-hand corner.
Ask prompting questions to start a discussion, such as:
-
What is going to happen? Why?
-
Let's press play and see what happens. Why did that happen?
-
What do we need to do?
Make a Hound run in the grass
Have the students determine what needs to happen to make the Hound run around in the grass. Ask
questions to start a discussion such as:
-
Now that we have two agents, we need to give them behaviors. What kind of behaviors does
grass have if it is a background? It is just there and the hound runs around in the grass.
-
What kinds of things affect what a dog does? Are any of those things in our model?
To have the Hound run randomly:
-
Double click on the hound in the gallery so his behavior window shows up. Then, click on the
action gallery and search for a basic motion called "move random on".
-
Drag that into the "then" section of the behavior. Right now it has an image of the hound,
but we want the hound to move randomly on the grass. Click on the hound image and it should
bring up the grass as well.
-
Now what should happen?
-
What did happen?
-
What do we want to do next in order to model our situation?
Adding in the cookies
-
Click new agent, name it: cookie
-
Click on cookie and import image: pick cookie.gif then click done.
-
Add 5 or 6 cookies onto our worksheet.
-
Double click on cookie: behavior window pops up.
-
Define what it is that we are doing in the first open box: Each cookie has 1000
cookie_scent.
-
Open up the actions gallery and scroll down until we find an action that would define our
cookie. It is what we call an "attribute". Use: Set value to value[left] + 1.
-
Change that to be similar to our problem: Set cookie_scent to 1000.
Ask the students what they think will happen:
-
Now what will happen when we press play?
-
Will the dog be attracted to the cookies?
-
What happened? Why?
Setting the Hound on the cookies
-
Look at the background and give it a new behavior.
-
What kind of behavior do you think we want it to have now?
-
Does the area around a cookie have a particular scent? How strong of a scent?
-
What if you were very far away from the cookie?
-
The grass is going to have the "attribute" of a cookie_scent. We want it to have this for a
description: The human_scent and cookie_scent of a square of grass is the average of the
scents of its neighboring squares(above, below, right, and left). This occurs while running.
-
Go down to attributes in the action gallery again and select the same attribute as the
cookie. Set cookie_scent to (cookie_scent[up] + cookie_scent[down] + cookie_scent[left] +
cookie_scent[right])/4. This gives the grass the attribute of the average of its surrounding
agents. If a blade of grass is near a cookie, the scent will be stronger.
-
Define this action while running: If there is very little cookie scent the hound will move
randomly on the grass. Otherwise the hound will use the method hunt_cookie to choose where
to go.
-
Start with random movement since we already have the "then" statement for it. Take the "is
value = 0" attribute and put it in the if section. Change the value to the average:
(cookie_scent[up] + cookie_scent[right] + cookie_scent[down] + cookie_scent[left]) / 4.
Change the equal sign to a less than sign and then the value should be 4.
-
Go up to basic and find the condition: once every 1.0 secs. Let's make it 0.4 secs just to
speed things up. These are the conditions for the hound to move randomly. Make sure that you
have the hound moving randomly on "background".
-
We want to make another rule while running for when it isn't random. For the if, let's put
once every 0.15 secs. And the Then needs to be Make hunt_cookie.
-
Add a new method to explain what the hound does while he is hunting the cookie. Change the
first box to say "If hound is directly next to a cookie, the hound will operate according to
devour_cookie. Otherwise the hound will move in the direction where the cookie_scent is
strongest."
-
If the hound is next to a cookie we want it to eat the cookie (devour_cookie). Find the
condition that says next to = 0. Change that to greater than/equal 1 for the IF statement.
The THEN statement should read "make devour_cookie".
-
The next IF statement should be if the hound isn't next to the cookie, how it should move.
If cookie_scent[left] is greater than/equal to cookie_scent[right], [up], [down],
respectively it moves left. Do this for right, up, and down.
-
Create a new method. Label it devour_cookie. Define it as: When the hound sees a cookie it
will erase(eat) the cookie.
-
IF statements should be see (the direction) (the agent). Click on the direction to change
it. Same with the agent. The THEN statement should be erase (that same direction).