Programming Assignment

advertisement

CS108L Computer Science for All

Lab 13: Eating Nemo:

A More Advanced Ecosystems Model

In this lab, you will be creating a more advanced model that represents a fish ecosystem. You have fish swimming around eating plankton and having fun! The fish die if they can’t find enough plankton and have fishlettes if they can eat enough plankton. The fish are eaten by sharks that also want to thrive! The sharks eat fish to gain energy, have sharklettes if they have enough fish to eat and die when they have no energy! You can use the model you developed in week 7 as the start of the model for this week or you can start over!

Документ1

The Ecosystem Model:

The model has the following requirements:

 Change your world o On the interface tab, choose settings and change the max-pxcor, and max-pycor (suggestion: 100). Also change the size of your patches

(suggestion: 3). o The world wraps around! Your agents live on a doughnut! o Change the color of your world to a blue because Nemo lives in the ocean!

Here are the color numbers for blues!

 There are Fish and Sharks in your world! o Create two breeds of agents (fishes/fish and sharks/shark or something like that). Make sure they are both fish shaped. o Add two sliders that allow you to change the initial number of fish and sharks. o Fish are big, but NOT too big (size 3 or less) and they are all the same color. o Sharks are bigger than fish but not too big either (size 5 or less) and they are all one color that is different from the fish! o Each fish and each shark has its own variable to monitor its energy and the initial energy is not zero.

 There is plankton in your world. Plankton makes the patches green! Not all the patches are green though – most are blue!

 Fish and shark do their own thing….

Документ1

o For each tick, the fish and sharks move in a wiggle and lose a bit of energy. Remember that the energy variable for each agent needs to be set when a fish or shark wiggles. o Fish eat plankton when they get to a green patch and then the patch becomes blue. Also, when a fish eats plankton, it gains energy so its energy value increases. o Sharks eat fish when they share a patch (remember the epidemic model!) and the fish dies. The shark gains energy when it eats a fish! o Fish and shark die if their energy falls to zero or below. o Each fish and shark can reproduce if they have enough energy to do so.

Again, how much energy the agent needs to reproduce is up to you to decide but the model needs to behave as required (see Stable or

Oscillating Population in the grading rubric). o When a fish or shark reproduces, they lose energy. Sharks need to have more energy before they can reproduce and loose more energy when they reproduce. o Also, remember that the fishlettes and sharklettes have an energy variable that needs to be set when a fish is hatched. o How much energy the fish and sharks gains and loses for each activity

(moving, eating, and reproducing) is up to you. However, too much or too little makes a difference! There is not one right answer; it’s all about

BALANCE! You will need to decide what those values are so that the model behaves in the required manner (see Stable or Oscillating

Population in the grading rubric). You might want to put sliders in to control the energy lost or gained for each agent and activity so you can easily adjust them. o Then you have to model at least one of two things: o The fish and sharks grow as they age. Remember you have to keep track of their age as an agent variable in order to do this! Also, the fish and sharks cannot get too big – there is a maximum size for each – perhaps no bigger than twice its original size. Sharks can get bigger than fish!

Документ1

o The fish and sharks swim faster as the get more energy.

Swimming faster means moving forward more that one step! One way to do this is to have the distance the turtle will try to move is equal to a fraction of its current energy (for example, if a fish has an energy of 24, then it could move forward 24/10 or 2.4 patches).

Remember the faster they swim the more energy they loose. So both the speed of the agent and the amount of energy lost would depend on the energy of the agent.

 Plankton happens! Each blue, empty water patch randomly grows plankton (and changes the patch color to green) with a probability of 1 in 1000 each tick.

Note: To keep the model simple we use abstraction to simplify this so we are modeling the presence of significant concentrations of plankton in the water as a simple green patch. In the real world, plankton are very small and as the density of plankton increases or decreases within a patch of water, the water would gradually change color. In the model, when an empty (blue) patch spontaneously generates plankton, you can think of this as a small population of plankton having the right conditions to increase their population density and that this increased density is represented in the model by changing the patch color to green.

 You are also very anxious about your fish, shark and plankton. You create a graph that tracks how many of each is alive in the model as a function of time.

