BIOL 362 Simulating Life Midterm

Sally Wong
1) Describe what the code in your section is supposed to do. What are the agents? What do the agents do?
What do the agents sense? How do the agents respond? This should describe their behavior - not how the
code makes this happen.
The code that I created for my simulation is supposed to mimic the spread of the Zika virus over
short period of time from mosquitoes to humans, humans to humans, and humans to mosquitoes. My
agents are humans and mosquitoes. The humans roam around the green terrain which represents land. The
mosquitoes roam around the pond, which is the blue terrain, and a little bit of the dark green land
surrounding the pond, but they can also roam around on land (green terrain), but they will move back to
the pond to their home because they like to lay their eggs around wet/moist areas. Since the lifespan of
female mosquitoes are around 45 days for females and the lifespan of male mosquitoes are about 10 days,
I implemented the reproduction for mosquitoes in my simulation. The mosquitoes move back to the pond
after a period of time and then stop in the pond for a period of time to lay down their eggs. The mosquito
dies after it reproduces. Since female mosquitoes lay eggs often (about every three days), a lot of
mosquitoes will be born, in which the population of new mosquitoes will be tracked in a graph. If the
humans hit the pond (blue terrain), they will turn around and move back to the land (green terrain). The
mosquitoes are either white or black. White mosquitoes are mosquitoes with the Zika virus and black
mosquitoes are healthy mosquitoes. White mosquitoes roam randomly and if they collide with a human,
then the Zika virus will be transferred to the human by the mosquito’s bite. Humans are either red or
yellow. Red humans are those infected with the Zika virus, either by a mosquito bite or a human
interaction, such as through sex, blood transfusion, or healthcare setting exposure. There haven’t been any
cases where the Zika virus was spread through a healthcare setting and the virus itself only stays in the
human body for about a week, so the spread of the Zika virus from human to human is not as likely as the
spread of the virus from a mosquito to a human. Because my simulation only represents a short section of
time and because the time of the simulation would not really correlate with human reproduction, I did not
include reproduction of humans. In reality, the Zika virus causes the most problems when it is transferred
from an infected mother to child through birth, but it is not shown in the simulation. The Zika virus is
known to cause a birth defect called microcephaly and other severe fatal brain defects in the fetus. There
is no cure for the Zika virus, and most symptoms of the virus are not displayed or developed.
2) Describe how your code implements the behavior you described in (1). Be sure to include screenshots
of the code with enough context so that I can understand how it works. Describe all traits and what they
represent.
Behavior of Humans (Under Human Tab):
In this part of the code under my human breed,
the movement of the humans are defined. The humans
do not move in a straight line or in circles, but they
move in random directions, which is shown in the
codes “left by random 10 degrees” and “right by
random 15 degrees.” The “random 10 degrees” and the
“random 15 degrees” allows the human to randomly
move between 0 to 9 degrees or randomly move
between 0 to 14 degrees. This allows all humans to
move differently from one another. The humans move
only “forward 1” because I do not want them to move
at a too fast of a pace or too slow of pace. The first “if
then” statement makes the humans refrain from
moving into the water. Once a human hits the
pond/water or the blue terrain, it will turn around and move in the opposite direction; thus the code “set
my heading to my heading – 180.” This will allow the human to move in the opposite direction when they
hit a different terrain. I set their movement to “forward 2” after they hit the blue terrain because I wanted
to really be able to see that the humans have moved away from the pond. The second “if then” statement
is placed in the code in case the first “if then” statement is ignored. If the humans ever go into the
pond/blue terrain for any reason, it will be deleted because humans would drown in the pond if this was
reality.
This part of the code for the
humans under the “while forever
toggled” represents the Zika virus
eventually leaving the human body.
The Zika virus only stays in the
human body for about a week, and in
most people, symptoms never actually
develop in the human. It has been said
that once a human gets infected from
the Zika virus, they won’t get infected
by the virus again so I made the
humans change into a blue color to represent that they are immune to the virus. Since they are immune to
the virus, they will not be affected after collisions with the infected humans and/or the infected
mosquitoes. In this code, the red color of the humans represents a person infected with the Zika virus. The
humans are born with a sick time of 0, which means that they are not infected. However, when the
humans become infected due to a collision with either an infected mosquito or an infected human, they
change into the color red. When they become infected, I created a trait for the humans that set a sick time
for each infected human. Since I set each tick to represent 6 hours, 28 ticks will represent 7 days so after
28 ticks or more on the clock, the human will no longer be infected and will become immune to the Zika
virus, causing them to change into the blue color.
When an uninfected yellow human collides with an infected red human, there is a 1/100 chance
that the uninfected yellow human will become infected, thus changing their color to red. There is a 1/100
chance that the uninfected yellow human will become infected with the Zika virus upon a collision with
an infected human because human-to-human contact doesn’t necessarily cause the disease to spread. The
disease can be spread from a mother to child (which is not represented in my simulation due to the
difficulty of making reproduction seem realistic in the simulation), through sex, through blood
transfusion, and through laboratory and healthcare setting exposures. Because there have been no cases
were the Zika virus has been spread through blood transfusion and because not every person a person
encounters will have sex, there is only a random probability that the Zika virus will be transmitted from a
human to another human. When an immune blue human collides with an infected red human, the immune
blue human will stay immune because it can no longer become infected with the Zika virus since the
human body has created antibodies to fight off the virus now.
When an uninfected yellow human collides with an infected white mosquito, the human will
become infected with the virus and become red. Since infected mosquitoes can transmit the Zika virus
through bites, the humans are very susceptible to the virus through this type of contact. When a blue
immune human collides with an infected white mosquito, the immune blue human will still be blue and
immune as they can no longer be infected with the virus through mosquito contact, as well as human
contact.
Behavior of Mosquitoes (Under Mosquito Tab):
Because the lifespan of a mosquito is
less than two months, I included the
mosquitoes’ ages and their reproduction in
my simulation. Each mosquito’s age is set
by a trait that I created within the mosquito
breed and follows along with the tick of the
clock, which is shown in the code “set my
mosquito’s age to my mosquito’s age +1.”
Because mosquitoes like to stay around wet
and moist areas, they usually like to stay
near the pond and only those that need
protein from human blood to reproduce
will migrate into the land with the humans.
Therefore, when the mosquitoes fly in the
green terrain color (land), they will have a
1/8 chance that the mosquitoes would
move away from the land, which would
make the mosquitoes less likely to go into
the green terrain. This would allow the
mosquitoes to live longer because there is a 1/80 chance that the mosquitoes will die when they are in the
land since they like to stay in their usual wet and moist habitat.
Mosquitoes like to reproduce near water since water is necessary
for the eggs to hatch into larvae. In order to add water into my
simulation, I created three different ponds in the world in which the
mosquitoes are born in and live around. To allow the mosquitoes to
reproduce in the water, I created a “stopped” trait under the
mosquito breed, which allows the mosquito to lay their eggs in the
water. When “stopped” = 0, that means that the mosquito is freeroaming in a random pathway, which is coded by “forward 1, left
by random 10 degrees, and right by random 11 degrees.” For
example, The “random 10 degrees” allows the mosquitoes to move
anywhere from 0 to 9 degrees, causing the pathway between each
mosquito to be slightly different. When “stopped” = 1, that means
that the mosquitoes have become stationary and that there is a 1/40
chance that they can become free-roaming (“stopped = 0”) in the
simulation again. Because the mosquitoes like to stay in the water
for about 10 days after they are born, I created a 1/40 chance that
they will move from their stationary position to a roaming position.
The mosquitoes will only stop when
they are in the ponds (“blue terrain”) and they
will never stop moving while they are on the
land (“green terrain”). Because the mosquitoes
stop once they are on the pond, there is a 1/50
chance that the mosquitoes will become
stationary when they are located in the pond.
When the uninfected black mosquitoes
and the infected white mosquitoes are stationary
on the pond, there is a 1/15 chance that either
mosquitoes will reproduce since the mosquitoes
do not always reproduce once they are stopped
on a pond. Four mosquitoes will reproduce in the
location of the pond where the parent mosquito is
located and the newborn mosquitoes will have
their “stopped = 0,” allowing the newborn
mosquitoes to freely roam. After the parent
mosquito reproduces, it dies.
Mosquitoes have a lifespan of about 2 months.
When the mosquito’s age is greater than 120 ticks (120
ticks = 30 days), they have 1/50 chance of dying since not
every mosquito lives to about 2 months.
When an uninfected black mosquito collides with an infected red human, since the mosquito will
bite the human, it will become infected and turn into a white infected mosquito.
3) How do you know that your code “works”? Give two examples of how you tested it, what should have
happened if the code was working, and what actually happened. These tests must involve changes to the
simulation. In your case, these could involve changing the starting numbers of organisms or their life
spans, their behavior when infected, the chance of spreading the disease, etc. and observing the
effects of these on the numbers of infected organisms. You could also remove some key element of
the simulation, then predict and observe the results. Be sure to include graphs if appropriate.
One example to test if my code “works” is to increase the amount of starting infected white
mosquitoes in my simulation. Increasing the amount of starting infected white mosquitoes will
increase the amount of infected mosquitoes, as well as the amount of infected humans since there
will be more chance of a contact between an infected mosquito and an uninfected human and/or the
births of more infected mosquitoes.
These two graphs display the number of infected mosquitoes (red) and infected humans (red)
with my normal code without any changes (starts with 7 infected mosquitoes in each of the three
ponds).
These two graphs display the number of infected mosquitoes (red) and infected humans (red)
with the starting population of the infected mosquitoes changed to 25 in each of the three ponds. The
number of infected mosquitoes increase greatly, so much that the population of the infected
mosquitoes exceeded the population of the healthy mosquitoes (orange). The number of infected
humans also increased after the increase of starting infected mosquitoes. For example, when time
equals 60, in the first graph, there are about 15 infected humans. In the second graph, after I changed
the code, there are about 35 infected humans when time equals 60. This proves that my code “work”
in which increasing the starting number of infected mosquitoes resulted in an increase in both the
infected mosquito population and the infected human population.
Another example to test if my code “works” is to change the lifespan of the mosquitoes. In
my original code, the mosquitoes have a 1/50 chance of dying when they are the age of 30 days or
greater (120 ticks or more). I will remove the 1/50 chance of dying and make the life span of the
mosquitoes to be 120 days only. This will decrease the populations of both infected and healthy
mosquitoes.
This graph displays the populations of both
the infected (red) and healthy (orange)
mosquitoes with my original coding. When the
mosquitoes are greater than the age of 30
(greater than 120 ticks), they have a 1/50 chance
of dying.
This graph displays the populations of
both the infected (red) and healthy (orange)
mosquitoes when I changed the lifespan of the
mosquitoes to only live for 30 days (120 ticks).
As predicted, the populations of infected and
healthy mosquitoes significantly decreasing.
When time equals 120, both populations of
mosquitoes decreased. This proves that my code
works, in which the probability (1/50) of the
mosquitoes dying works since the populations
of the healthy and infected mosquitoes in the
graph above do not reach 0 at any point,
showing that only some mosquitoes die at the
age of 30 days.
4) Give one example of a hypothesis you can test with your simulation and how you’d test it.
An example of a hypothesis that I would like to test with my simulation is how the
probability of infection from human to human affects the number of people infected with the Zika
virus. The Zika virus can be fully transmitted from mosquito to human through bites, but the Zika
virus does not always transmit the virus from a human-to-human interaction. To test this, I will
change the probability of infection 10 times and measure the number of infected humans when time
equals 60. When the probability of infection is smaller, there should be a decrease in the number of
infected humans, and when the probability of infection is larger, there should be an increase in the
number of infected humans.
Number of Infected Humans with Zika Virus When Time Equals 70
Number of Infected Humans with Zika Virus
45
40
35
30
25
20
15
10
5
0
0
0.2
0.4
0.6
0.8
1
1.2
Probability of Infection from Human-to-Human Contact
Probability
0.01
0.011111111
0.0125
0.014285714
0.016666667
0.02
0.025
0.033333333
0.05
0.1
1/8
1/6
1/4
1/3
1/2
1
Number of Infected Humans with Zika Virus
20
20
22
16
21
15
22
22
30
32
35
15
30
27
25
40
The scatter plot above displays the number
of infected humans with the Zika virus when
time equals 70 with different probabilities of
human-to-human contact. As the probability
increased, the number of infected humans
with the Zika virus also increased, but with a
few outliers. I changed the probability of
infection from human-to-human for each
time I measured the infected humans when
time equals 70. The probabilities that I tested
included 1, ½. 1/3, ¼, 1/6, 1/8, 1/10, 1/20,
1/30, 1/40, 1/50, 1/60, 1/70, 1/80, 1/90, and
1/100 (which was my original probability in
my simulation). The number of infected
humans slowly increased as the probability
increased from 1/100 to 1.