I am trying to compare the local variables of a turtle, with its neighbors and trying to find out the total number of neighbors which match this criterion total-nearby = total number of neighbors. I am checking according to the color of the turtles, if the color is different, then I will check for the attributes/variables Error: A patch can't access a turtle or link variable without specifying which agent
CODE:
turtle-own[
total-similar-nearby ; sum of previous two variables
total-other-nearby
total-nearby
native
language
income
maritalstatus
]
;;then assigning multiple number of turtles with different values to the local variables.
ask turtles[
repeat total-nearby
[
if color = [color] of one-of neighbors
[set d1 d1 + 1]
if color != [color] of one-of neighbors
[
if native = [ native ] of one-of neighbors
[set a 1]
if language = [ language ] of one-of neighbors
[set b 1]
if income = [ income ] of one-of neighbors
[set c 1]
if maritalstatus = [ maritalstatus ] of one-of neighbors
[set d 1]
] set p a + b + c + d
if p >= 50 [set d1 d1 + 1]
]
]
neighborsis apatchvariable, not aturtlevariable. So, the turtles in your model use the primitiveneighbors, they are querying an agentset of patches when they want to query an agentset of turtles. There are several ways for turtles to evaluate nearby turtles, suchin-radiusorin-cone, but in this case if you're wanting the turtles that are specifically on the patches directly adjacent, you could use theother,turtles-on, andneighborsprimitives to get what you're looking for. For a simple example, have a look at this toy model:Check out the dictionary definitions for other, turtles-on, and neighbors for more information.