Flash Player
This site makes use of the Macromedia Flash plugin to display videos.
Click here
to download the Macromedia Flash player.
Video Tutorials

Wherever you see the
eye icon
on this site,
it is a link to a video tutorial.
|
|
When you install Starlogo TNG, you will
see that there are a number of example projects that are also installed.
You can open them from the shortcut on the start menu. Look in the
Simulations folder and open fish and plankton.sltng
This is a model of an ecosystem. The fish move around, eat
plankton, reproduce and die. The plankton move around slowly and
reproduce.
Explanation of the Code Blocks
 |
Start by looking at the Runtime area in the Blocks
window.
The Forever block will create a 'Forever' button in the
SpaceLand window, which you can click to make the simulation
run.
You can see the Procedures (Green blocks) that
tell the fish and plankton what to do. Procedures are
just blocks of code with a name .
So the Fish move left or right, go up and down, reproduce
and die
The plankton move left or right slowly, go up and down
(in the same way as the fish do), and multiply. |
 |
Next look at the Setup area of the Blocks window.
The Setup Block creates a button in SpaceLand that will do
whatever is in the blocks it contains. Clear Everyone -
removes all objects from SpaceLand
Create Fish
- Creates 50 fish, with random altitudes (height above
SpaceLand) up to 30.
- Sets their size to be 4
- Sets their energy, which will be a random number up
to 5.
Create Plankton
- Creates 300 plankton
- Sets their altitude randomly
- Sets a size for them (1)
- Makes them green
Scatter Everyone spreads fish and plankton all around
SpaceLand.
|
Now move to the Fish Area in the Blocks window.
 |
is just the name of a 'variable' that holds the value of a
fish's energy at any one time. It is an 'agent variable'
(blue) meaning that it has a separate value for each different
fish. |
 |
This is the procedure that tells the fish how to move.
They move left a random number of degrees up to 10, then right a
random number of degrees up to 10. This has the total
effect of turning them in a random direction up to 10 degrees
left or right.
Then they move forward 1 step.
Moving takes energy, so the energy variable is incremented
(increased) by -.05 (Increasing it by a
negative amount is the same as decreasing it). |
 |
This is the procedure that makes the fish move up and down
randomly, but keeps them from going too high (over 30) or below
the ground level.
Random 3 will produce numbers 1, 2 or 3. So random 3
- 2 will produce -1, 0, or 1 for final values.
So the fish will randomly move down 1, stay the same, or move up
1.
If altitude goes below 1, then it gets set back to be 1 (so
the fish can't go below the ground)
If altitude goes above 30, it gets set back to 30 (so the
fish can't go up out of the water)
|
 |
If Fish energy goes below 0, then they die (disappear). |
 |
If Fish and Plankton collide, then the Fish eats the
plankton. The fish energy goes up .5 and the plankton die
(disappear) |
 |
If Fish have energy above 5, they will reproduce. When
they reproduce, their energy goes down by 2.
Hatch produces a baby. The baby is given a random
heading (so it will move off in a random direction). It
will move forward a random number of steps up to 3, and its
energy will start out with a value of 2. |
Next we will look at the procedures for the Plankton.
 |
Plankton move in a similar way to the fish, but only go
forward .1 of a step each time, so they are moving very slowly. |
 |
This is the procedure to make the plankton multiply. Test
random 50 = 1, produces a random number between 1 and 50 and
tests to see if it equals 1. It will equal one roughly
once in 50 times.
If the random number was equal to 1, then it tests to see if
there are less than 500 plankton left. If so then
reproduction will happen.
The total result of all this is that about one in 50 of the
plankton will reproduce each step of the game, as long as total
plankton numbers are below 500. |
Add in Monitoring to Track the Number of Fish and Plankton
 |
In the Runtime area, add in a Monitor block (Setup and Run
library), name it Plankton. Attach the Count Plankton
block from My Blocks.
Now do the same for the count of
fish. 
Switch to SpaceLand and watch the
numbers change as it runs.
Add in a Line Graph as well.

|
 |
Things for you to try:
| |
1. Try putting in different starting numbers of fish or plankton to
see the effects.
- What do you think might happen if you started off with no
plankton?
- What do you think might happen if you started off with no fish?
2. Can you find a starting number of fish and plankton that make the
ecology stable? ie neither fish nor plankton ever die out completely.
3. Explore the effects of changing how frequently the fish or
plankton breed
4. What happens with the colours of fish over time? Why do you
think this might be? |
|
|
|