I create interactions for a predator prey model.
I have a victim who changes color based on the state he is currently in. The state I'm working on is “hiding” in which the prey is yellow. I have a predator that is trying to assess whether it can pursue a victim, I try to do this by evaluating the color of the victim, but it does not seem to work.
to chase
let target min-one-of prey [distance myself]
output-print target
ifelse target != yellow
[
output-print "chase"
]
[
output-print "ignore"
]
end
When I run the model, the predator constantly prints a “chase” - regardless of whether the prey is hidden or not.
Here is a hiding function.
to hiding
set color yellow
set energy (energy - 1)
if (count predators = 0)
[
output-print "safe"
]
end
Any help would be greatly appreciated.
source
share