I set up my code so that on collision with the fire, all of the agents turn green and have to head straight to the hospital for “cure”. On collision with the hospital, they have a 10 percent chance of dying, otherwise, they survive, which cause them to go back to their original colors (blue for males and red for females). The problem that I notice in the simulation is that I have “green” agents floating around, meaning that somehow they haven’t gotten any cure nor died. I am not sure how to fix it yet, but I’m assuming that the problem has to do with the “on collision” part because the code that makes them head to the hospital works, however, when they collide with the hospital, they don’t get cured or die.
Ritchey’s code review
March 30, 2017 | 4 Comments
April 1, 2017 at 12:41 pm
I see your problem – the fire code is AOK
it’s the hospital code
as written,
if they hit a hospital:
– if they’re lime, they have a 20% chance of dying
– but if they don’t die, nothing happens to them!
– if they’re not lime, they turn blue
you want
in collision
if my color = lime {
if random 10 < 2 {
delete
} else {
turn blue
}
}
the else turn me blue belongs as part of the random thingy
April 2, 2017 at 2:51 pm
also, even if you fixed it as above, every cured person would be blue! You need to give them a trait of sex = 1 for females and =0 for males and use that to restore their color.
August 1, 2024 at 9:52 am
I set up my code so that on collision with the fire, all of the agents turn green and have to head straight to the hospital for “cure”. On collision with the hospital, they have a 10 percent chance of dying, otherwise, they survive, which ca All Rights Reserved 2024 Theme: Fairy by arabuloku
November 23, 2024 at 6:22 am
that makes them head to the hospital works, however, when they collide with the hospital, they don’t get cured or die? Visit us Ilmu Komunikasi