Simulating Life

Just another UMass Boston Blogs site

Ritchey’s code review

| 4 Comments

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.

4 Comments

  1. 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

  2. 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.

  3. 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

  4. 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

Leave a Reply

Required fields are marked *.


Skip to toolbar