Ask the Turtle to rate the color of the different Turtle breeds.

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.

+4
source share
1 answer

( ) "", ,

[color] of target

 to chase
 let target nearest-of prey
 output-print target
 ifelse [color] of target != yellow 
 [

  output-print "chase"
 ]
 [
 output-print "ignore"
 ]

, , object.variable, "C".

+2

Source: https://habr.com/ru/post/1615901/


All Articles