Hello i will try to be quick I have a room with a fire that expands , and i have two exits , all i want to do is say to agents that if a door is blocked by fire then to go to the other one. i came up with something like this but not result.
to doorblock show count neighbors with [pcolor = 77] ;; the patch color of the two doors end ;;to go ask smarts [ ;;smarts are the agents inside the room that need to get oout if [ doorblock > 5 ] [ set target one-of sexits]] ;;sexits is the other door
Anyone got a better idea? Thanks
OK, so if I understood correctly, you want your agents to take a look at the door that is their current target, check if that door has more than 5 fire agents around it, and choose another target door if that is the case.
If your fire agents are just red turtles (with no specific breed), you probably want something like this:
ask smarts [ if count ([ turtles-on neighbors ] of target) with [ color = red ] > 5 [ if-else ([ breed ] of target = sexits ) [ set target one-of nexits ] [ set target one-of sexits ] ] ]
The key primitives here are:
neighbors
, that will give you the patches around a turtle (the patches around target
, in this case) turtles-on
, that will give you the turtles that are on members of a patch set (here, that will be the turtles that are on the patches that are the neighbors
of target
) - and finally,
with
allows you to get only the turtles from an agentset that satisfy some condition (here, we use it to get only the red turtles that represent the fires).
You should also try to understand the of
primitive.
And I guessed you wanted to assign a new target that was of a different breed than the previous one (south if north, north if south) but that's up to you.