Prit Tuntisak
Prit Tuntisak

Reputation: 51

NetLogo: Is there any way to change patch colour under turtles which dies?

I wrote a simulation which contain ants and spiders. spider will kill ants and not things will happens however spider will take some of ant venom and reduces health. At some certain point spider will die after there energy is equal 0 . I want spider to die and change patch colours under death spider from black to brown

I have tried this code but it didn't work .spider just disappear (die) but pcolor is not change

to spider-death  
  if energy  <= 0 [ask antiagents-here [die if pcolor = black [set pcolor brown]]]
end

please help

Upvotes: 0

Views: 436

Answers (1)

Seth Tisue
Seth Tisue

Reputation: 30453

After an agent dies, it no longer exists, and therefore can no longer take any actions.

So for example:

ask turtles [
  die
  print "hello!"
]

Nothing will ever be printed, because the turtle dies before it can print anything.

So in your code, you just need to change this part:

die if pcolor = black [set pcolor brown]

to:

if pcolor = black [set pcolor brown] die

Upvotes: 2

Related Questions