| ||||||||||
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? |
1 public void act(){ 2 // Default action: wander aimlessly 3 4 // if the random number is > prob of NOT turning then turn 5 if (randNumGen.nextFloat() > PROB_OF_STAY) 6 this.turn(randNumGen.nextInt(360)); 7 8 // go forward some random amount 9 forward(randNumGen.nextInt(speed)); 10 } // end act()The most helpful line here would line 5 and is basically what you need to do except yours will probably be less than instead of greater than. Dawn Finney.
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. |
public class Student{ public void doAssignments(Assignment[] assignments){ for (int i = 0; i < assignments.length; i++){ complete(assignments[i]); } } public void complete(Assignment a){ ... } public void goOnSpringBreak(){ //defaults to the beach ... } } public class UGAStudent extends Student{ public void doAssignments(Assignment[] assignments){ for (int i = 0; i < assignments.length; i++){ party(); } } public void party(){ ... } public void goOnSpringBreak(Destination place){ ... } }UGAStudent overrides doAssignments but does not override goOnSpringBreak. Dawn Finney.
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\HWPersonAgent.java [line: 184] Error: cannot find symbol symbol : variable getBodyColor location: class HWPersonAgentWhy 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? |
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 withif(randNumGen.nextFloat() > PROB_OF_TM) this.setColor(Color.red);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. |
if (assigned == false){ assigned = true; if(randNumGen.nextFloat() > PROB_OF_TM){ tmcarrier = false; this.setColor(Color.red); } else{ tmcarrier = true; } }Dawn Finney.
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){ this.setColor(Color.lightGray);} if ( i == 2){ if(randNumGen.nextFloat() > .05) this.setColor(Color.red); if(i==5){ if (randNumGen.nextFloat() < .25){ this.dead=true;}} if (i == 6){ this.setColor(Color.lightGray);} 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 |
1. public void run(int timeRange){ 2. // For storing the current agent 3. Agent current = null; 4. 5. // Set up the simulation 6. this.setUp(); 7. 8. // loop for a set number of timesteps 9. for (int t = 0; t < timeRange; t++){ 10. // loop through all the agents, and have them 11. // act() 12. for (int index=0; index < agents.size(); index++) { 13. current = (Agent) agents.get(index); 14. current.act(t); // pass in timestep 15. } 16. // Could separate acting from updating... 17. 18. // repaint the world to show the movement 19. // IF there is a world 20. if (world != null) { 21. world.repaint();} 22. 23. // Do the end of step processing 24. this.endStep(t); 25. 26. // Wait for one second 27. //Thread.sleep(1000); 28. } 29. }The important lines to look at here are 9 - 15. REMOVEDe 9, 28: The outer for loop will repeat for the amount of timesteps specified by the user. REMOVEDe 12, 15: The inner for loop will go through all of the Agents and have them act each timestep. REMOVEDe 14: Notice how the timestep is passed into the act method. Dawn Finney.
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? |
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? |
Question: this.turn(randNumGen.nextInt(360));Is this line in act() in agent.java 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. |
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? |