Shawkat
Shawkat

Reputation: 31

Netlogo ...compare a a turtle variable to patch variable on which it is standing

I would like to compare a turtle variable with the patch variable on which it is standing.

 ask  patches with [ pcolor = green and inventory > 0]

[ ask one-of turtles-here [if myself [ conviction] > detection )

Conviction is a turtle variable and detection is a patch variable. Can it be done. This is my first posting. So apologies if the format is not correct.

Upvotes: 3

Views: 313

Answers (1)

Nicolas Payette
Nicolas Payette

Reputation: 14972

A turtles has direct access to the variables of the patch under it:

turtles-own [ conviction ]
patches-own [ detection ]

to go
  ask patches [
    ask one-of turtles-here [
      if conviction > detection [ ; the turtle accesses both variables directly
        ; do something
      ]
    ]
  ]
end

Upvotes: 3

Related Questions