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

FinalExam Review Fall2005: Slow! Sick People Crossing!

Questions? Comments? Answers?
(Back to Final Exam Review Fall2005)


public void act()
{
// Is there a person within infection range of me?
PersonAgent closePerson = (PersonAgent) getClosest(20,
simulation.getAgents());

if (closePerson != null) {
// If this person is infected, and I'm not infected
if (closePerson.infection & !this.infection) {
// I become infected
this.infect();
}
if (infection = true)
{speed = speed.25;}
}

// Run the normal act() – wander aimlessly
super.act();
}Kyle REMOVED
is not sure about that one, would it make more sense to put it in the infect() method? If we did that would it change the speed permanently for everyone?

If you do it this way, a sick person would get 75% slower each time step. It would only take two or three time steps before they'd stop completely. BTW, did you mean == instead of =? Mark Guzdial


so how about if we just say
if (infection == true)
{speed = 25;}
Kyle DuPont

that is exactly what i did kyle. I was going to ask the same thing, can we just do speed = 25? Removed at KS request

Why not put the line speed = 0.25 * speed;right after this.infect();? Then it only occurs once, when the person gets infected.Mark Guzdial



Link to this Page