Hint: Don’t forget about ticks!

That’s it for the basic model! Have Fun Modeling!

Lab 13: Eating Nemo Grading Rubric (20 Points Total)

Done Points Task

1

3

2

A: Do the following:

 Submit your NetLogo source code with a file name as shown below:

W13.

firstname .

lastname .nlogo to your instructor.

 The first few lines of your code are comments including your name, the date, your school, and the assignment name.

B: The code in the Code tab of your program is appropriately documented with “in-line comments”.

C: Your program includes a description of what your program does in the

Документ1

2

2

6

Info tab. Please describe the overall program, each procedure and anything else you want someone to know about your program.

D: Correct Setup:

 Your program is set up with the required world settings (many more than the default 33  33 patch world).

 The patches on you world are blue except where there are green plankton.

 You start with some plankton (around 1 in 100 patches are green)

 You have a slider that inputs the initial number of fish and shark in the model.

 You created a fish and a shark breed and they have a fish shape.

 The fish are all of the same color and the sharks are all a different color.

 Two sliders are used to specify how many fish and sharks are created with your setup procedure.

 Each fish is set to a size larger than size 1 but no greater than size 3 and has an energy variable that has an initial value that is greater than zero.

 Each shark is set to a size larger than the fish but no greater than size 5 and has an energy variable that has an initial value that is greater than zero.

E: Your fish, sharks and plankton behave correctly:

 The fish and sharks loose energy when they move.

 The fish eat plankton and gain energy when the get to a green patch, turning the patch blue.

 The sharks eat fish when they share a patch. The sharks gain energy and the fish die.

 Fish and sharks die if they do not have enough energy and reproduce if the have enough energy.

 The plankton disappears (patches turn blue) when they are eaten and the plankton reproduces once in a while (patches turn green).

 You have a graph that shows the number of fish and the plankton as the model progresses.

F: Stable or Oscillating Population: When your model is run, neither the fish, the sharks nor the plankton die out completely right away. Rather, the populations of each either oscillate or stabilize. In order to accomplish this, you may need to adjust the amount of energy lost or gained for moving, birthing, eating and at birth. It might be convenient to put in sliders for these variables. There should be fish and plankton

Документ1

after 5,000 ticks. Please make sure to make down the values used to run the model in the Info section of the NetLogo program. Remember you can change the speed at which the program runs so you can speed things up a bit!

To get 20 points for the lab you only need to do one of the following two activities – if you do both you get extra credit for the second activity!

4 G: The fish and sharks grow as they age until they reach the maximum size for that type of agent! Sharks can grow bigger than fish. You get to decide on the maximum size but you they cannot grow too big or you wont be able to see your world after a while!

4

[Hint: the energy gained by eating needs to be more than the energy lost by wiggling – see the image at the beginning of the lab!]

3

10

H: The fish and sharks swim faster as the get more energy. The faster they swim the more energy they loose. So both the speed of the agent and the amount of energy lost depends on the energy of the agent.

I: (Extra Credit) Your program has separate procedures for fish and sharks eating, moving, reproducing and dying. You call each of these procedures in your “go” procedure.

J: (Extra Credit) Make you model even more realistic - add a second breed of fish. The new breed must have a different color. It must move, eat, reproduce and die as the original breed; however, the new breed must have a different initial energy value, and gain or loose energy differently than the first type of fish. The new breed also moves differently than the first breed (turns left and right in the wiggle walk by a different maximum angle). For example, the new breed might move faster but lose more energy from moving. Also, the new breed might need less energy to reproduce, but the baby fish start their life with less energy than the baby fish of the first breed. As part of creating a new breed, modify the chart to plot four lines: one for the population of each fish breed and one for the population of the plankton. To gain these extra credit points, you must choose energy gains and loses so that the populations of all breeds remain stable or oscillating (none of the breeds die out) for at least 5000 ticks.

Документ1

Download