Computational science club

The idea of a computational science club is to create a forum similar to existing forms of game design and computer clubs. At the Centennial Middle School students meet once a week to build, test and explore computational science models. How does a virus spread? How does a bridge hold up? When to avalanches get triggered?

Mike MacFerrin is organizing the computational science club.

= Predator-Prey Ecosystem = From animals to plants to bacteria, all layers of life follow some form of a predator-prey relationship. Some of the rules are simple (an animal eats when it's hungry) and some are more complex, such as how two animals might compete for the same prey. Since these relationships are hard to predict, scientists use simulations to study how predators and prey interact in their environments, and how changes to those environments affect them.

We will use AgentSheets to build and run your own simulations. We will then be able to study the relationships in our ecosystems and learn more about how these populations interact.

First, Choose Your Ecosystem
If you want to work with a partner, feel free. Or, build your own simulation.

Before you can build anything, what type of ecosystem do you want to build? Possibilities include:

 Microscopic (bacteria and viruses) Desert Mountains Beach Insects (spiders, flies and other creepie-crawlies) Underwater (fish, sharks) Airborn (birds, nests, falcons) Anything you can imagine! (doesn't have to be real.)</li> </ul>

What types of animals/plants will your ecosystem have? What eats what? This may seem boring, but having plan will help you build your simulation easier. It might be helpful to draw a simple predator/prey diagram called a Food Web. You should have at least 2-3 plants or animals in your web. The top predator eats the animals or plants below it. As you design your ecosystem, you will add species to your diagram to make it more complicated. For now, you only need 2 or 3 animals (and one plant) to build your ecosystem. Choose now, so you don't have to think about it while you build your system.

This will probably take you 5-10 minutes or more. Think carefully about how each of your animals will interact! For each animal, think about

Getting Started
Okay, let's get building!

1. Create a New Simulation
First, you need to create a New Project. If you don't know how to create a new AgentSheets Project, click on the NEW PROJECT link, and follow the directions there. Save the project in your personal network folder so you can get it later. Your "Agent Size" will determine how large your agents are. If you make them BIG (128x128), you will have large icons, but won't be able to fit very many on your screen. If you make them smaller (16x16 or 32x32), the icons will be smaller, but you can fit a lot more of them on your page. Choose wisely! After you create the project, click "File->Save" to save the project to your folder. <br style="clear:both" />

2. Create Your Environment Worksheet
Go to the File Drop-Down Menu and select New Worksheet. Resize the window to cover the rest of the screen not taken up by the Gallery window (by clicking and dragging the bottom right of the window). Once you have this, go to "File->Save" to save your Worksheet so that it will appear the next time you open your project. You'll need to give the worksheet a name.

You don't need a background image to run a simulation, but it does make it look nicer. A few images are listed below, or find one on the web to use in your environment. When you've found an image, click "File->Save As" in your browser, and save the image to your folder. Once you've done that, go to AgentSheets, click on your open worksheet and select "Load Background...". Select the image file you saved. You should now see your background in the Worksheet. Images from the Web: <ul> Desert</li> Under Water</li> Mountains</li> Outer Space</li> Beach</li> Rainforest</li> Spider Web</li> Find your own!</li> </ul>

3. Make a "Background" Agent
A window should appear in the top left; this is the Gallery Window. Click on the Gallery Drop-down Menu at the top of the screen and select New Agent. Name the agent “Background.” Right now, our background doesn't "do" anything (it will later), but it tells the agents where they can (and cannot) go. You don't need to draw any picture for the background Agent.

Fill your Worksheet with the Background Image. Once you have a "Background" Agent, click on it in the Gallery Window. Then click the "Box" icon on your worksheet. Trace a box around the area of your worksheet where you want all your animals to move. This allows your animals to run around on the background image.

4. Create Your First Agents
We will start with your simplest Agents. First, pick an agent that doesn't eat anything (could be a plant, or a small animal). This will be the "base" of your ecosystem. Create a New Agent and draw the picture for it in your Gallery. Then, do the same for your second Agent. Once you have a couple Agents, click on one of them in the gallery, then click on the Pencil icon on your Worksheet. Add a few of your agents to the ecosystem.

5. Make your Agents Move
Click on one of your Agents and then select "Gallery->Edit Behavior" to edit its behavior. You see a lot of "If-Then" statements. Find the block that says "While Running". Anything you put here will happen to this agent on every step of the simulation. We want the agent to move around the board to an empty "Background" spot. Since this should always happen, we don't need an "If" condition. Double-click on the "Then" box, and select "Move Random On", and choose a Background image (where it will move).



Later on you'll make your Agents move in smarter ways (chase each other), but for now they will move randomly.

"Save" your Gallery and Worksheet (click on each, then "File->Save"). Now click the green arrow on the toolbar to run it and see if it works. You should see your animals moving around the board randomly. If not, ask for help.

6. Make your Animals Multiply
Now that your animals are moving around the board, let's make them multiply. For now, we'll just have them multiply at random. We don't want them to multiply each step, but maybe just 1% of the time. In the "While Running" box of your Agent's Behavior, click "Add Rule". In the "If" side, add a "% Chance" box and set it to "1" (1%). In the right side, put a "New" box to create a new agent. Now, every time a spider moves, it has a 1% chance of making a copy of itself. Later on, we'll make the mating habits of our agents more complicated.

Now run your program again. Your agents should be multiplying.

7. Make your Animals Die
You've probably noticed that your animals never die... that's not a very balanced ecosystem! We don't want the agents to die immediately... that's not any better. To make agents roam around the board before dying, we're going to use a Variable called "hunger." We can store a value in that variable that stays with the animal wherever it walks. Every time they walk without eating, their hunger will increase. In the Agent Behavior, add a "Set" box just under the "Move Random" box you created before. Set the values to say "Set [hunger] to [hunger + 1]" Now, your animal gets hungrier every time it walks. To make your agent die, add another rule to the "While Running" box. Each time we walk, we'll check the value of "hunger." In the "If" statement, put a "Is hunger > 60" (or some other value). In the "Then" statement, make the Agent delete itself. This means that, if the agent starts with zero hunger, they will walk 60 steps before starving to death. Run your simulation again. You should see the behavior very differently now. You will probably notice that most your animals die of starvation after 60 steps.

= Other Behaviors (the Advanced Stuff) =

Making Agents Chase Each Other
Until now, all agents on your board move around at random, and bump into each other. You might want animals to actually chase each other. This might take awhile, but here's how it's done.

For this example, I will use a "Virus Attack" simulation we looked at before. If you want to play with this, you can open the Project (File->Open Project) under "Macintosh HD -> teaching materials -> science club -> Virus Attack". In this example, healthy people and sick people wander around a board. When healthy people bump sick people, they might also get sick. You can place "Doctors" on the board to walk around and "heal" the sick people (make them healthy again). Unfortunately, the doctors aren't very smart yet. If we want to make the doctors more effective, we can make them "chase" the sick people around. That way, we don't need as many doctors! Play around with the simulation to see how it works.