Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Questions on HW8-Spring07

Question:How do you do probability? Like if there is 25% chance that some sick will die and .05% that there will be a typhoid mary, how would we do that?

Question: When a person dies, how do we make them stop wandering aimlessly? We are assuming that they need to be kept on the list so that they are able to continue infecting the other people.

Question: on the implementation of the public Health policies. Do they need to be implemented separately? meaning you to one policy and then start over and do the second one ... or do you do one policy (changing the classes) and then do the second one by making additional changes to those classes you just changed?

Question: Okay we're confused by what the homework description is saying, Are we suppose to modify PersonAgent or do we just create all new subclasses for Agent? How exactly do you override Agent?

We know some of this was discussed in lecture but we didn't entirely comprehend what we were suppose to create versus what was given to us.

Question: Any hints on how to actually set up time?

Question: This is from the homework: "People, once infected (come within 10 steps of an infected person), don't turn red for two days – though they do spread the disease." So, if I became sick on Monday (as in woke up and was sick) do I turn red when I wake up on Tuesday? (aka the next time step) Or do I wake up red on Wednesday? Is Monday counted as one of those 2 days? Just trying to clarify.

Question: Our HWPersonAgent extends Agent, which extends Turtle, which extends SimpleTurtle. SimpleTurtle has a method called .getBodyColor() and none of the subclasses overwrite this method. However, when we try and call .getBodyColor() on a instance of HWPersonAgent, we get the following error:
File: C:\cs1316\java-source-Fall06\  [line: 184]  
Error: cannot find symbol  
symbol  : variable getBodyColor
location: class HWPersonAgent
Why is that? And how can we check if someone is red so that we can run away from them? Thanks!

Question: We created a variable called lengthOfInfection=0; that was initialized. We were wondering how we could increase it as the amount of days increases. For instance on day 12, a person gets infected so lengthOfInfection=0; but on day 13, this value should increase to 1. How do we make it do that?


Please run your simulation for 100 time steps, not just 50. From the runs that I'm seeing, 50 time steps is too early in the simulation, and there seems to be a critical mass a little after 50. You are welcome to change Simulation run() that lets you run for 100.

BTW, please count the number of LIVE infected, not dead infected, in your "infected" count. Mark Guzdial

Question: We understand how to create a typhoid mary carrier but how does it stay one? We first created a for loop to count time and increment it. We then created the if statements for the various parameters. For the one in question we said for days between 1 and 6 a person is infected. Within that we created an if statement for the probability of typhoid mary with
if(randNumGen.nextFloat() > PROB_OF_TM)
So how do we ensure that after you either become a typhoid mary carrier or don't that a person stays that way. We feel that at this time the code would cause a person to find a new Random Number everytime and thus possibly change what they were.

Question: When I run my disease simulation everything seems to work, except how it prints out how the number infected. I end up getting a number over 100, which obviously doesn't make sense. Also, for some of the timesteps, 'number infected' shows up multiple times.

Question: I cannot seem to figure out how to say on day 2 turn red day 5 die. etc. i have put the code that i have tried to use below and i think my problem is that it goes through the entire for loop in one time step. how can i get int i to increase once every day?
public void infect(){
    for (int i = 0; i < 8; i++){
    this.infection = true;
  if (i == 0){
  if ( i == 2){
    if(randNumGen.nextFloat() > .05)
    if (randNumGen.nextFloat() < .25){
  if (i == 6){
  if (i == 7){
    this.infection = false;}

Question: Dawn could you please clarify your answer to the previous question. We are having the same problem but we don't understand how make the current timestep as a parameter or even how to call it. We looked at the run() method in the Simulation class and it didn't really help us figure it out.

Thanks so much

Question: Is it normal to be getting "dry" runs on the simulation? Most of the time, the first time we run it after compiling, no one but the first gets infected. If we run it again, from the interactions pane without compiling it again, it usually runs fine but displays the result from running both the old world again and adding in the new world. Does this sound like a normal problem or would this be a problem with our code? I mean, if we change some things then it works really well killing many people and infecting many. If we change the area of infection or the probability of death then the disease is really deadly.
Yes, we are.

Question: Does a Typhoid Mary carrier (or an infected person who is not yet red) consider himself/herself to be healthy?
Since the instructions say a "healthy person" turns away from visibly sick people, does a Typhoid Mary turn away from a visibly sick person?|

Question: We have a question about the graphs. We looked through the slides and we understand how to write in the interactions pane to open a file but not how to tell the file what it should write. We looked at the lineForFile in DiseaseSimulation and saw that it outputted the number of infected but it didn't match the number that was in our excel sheet. Also how would we get it to also output another variable such as the number of dead. We already have it the code to make it show up in the interactions pane but we weren't sure how to make it show up in excel.

Question: How do you increment the days without using a time step?

Question: If a person can become healthy again after 7 days, can he get sick again? So does that person get added to the total number of sick people again or are they removed from the number of sick and then added again?

Is this line in act() in something we would use to make a healthy dude turn away from red dude?

Question: Is our code supposed to create a graph our do we do that manually with our averages?

Question: How do we get ALL the agents within a range? Not just the closest person in the range like when we use getClosest()?

Of course healthy people can get sick again. The number of infected should be the number infected at that time. No – look at the wolf and deer code for how to turn away. You graph in Excel as was shown in class MANY times. To get all agents in a range, use getAgents() to get all agents. Look at the simulation examples Mark Guzdial

Question: The political simulation only counts how many agents are in a range. I want to be able to have my current agent see if anyone in that range is infected and then get infected.

Question: It says the simulation is suppose to run for 100 timesteps, but we are only suppose to graph the first 30 days. So are we just graphing the first 30 timesteps or 3 timesteps equals 1 day?

Question/Rant: What the hell I've tried everything for the vaccination. I have a counter that will count the total amount of people that go infected at the end of the run. So when I vaccinate one of them I get 99 total infected if I run it for a long time to the point everyone dies. However, there isn't a turtle moving around my screen that represents the vaccinated person.

Why aren't you helping one another?

I am getting umpteen messages, asking me, "We're getting these results – is that normal?!?" Why aren't you all helping one another with this?!? We created the Gallery explicitly so that you could share your graphs. I expect to see a dozen graphs up there saying, "This is what we're getting for the base case – how about you?" and another half-dozen for each of the base health policies. Why aren't you helping one another by sharing your results?!? Mark Guzdial

Question: I have a question. Are we supposed to implement policy 1 and have 3 graphs of it. 3 graphs of no policy implementation. and 3 graphs of policy 2. (or is is supposed to be 3 graphs of policy 1 and 2).

Question: Are we turning in two different PersonAgent's? One with policy one and the second with policy two?

Question: How do we write our our results as a string?

Question: I can't find anywhere on the homework page that tells us we need to be outputting our results to a file. Will we be counted off if we do the graphs manually?

Link to this Page